From patchwork Thu Jan 12 10:00:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 9512487 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 87A6A601E5 for ; Thu, 12 Jan 2017 10:01:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A4B8285D2 for ; Thu, 12 Jan 2017 10:01:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6D35B28632; Thu, 12 Jan 2017 10:01:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 87B3C285D2 for ; Thu, 12 Jan 2017 10:01:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751240AbdALKBD (ORCPT ); Thu, 12 Jan 2017 05:01:03 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:36563 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750872AbdALKBC (ORCPT ); Thu, 12 Jan 2017 05:01:02 -0500 Received: by mail-wm0-f68.google.com with SMTP id r126so2516453wmr.3 for ; Thu, 12 Jan 2017 02:01:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=szeredi.hu; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=WpVWCdnPEynIMOj9JLX1K6TEyylhlBnqHxK7X4UsNpo=; b=Nh9PyPZwnkKAhH+QLN5J0i1W2X3h49wZ4opudmEY6V5TaKfeT7gvML+bZpfX0czM0l MTsW6NnYcNsF0wM6pnOVdPrG1UQUQJrCqUYI4pwkHmrOqeCF4vKvQCwIdk38RDb3MY7p i4Zeq5gVPDEe8Slkyw0G1t2l0FZjaWO8lRAwE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=WpVWCdnPEynIMOj9JLX1K6TEyylhlBnqHxK7X4UsNpo=; b=RuLy7U4EGa0MHZRF4j5BOCcbATxH2cDGb/gNIraN04FKqCI2uLmcFIaZHoWPnPuQoJ 0wnJic1WgrB/MiQVi0ywACG1G3cwwy0NYoojHnoLZPkdnGxZJGfo/9FqXMKnJPi3EjI+ 96E+I4YuO+6mqVwY4KtOFnGJwoTLFiiPsrZOhdyCd+/aCcvE0ZVO/KwXdBonLOrv8cez 5WDlltctNnidc1J7pbB25ZJGw2J4wm6O3XpHGUuYPEvoJcyziRWWJI1cvpH3I6enYZG5 C/u+7BpjqE9LRePh2mE7yE4+DjDfjzGqciQjUYGyJ3/er5pExJM/YMmSyIq6Er6G3W2T fUtg== X-Gm-Message-State: AIkVDXKt9Sz0fPpyWFsi04vTxy8eyHqzzYAJHY6Tz8zX3A+g2Pd0e2Pl80ok/0PohMX4GA== X-Received: by 10.28.93.74 with SMTP id r71mr7510237wmb.67.1484215260155; Thu, 12 Jan 2017 02:01:00 -0800 (PST) Received: from veci.piliscsaba.szeredi.hu (pool-dsl-2c-0018.externet.hu. [217.173.44.24]) by smtp.gmail.com with ESMTPSA id x135sm2272066wme.23.2017.01.12.02.00.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Jan 2017 02:00:59 -0800 (PST) Date: Thu, 12 Jan 2017 11:00:56 +0100 From: Miklos Szeredi To: Amir Goldstein Cc: Al Viro , Konstantin Khlebnikov , "linux-unionfs@vger.kernel.org" , linux-fsdevel Subject: Re: [RFC][PATH 4/4] ovl: relax lock_rename when moving files between work and upper dir Message-ID: <20170112100056.GF27207@veci.piliscsaba.szeredi.hu> References: <20161110235444.GO19539@ZenIV.linux.org.uk> <20161111002756.GP19539@ZenIV.linux.org.uk> <20161111154034.GR19539@ZenIV.linux.org.uk> <20161111172737.GS19539@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.7.1 (2016-10-04) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Thu, Jan 12, 2017 at 07:42:22AM +0200, Amir Goldstein wrote: > I think you suggested here to use a waitqueue for pending copyups? > Did you mean a waitqueue per overlay parent directory inode or > did you mean something else? Something like this: --- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/overlayfs/ovl_entry.h b/fs/overlayfs/ovl_entry.h index d14bca1850d9..a46e7e53cd7a 100644 --- a/fs/overlayfs/ovl_entry.h +++ b/fs/overlayfs/ovl_entry.h @@ -27,6 +27,7 @@ struct ovl_fs { struct ovl_config config; /* creds of process who forced instantiation of super block */ const struct cred *creator_cred; + wait_queue_head_t copyup_wq; }; /* private information held for every overlayfs dentry */ @@ -38,6 +39,7 @@ struct ovl_entry { u64 version; const char *redirect; bool opaque; + bool copying; }; struct rcu_head rcu; }; diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c index 952286f4826c..4e2b2c485165 100644 --- a/fs/overlayfs/util.c +++ b/fs/overlayfs/util.c @@ -263,3 +263,32 @@ struct file *ovl_path_open(struct path *path, int flags) { return dentry_open(path, flags | O_NOATIME, current_cred()); } + +int ovl_copy_up_start(struct dentry *dentry) +{ + struct ovl_fs *ofs = dentry->d_sb->s_fs_info; + struct ovl_entry *oe = dentry->d_fsdata; + int err; + + spin_lock(&ofs->copyup_wq.lock); + err = wait_event_interruptible_locked(ofs->copyup_wq, !oe->copying); + if (!err) { + if (oe->__upperdentry) + err = 1; /* Already copied up */ + else + oe->copying = true; + } + spin_unlock(&ofs->copyup_wq.lock); + + return err; +} + +void ovl_copy_up_end(struct dentry *dentry) +{ + struct ovl_fs *ofs = dentry->d_sb->s_fs_info; + struct ovl_entry *oe = dentry->d_fsdata; + + spin_lock(&ofs->copyup_wq.lock); + oe->copying = false; + spin_unlock(&ofs->copyup_wq.lock); +}