···525525 set_delayed_call() where it used to set *cookie.526526 ->put_link() is gone - just give the destructor to set_delayed_call()527527 in ->get_link().528528+--529529+[mandatory]530530+ ->getxattr() and xattr_handler.get() get dentry and inode passed separately.531531+ dentry might be yet to be attached to inode, so do _not_ use its ->d_inode532532+ in the instances. Rationale: !@#!@# security_d_instantiate() needs to be533533+ called before we attach dentry to inode.
···13601360 return ERR_PTR(error);13611361 }13621362 s = sget(&gfs2_fs_type, test_gfs2_super, set_meta_super, flags,13631363- d_inode(path.dentry)->i_sb->s_bdev);13631363+ path.dentry->d_sb->s_bdev);13641364 path_put(&path);13651365 if (IS_ERR(s)) {13661366 pr_warn("gfs2 mount does not exist\n");
···552552 * different read/write sizes for file systems known to have553553 * problems with large blocks */554554 if (nfserr == 0) {555555- struct super_block *sb = d_inode(argp->fh.fh_dentry)->i_sb;555555+ struct super_block *sb = argp->fh.fh_dentry->d_sb;556556557557 /* Note that we don't care for remote fs's here */558558 if (sb->s_magic == MSDOS_SUPER_MAGIC) {···588588 nfserr = fh_verify(rqstp, &argp->fh, 0, NFSD_MAY_NOP);589589590590 if (nfserr == 0) {591591- struct super_block *sb = d_inode(argp->fh.fh_dentry)->i_sb;591591+ struct super_block *sb = argp->fh.fh_dentry->d_sb;592592593593 /* Note that we don't care for remote fs's here */594594 switch (sb->s_magic) {
+1-1
fs/nfsd/nfs3xdr.c
···146146 default:147147 case FSIDSOURCE_DEV:148148 p = xdr_encode_hyper(p, (u64)huge_encode_dev149149- (d_inode(fhp->fh_dentry)->i_sb->s_dev));149149+ (fhp->fh_dentry->d_sb->s_dev));150150 break;151151 case FSIDSOURCE_FSID:152152 p = xdr_encode_hyper(p, (u64) fhp->fh_export->ex_fsid);
···5454#include "uptodate.h"5555#include "quota.h"5656#include "refcounttree.h"5757+#include "acl.h"57585859#include "buffer_head_io.h"5960···36233622 * them around in that case. */36243623 filemap_fdatawait(mapping);36253624 }36253625+36263626+ forget_all_cached_acls(inode);3626362736273628out:36283629 return UNBLOCK_CONTINUE;
···274274 if (!S_ISDIR(inode->i_mode) || !inode->i_op->getxattr)275275 return false;276276277277- res = inode->i_op->getxattr(dentry, OVL_XATTR_OPAQUE, &val, 1);277277+ res = inode->i_op->getxattr(dentry, inode, OVL_XATTR_OPAQUE, &val, 1);278278 if (res == 1 && val == 'y')279279 return true;280280
+76-42
fs/posix_acl.c
···2121#include <linux/export.h>2222#include <linux/user_namespace.h>23232424-struct posix_acl **acl_by_type(struct inode *inode, int type)2424+static struct posix_acl **acl_by_type(struct inode *inode, int type)2525{2626 switch (type) {2727 case ACL_TYPE_ACCESS:···3232 BUG();3333 }3434}3535-EXPORT_SYMBOL(acl_by_type);36353736struct posix_acl *get_cached_acl(struct inode *inode, int type)3837{3938 struct posix_acl **p = acl_by_type(inode, type);4040- struct posix_acl *acl = ACCESS_ONCE(*p);4141- if (acl) {4242- spin_lock(&inode->i_lock);4343- acl = *p;4444- if (acl != ACL_NOT_CACHED)4545- acl = posix_acl_dup(acl);4646- spin_unlock(&inode->i_lock);3939+ struct posix_acl *acl;4040+4141+ for (;;) {4242+ rcu_read_lock();4343+ acl = rcu_dereference(*p);4444+ if (!acl || is_uncached_acl(acl) ||4545+ atomic_inc_not_zero(&acl->a_refcount))4646+ break;4747+ rcu_read_unlock();4848+ cpu_relax();4749 }5050+ rcu_read_unlock();4851 return acl;4952}5053EXPORT_SYMBOL(get_cached_acl);···6259{6360 struct posix_acl **p = acl_by_type(inode, type);6461 struct posix_acl *old;6565- spin_lock(&inode->i_lock);6666- old = *p;6767- rcu_assign_pointer(*p, posix_acl_dup(acl));6868- spin_unlock(&inode->i_lock);6969- if (old != ACL_NOT_CACHED)6262+6363+ old = xchg(p, posix_acl_dup(acl));6464+ if (!is_uncached_acl(old))7065 posix_acl_release(old);7166}7267EXPORT_SYMBOL(set_cached_acl);73686969+static void __forget_cached_acl(struct posix_acl **p)7070+{7171+ struct posix_acl *old;7272+7373+ old = xchg(p, ACL_NOT_CACHED);7474+ if (!is_uncached_acl(old))7575+ posix_acl_release(old);7676+}7777+7478void forget_cached_acl(struct inode *inode, int type)7579{7676- struct posix_acl **p = acl_by_type(inode, type);7777- struct posix_acl *old;7878- spin_lock(&inode->i_lock);7979- old = *p;8080- *p = ACL_NOT_CACHED;8181- spin_unlock(&inode->i_lock);8282- if (old != ACL_NOT_CACHED)8383- posix_acl_release(old);8080+ __forget_cached_acl(acl_by_type(inode, type));8481}8582EXPORT_SYMBOL(forget_cached_acl);86838784void forget_all_cached_acls(struct inode *inode)8885{8989- struct posix_acl *old_access, *old_default;9090- spin_lock(&inode->i_lock);9191- old_access = inode->i_acl;9292- old_default = inode->i_default_acl;9393- inode->i_acl = inode->i_default_acl = ACL_NOT_CACHED;9494- spin_unlock(&inode->i_lock);9595- if (old_access != ACL_NOT_CACHED)9696- posix_acl_release(old_access);9797- if (old_default != ACL_NOT_CACHED)9898- posix_acl_release(old_default);8686+ __forget_cached_acl(&inode->i_acl);8787+ __forget_cached_acl(&inode->i_default_acl);9988}10089EXPORT_SYMBOL(forget_all_cached_acls);1019010291struct posix_acl *get_acl(struct inode *inode, int type)10392{9393+ void *sentinel;9494+ struct posix_acl **p;10495 struct posix_acl *acl;105969797+ /*9898+ * The sentinel is used to detect when another operation like9999+ * set_cached_acl() or forget_cached_acl() races with get_acl().100100+ * It is guaranteed that is_uncached_acl(sentinel) is true.101101+ */102102+106103 acl = get_cached_acl(inode, type);107107- if (acl != ACL_NOT_CACHED)104104+ if (!is_uncached_acl(acl))108105 return acl;109106110107 if (!IS_POSIXACL(inode))111108 return NULL;112109110110+ sentinel = uncached_acl_sentinel(current);111111+ p = acl_by_type(inode, type);112112+113113 /*114114- * A filesystem can force a ACL callback by just never filling the115115- * ACL cache. But normally you'd fill the cache either at inode116116- * instantiation time, or on the first ->get_acl call.114114+ * If the ACL isn't being read yet, set our sentinel. Otherwise, the115115+ * current value of the ACL will not be ACL_NOT_CACHED and so our own116116+ * sentinel will not be set; another task will update the cache. We117117+ * could wait for that other task to complete its job, but it's easier118118+ * to just call ->get_acl to fetch the ACL ourself. (This is going to119119+ * be an unlikely race.)120120+ */121121+ if (cmpxchg(p, ACL_NOT_CACHED, sentinel) != ACL_NOT_CACHED)122122+ /* fall through */ ;123123+124124+ /*125125+ * Normally, the ACL returned by ->get_acl will be cached.126126+ * A filesystem can prevent that by calling127127+ * forget_cached_acl(inode, type) in ->get_acl.117128 *118129 * If the filesystem doesn't have a get_acl() function at all, we'll119130 * just create the negative cache entry.···136119 set_cached_acl(inode, type, NULL);137120 return NULL;138121 }139139- return inode->i_op->get_acl(inode, type);122122+ acl = inode->i_op->get_acl(inode, type);123123+124124+ if (IS_ERR(acl)) {125125+ /*126126+ * Remove our sentinel so that we don't block future attempts127127+ * to cache the ACL.128128+ */129129+ cmpxchg(p, sentinel, ACL_NOT_CACHED);130130+ return acl;131131+ }132132+133133+ /*134134+ * Cache the result, but only if our sentinel is still in place.135135+ */136136+ posix_acl_dup(acl);137137+ if (unlikely(cmpxchg(p, sentinel, acl) != sentinel))138138+ posix_acl_release(acl);139139+ return acl;140140}141141EXPORT_SYMBOL(get_acl);142142···797763798764static int799765posix_acl_xattr_get(const struct xattr_handler *handler,800800- struct dentry *dentry, const char *name,801801- void *value, size_t size)766766+ struct dentry *unused, struct inode *inode,767767+ const char *name, void *value, size_t size)802768{803769 struct posix_acl *acl;804770 int error;805771806806- if (!IS_POSIXACL(d_backing_inode(dentry)))772772+ if (!IS_POSIXACL(inode))807773 return -EOPNOTSUPP;808808- if (d_is_symlink(dentry))774774+ if (S_ISLNK(inode->i_mode))809775 return -EOPNOTSUPP;810776811811- acl = get_acl(d_backing_inode(dentry), handler->flags);777777+ acl = get_acl(inode, handler->flags);812778 if (IS_ERR(acl))813779 return PTR_ERR(acl);814780 if (acl == NULL)
···158158 if (error) {159159 /*160160 * If the attribute doesn't exist make sure we have a negative161161- * cache entry, for any other error assume it is transient and162162- * leave the cache entry as ACL_NOT_CACHED.161161+ * cache entry, for any other error assume it is transient.163162 */164164- if (error == -ENOATTR)165165- goto out_update_cache;166166- acl = ERR_PTR(error);167167- goto out;163163+ if (error != -ENOATTR)164164+ acl = ERR_PTR(error);165165+ } else {166166+ acl = xfs_acl_from_disk(xfs_acl, len,167167+ XFS_ACL_MAX_ENTRIES(ip->i_mount));168168 }169169-170170- acl = xfs_acl_from_disk(xfs_acl, len, XFS_ACL_MAX_ENTRIES(ip->i_mount));171171- if (IS_ERR(acl))172172- goto out;173173-174174-out_update_cache:175175- set_cached_acl(inode, type, acl);176176-out:177169 kmem_free(xfs_acl);178170 return acl;179171}