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

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

 



On Mar 10, 2016, at 2:59 PM, Al Viro wrote:

> 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.  

In fact I was surprised this was not the case already and so people
needed to call it by hand in every possible case where a new dentry is possibly
originated leading to a bit of a mess (and some bugs).

The downside is that we do the allocation at all times even if the dentry is
going to be promptly destroyed because we found a better alias.

In this way calling it just like we do today, after d_exact_alias + d_splice_alias
is another option, I guess and saves us some alloc + free trouble and a minuscle
overhead reduction for filesystems (majority of the in-kerel ones) that don't
really need this init at all.

> 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