From patchwork Thu Apr 16 14:43:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 6226631 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 391EEBF4A6 for ; Thu, 16 Apr 2015 14:43:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 539CE202E9 for ; Thu, 16 Apr 2015 14:43:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4BF9A202FF for ; Thu, 16 Apr 2015 14:43:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933553AbbDPOnH (ORCPT ); Thu, 16 Apr 2015 10:43:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55055 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932168AbbDPOnG (ORCPT ); Thu, 16 Apr 2015 10:43:06 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t3GEh4lN002666 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 16 Apr 2015 10:43:04 -0400 Received: from warthog.procyon.org.uk ([10.3.112.12]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t3GEh0RT004446; Thu, 16 Apr 2015 10:43:01 -0400 Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [PATCH 2/4] Overlayfs: Convert own ->d_inode to d_inode() or d_really_is_positive/negative() From: David Howells To: viro@zeniv.linux.org.uk, miklos@szeredi.hu Cc: dhowells@redhat.com, linux-fsdevel@vger.kernel.org, linux-unionfs@vger.kernel.org Date: Thu, 16 Apr 2015 15:43:00 +0100 Message-ID: <20150416144300.12620.93012.stgit@warthog.procyon.org.uk> In-Reply-To: <20150416144241.12620.85836.stgit@warthog.procyon.org.uk> References: <20150416144241.12620.85836.stgit@warthog.procyon.org.uk> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Convert instances of dentry->d_inode that refer to an overlay filesystem's own inodes to d_inode(dentry), d_really_is_positive() or d_really_is_negative() as appropriate. Where dentry->d_inode refers to a subordinate filesystem, even if that subordinate is itself an overlay, other accessors should be used. These will be addressed in a separate patch. Signed-off-by: David Howells --- fs/overlayfs/dir.c | 15 ++++++++------- fs/overlayfs/super.c | 10 +++++----- 2 files changed, 13 insertions(+), 12 deletions(-) -- 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/dir.c b/fs/overlayfs/dir.c index d139405d2bfa..7b15d88d704e 100644 --- a/fs/overlayfs/dir.c +++ b/fs/overlayfs/dir.c @@ -54,7 +54,7 @@ static struct dentry *ovl_whiteout(struct dentry *workdir, { int err; struct dentry *whiteout; - struct inode *wdir = workdir->d_inode; + struct inode *wdir = d_inode(workdir); whiteout = ovl_lookup_temp(workdir, dentry); if (IS_ERR(whiteout)) @@ -75,7 +75,7 @@ int ovl_create_real(struct inode *dir, struct dentry *newdentry, { int err; - if (newdentry->d_inode) + if (d_really_is_positive(newdentry)) return -ESTALE; if (hardlink) { @@ -106,7 +106,8 @@ int ovl_create_real(struct inode *dir, struct dentry *newdentry, err = -EPERM; } } - if (!err && WARN_ON(!newdentry->d_inode)) { + + if (!err && WARN_ON(d_really_is_negative(newdentry))) { /* * Not quite sure if non-instantiated dentry is legal or not. * VFS doesn't seem to care so check and warn here. @@ -145,7 +146,7 @@ static int ovl_dir_getattr(struct vfsmount *mnt, struct dentry *dentry, return err; stat->dev = dentry->d_sb->s_dev; - stat->ino = dentry->d_inode->i_ino; + stat->ino = d_inode(dentry)->i_ino; /* * It's probably not worth it to count subdirs to get the @@ -715,7 +716,7 @@ static int ovl_rename2(struct inode *olddir, struct dentry *old, if (OVL_TYPE_MERGE_OR_LOWER(old_type) && is_dir) goto out; - if (new->d_inode) { + if (d_really_is_positive(new)) { err = ovl_check_sticky(new); if (err) goto out; @@ -798,14 +799,14 @@ static int ovl_rename2(struct inode *olddir, struct dentry *old, if (overwrite) { if (old_opaque) { - if (new->d_inode || !new_opaque) { + if (d_really_is_positive(new) || !new_opaque) { /* Whiteout source */ flags |= RENAME_WHITEOUT; } else { /* Switch whiteouts */ flags |= RENAME_EXCHANGE; } - } else if (is_dir && !new->d_inode && new_opaque) { + } else if (is_dir && d_really_is_negative(new) && new_opaque) { flags |= RENAME_EXCHANGE; cleanup_whiteout = true; } diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c index d5f7117caf5e..c1ae2b5e1f4e 100644 --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c @@ -224,7 +224,7 @@ void ovl_dentry_version_inc(struct dentry *dentry) { struct ovl_entry *oe = dentry->d_fsdata; - WARN_ON(!mutex_is_locked(&dentry->d_inode->i_mutex)); + WARN_ON(!mutex_is_locked(&d_inode(dentry)->i_mutex)); oe->version++; } @@ -232,13 +232,13 @@ u64 ovl_dentry_version_get(struct dentry *dentry) { struct ovl_entry *oe = dentry->d_fsdata; - WARN_ON(!mutex_is_locked(&dentry->d_inode->i_mutex)); + WARN_ON(!mutex_is_locked(&d_inode(dentry)->i_mutex)); return oe->version; } bool ovl_is_whiteout(struct dentry *dentry) { - struct inode *inode = dentry->d_inode; + struct inode *inode = d_inode(dentry); return inode && IS_WHITEOUT(inode); } @@ -247,7 +247,7 @@ static bool ovl_is_opaquedir(struct dentry *dentry) { int res; char val; - struct inode *inode = dentry->d_inode; + struct inode *inode = d_inode(dentry); if (!S_ISDIR(inode->i_mode) || !inode->i_op->getxattr) return false; @@ -409,7 +409,7 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry, /* * If this is a non-directory then stop here. */ - if (!S_ISDIR(this->d_inode->i_mode)) + if (!S_ISDIR(d_inode(this)->i_mode)) opaque = true; stack[ctr].dentry = this;