Re: [RFC v2] fs: Don't create file when open() with O_DIRECT if fs not support

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

 



On Sat, Jul 29, 2017 at 02:29:58AM +0800, weiping zhang wrote:
> Some filesystems not support O_DIRECT, when user open with O_DIRECT ,
> an errno -EINVAL return to userspace by open_check_o_direct, but the
> file has been created, it's a strange thing. Add a checking for that
> can avoid creating file if fs not support O_DIRECT.

>  		if (error)
>  			goto out_dput;
> +		/* if fs not support direct io, delete this inode */
> +		if (unlikely(open_flag & O_DIRECT) &&
> +			!(dentry->d_inode->i_mapping &&
> +			dentry->d_inode->i_mapping->a_ops &&
> +			dentry->d_inode->i_mapping->a_ops->direct_IO) &&
> +			dir_inode->i_op->unlink) {
> +			error = dir_inode->i_op->unlink(dir_inode, dentry);
> +			if (error == 0)
> +				error = -EINVAL;
> +			goto out_dput;

Surely it's better to change the prototype of ->create to take open_flag
(like atomic_open does) and then have the filesystem check for O_DIRECT?
This solution seems quite inelegant to me.



[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