From patchwork Thu Dec 7 08:37:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Khalid Elmously X-Patchwork-Id: 845466 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 3yspmK4C82z9s84; Thu, 7 Dec 2017 19:38:41 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1eMrhV-0005LS-PH; Thu, 07 Dec 2017 08:38:37 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1eMrhB-00059E-Dc for kernel-team@lists.ubuntu.com; Thu, 07 Dec 2017 08:38:17 +0000 Received: from mail-it0-f69.google.com ([209.85.214.69]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1eMrhA-0006xK-Vx for kernel-team@lists.ubuntu.com; Thu, 07 Dec 2017 08:38:17 +0000 Received: by mail-it0-f69.google.com with SMTP id g202so9908295ita.4 for ; Thu, 07 Dec 2017 00:38:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=1eNh7WQ7Rwkr4nuxCTMNpxURV1UnOkZN5NikeLd+Bjo=; b=ieXB5jtlFni+LqY18rofzbYZgM6R+d5+/HBGdlA0IsGMVWD7xIA6y0UKIj7mSOpGwZ 2XM/YZTbbozPmB6VbZFSilz6kE8KbKs4gI58XQLETXGxaukhmyBtnY9tOobcQ6+qLxu0 9KxwNErJkDO3KgnCOLP9I/rnqbjKGPWtjFH555dqHfv60s0WqpsUyp/rL3m3cFGN5iXj fqOOvmEhKMTUsgqTFi/IKiT1vCUlSBTyNScwHU5X6Sj/a8PpA58D2riVkP9/XoaFkU8s Er1+6kpCp36kC/NIoVGxvAybqbFTphJRru5Og/mkQ8GBaMQf+J82XgTFCTD6qgnPKjE+ M7qw== X-Gm-Message-State: AKGB3mKFI/Q1Ghkrg3OUsbWSwdF/AGBDiDQE/uH9cfrDZeQyTgAzCsNW 3ccUs7MGi4tGax4JZBMXveKjPYmXFMMHKtIER9Nl+zxmj/9sytyO2QBYU99jdXn0jRXcuwOoF9j tXSvEhE4P1p5NPTJK5rVv54kka/DtpyiRc4OeFdenzg== X-Received: by 10.36.118.207 with SMTP id z198mr403967itb.21.1512635895439; Thu, 07 Dec 2017 00:38:15 -0800 (PST) X-Google-Smtp-Source: AGs4zMarhI+NdeQvY92swk+CCKLY88QCAyiXoOIyMUJonMssXJpF8uRTZ25QR09Nk+PbXP0pkXISVg== X-Received: by 10.36.118.207 with SMTP id z198mr403948itb.21.1512635895136; Thu, 07 Dec 2017 00:38:15 -0800 (PST) Received: from kbuntu.fuzzbuzz.org (198-84-180-157.cpe.teksavvy.com. [198.84.180.157]) by smtp.gmail.com with ESMTPSA id i203sm2551981itb.40.2017.12.07.00.38.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Dec 2017 00:38:14 -0800 (PST) From: Khalid Elmously To: kernel-team@lists.ubuntu.com Subject: [Xenial][PATCH 5/9] ceph: Get rid of d_find_alias in ceph_set_acl Date: Thu, 7 Dec 2017 03:37:53 -0500 Message-Id: <5f8ea252ff88ff1aca959e13e9c9ffd32a6ffff0.1512634014.git.khalid.elmously@canonical.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: References: In-Reply-To: References: X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" BugLink: http://bugs.launchpad.net/bugs/1415636 commit a26feccaba296bd0ae410eabce79cb3443c8a701 upstream. Create a variant of ceph_setattr that takes an inode instead of a dentry. Change __ceph_setxattr (and also __ceph_removexattr) to take an inode instead of a dentry. Use those in ceph_set_acl so that we no longer need a dentry there. Signed-off-by: Andreas Gruenbacher Signed-off-by: "Yan, Zheng" Signed-off-by: Al Viro Signed-off-by: Khalid Elmously --- fs/ceph/acl.c | 14 +++++--------- fs/ceph/inode.c | 12 +++++++----- fs/ceph/super.h | 5 ++--- fs/ceph/xattr.c | 28 ++++++++++++---------------- 4 files changed, 26 insertions(+), 33 deletions(-) diff --git a/fs/ceph/acl.c b/fs/ceph/acl.c index bdb9c94335f1..722c93f84ef4 100644 --- a/fs/ceph/acl.c +++ b/fs/ceph/acl.c @@ -88,7 +88,6 @@ int ceph_set_acl(struct inode *inode, struct posix_acl *acl, int type) char *value = NULL; struct iattr newattrs; umode_t new_mode = inode->i_mode, old_mode = inode->i_mode; - struct dentry *dentry; switch (type) { case ACL_TYPE_ACCESS: @@ -124,29 +123,26 @@ int ceph_set_acl(struct inode *inode, struct posix_acl *acl, int type) goto out_free; } - dentry = d_find_alias(inode); if (new_mode != old_mode) { newattrs.ia_mode = new_mode; newattrs.ia_valid = ATTR_MODE; - ret = __ceph_setattr(dentry, &newattrs); + ret = __ceph_setattr(inode, &newattrs); if (ret) - goto out_dput; + goto out_free; } - ret = __ceph_setxattr(dentry, name, value, size, 0); + ret = __ceph_setxattr(inode, name, value, size, 0); if (ret) { if (new_mode != old_mode) { newattrs.ia_mode = old_mode; newattrs.ia_valid = ATTR_MODE; - __ceph_setattr(dentry, &newattrs); + __ceph_setattr(inode, &newattrs); } - goto out_dput; + goto out_free; } ceph_set_cached_acl(inode, type, acl); -out_dput: - dput(dentry); out_free: kfree(value); out: diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index 9f0d99094cc1..5db076410d23 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -1773,13 +1773,12 @@ static const struct inode_operations ceph_symlink_iops = { /* * setattr */ -int __ceph_setattr(struct dentry *dentry, struct iattr *attr) +int __ceph_setattr(struct inode *inode, struct iattr *attr) { - struct inode *inode = d_inode(dentry); struct ceph_inode_info *ci = ceph_inode(inode); const unsigned int ia_valid = attr->ia_valid; struct ceph_mds_request *req; - struct ceph_mds_client *mdsc = ceph_sb_to_client(dentry->d_sb)->mdsc; + struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc; struct ceph_cap_flush *prealloc_cf; int issued; int release = 0, dirtied = 0; @@ -1998,16 +1997,19 @@ int __ceph_setattr(struct dentry *dentry, struct iattr *attr) int ceph_setattr(struct dentry *dentry, struct iattr *attr) { + struct inode *inode = d_inode(dentry); + int err; - err = __ceph_setattr(dentry, attr); + err = __ceph_setattr(inode, attr); if (err >= 0 && (attr->ia_valid & ATTR_MODE)) - err = posix_acl_chmod(d_inode(dentry), attr->ia_mode); + err = posix_acl_chmod(inode, attr->ia_mode); return err; } + /* * Verify that we have a lease on the given mask. If not, * do a getattr against an mds. diff --git a/fs/ceph/super.h b/fs/ceph/super.h index 2793ae2c0ff6..209e16d43c33 100644 --- a/fs/ceph/super.h +++ b/fs/ceph/super.h @@ -788,7 +788,7 @@ static inline int ceph_do_getattr(struct inode *inode, int mask, bool force) return __ceph_do_getattr(inode, NULL, mask, force); } extern int ceph_permission(struct inode *inode, int mask); -extern int __ceph_setattr(struct dentry *dentry, struct iattr *attr); +extern int __ceph_setattr(struct inode *inode, struct iattr *attr); extern int ceph_setattr(struct dentry *dentry, struct iattr *attr); extern int ceph_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat); @@ -796,9 +796,8 @@ extern int ceph_getattr(struct vfsmount *mnt, struct dentry *dentry, /* xattr.c */ extern int ceph_setxattr(struct dentry *, const char *, const void *, size_t, int); -int __ceph_setxattr(struct dentry *, const char *, const void *, size_t, int); +int __ceph_setxattr(struct inode *, const char *, const void *, size_t, int); ssize_t __ceph_getxattr(struct inode *, const char *, void *, size_t); -int __ceph_removexattr(struct dentry *, const char *); extern ssize_t ceph_getxattr(struct dentry *, struct inode *, const char *, void *, size_t); extern ssize_t ceph_listxattr(struct dentry *, char *, size_t); extern int ceph_removexattr(struct dentry *, const char *); diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c index 4e4d0b7df85a..0f122130f68c 100644 --- a/fs/ceph/xattr.c +++ b/fs/ceph/xattr.c @@ -846,11 +846,10 @@ out: return err; } -static int ceph_sync_setxattr(struct dentry *dentry, const char *name, +static int ceph_sync_setxattr(struct inode *inode, const char *name, const char *value, size_t size, int flags) { - struct ceph_fs_client *fsc = ceph_sb_to_client(dentry->d_sb); - struct inode *inode = d_inode(dentry); + struct ceph_fs_client *fsc = ceph_sb_to_client(inode->i_sb); struct ceph_inode_info *ci = ceph_inode(inode); struct ceph_mds_request *req; struct ceph_mds_client *mdsc = fsc->mdsc; @@ -908,13 +907,12 @@ out: return err; } -int __ceph_setxattr(struct dentry *dentry, const char *name, +int __ceph_setxattr(struct inode *inode, const char *name, const void *value, size_t size, int flags) { - struct inode *inode = d_inode(dentry); struct ceph_vxattr *vxattr; struct ceph_inode_info *ci = ceph_inode(inode); - struct ceph_mds_client *mdsc = ceph_sb_to_client(dentry->d_sb)->mdsc; + struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc; struct ceph_cap_flush *prealloc_cf = NULL; int issued; int err; @@ -1018,7 +1016,7 @@ do_sync: do_sync_unlocked: if (lock_snap_rwsem) up_read(&mdsc->snap_rwsem); - err = ceph_sync_setxattr(dentry, name, value, size, flags); + err = ceph_sync_setxattr(inode, name, value, size, flags); out: ceph_free_cap_flush(prealloc_cf); kfree(newname); @@ -1039,14 +1037,13 @@ int ceph_setxattr(struct dentry *dentry, const char *name, if (size == 0) value = ""; /* empty EA, do not remove */ - return __ceph_setxattr(dentry, name, value, size, flags); + return __ceph_setxattr(d_inode(dentry), name, value, size, flags); } -static int ceph_send_removexattr(struct dentry *dentry, const char *name) +static int ceph_send_removexattr(struct inode *inode, const char *name) { - struct ceph_fs_client *fsc = ceph_sb_to_client(dentry->d_sb); + struct ceph_fs_client *fsc = ceph_sb_to_client(inode->i_sb); struct ceph_mds_client *mdsc = fsc->mdsc; - struct inode *inode = d_inode(dentry); struct ceph_mds_request *req; int err; @@ -1067,12 +1064,11 @@ static int ceph_send_removexattr(struct dentry *dentry, const char *name) return err; } -int __ceph_removexattr(struct dentry *dentry, const char *name) +static int __ceph_removexattr(struct inode *inode, const char *name) { - struct inode *inode = d_inode(dentry); struct ceph_vxattr *vxattr; struct ceph_inode_info *ci = ceph_inode(inode); - struct ceph_mds_client *mdsc = ceph_sb_to_client(dentry->d_sb)->mdsc; + struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc; struct ceph_cap_flush *prealloc_cf = NULL; int issued; int err; @@ -1153,7 +1149,7 @@ do_sync_unlocked: if (lock_snap_rwsem) up_read(&mdsc->snap_rwsem); ceph_free_cap_flush(prealloc_cf); - err = ceph_send_removexattr(dentry, name); + err = ceph_send_removexattr(inode, name); return err; } @@ -1165,5 +1161,5 @@ int ceph_removexattr(struct dentry *dentry, const char *name) if (!strncmp(name, XATTR_SYSTEM_PREFIX, XATTR_SYSTEM_PREFIX_LEN)) return generic_removexattr(dentry, name); - return __ceph_removexattr(dentry, name); + return __ceph_removexattr(d_inode(dentry), name); }