Re: races in ll_splice_alias() and elsewhere (ext4, ocfs2)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Mar 10, 2016 at 02:20:42AM +0000, Al Viro wrote:

> I'll pick it.  Mind if I fold it into the one I'd posted (with credits,
> obviously)?

Actually, it's still racy - there's a window between d_obtain_alias() and
ll_d_init() where it can be picked by d_splice_alias().

Sigh...  I'm really tempted to just add ->d_init() and let d_alloc() call it
if non-NULL.  

The question is what should it get and what should it be the method of...

How about
	int (*d_init)(struct dentry *);
in dentry_operations, with __d_alloc() ending with
        d_set_d_op(dentry, dentry->d_sb->s_d_op);
	if (unlikely(dentry->d_op && dentry->d_op->d_init)) {
		int err = dentry->d_op->d_init(dentry);
		if (unlikely(err)) {
			dentry_free(dentry);
			return ERR_PTR(err);
		}
	}
        this_cpu_inc(nr_dentry);

        return dentry;
}

Then lustre would simply have

int ll_d_init(struct dentry *de)
{
	struct ll_dentry_data *lld = kzalloc(sizeof(*lld), GFP_NOFS);
	if (unlikely(!lld))
		return -ENOMEM;
	lld->lld_invalid = 1;
	smp_wmb();	/* read barrier in whatever will find us */
	de->d_fsdata = lld;
        return 0;
}

as its ->d_init() and forget about all that mess.

Objections, better ideas?
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux