* [PATCH] f2fs: add ioctl to expose current features
@ 2017-07-21 20:11 Jaegeuk Kim
2017-07-21 21:20 ` Andreas Dilger
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Jaegeuk Kim @ 2017-07-21 20:11 UTC (permalink / raw)
To: linux-kernel, linux-fsdevel, linux-f2fs-devel; +Cc: Jaegeuk Kim
This patch adds an ioctl to provide feature information to user.
For exapmle, SQLite can use this ioctl to detect whether f2fs support atomic
write or not.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
fs/f2fs/f2fs.h | 2 ++
fs/f2fs/file.c | 13 +++++++++++++
2 files changed, 15 insertions(+)
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index e06d4e4b4579..5c46a462b56e 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -112,6 +112,7 @@ struct f2fs_mount_info {
#define F2FS_FEATURE_ENCRYPT 0x0001
#define F2FS_FEATURE_BLKZONED 0x0002
+#define F2FS_FEATURE_ATOMIC_WRITE 0x0004
#define F2FS_HAS_FEATURE(sb, mask) \
((F2FS_SB(sb)->raw_super->feature & cpu_to_le32(mask)) != 0)
@@ -308,6 +309,7 @@ static inline bool __has_cursum_space(struct f2fs_journal *journal,
struct f2fs_flush_device)
#define F2FS_IOC_GARBAGE_COLLECT_RANGE _IOW(F2FS_IOCTL_MAGIC, 11, \
struct f2fs_gc_range)
+#define F2FS_IOC_GET_FEATURES _IOR(F2FS_IOCTL_MAGIC, 12, __u32)
#define F2FS_IOC_SET_ENCRYPTION_POLICY FS_IOC_SET_ENCRYPTION_POLICY
#define F2FS_IOC_GET_ENCRYPTION_POLICY FS_IOC_GET_ENCRYPTION_POLICY
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 2706130c261b..0e07b5b18cfa 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -2384,6 +2384,16 @@ static int f2fs_ioc_flush_device(struct file *filp, unsigned long arg)
return ret;
}
+static int f2fs_ioc_get_features(struct file *filp, unsigned long arg)
+{
+ struct inode *inode = file_inode(filp);
+ u32 sb_feature = le32_to_cpu(F2FS_I_SB(inode)->raw_super->feature);
+
+ /* Must validate to set it with SQLite behavior in Android. */
+ sb_feature |= F2FS_FEATURE_ATOMIC_WRITE;
+
+ return put_user(sb_feature, (u32 __user *)arg);
+}
long f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
@@ -2426,6 +2436,8 @@ long f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
return f2fs_ioc_move_range(filp, arg);
case F2FS_IOC_FLUSH_DEVICE:
return f2fs_ioc_flush_device(filp, arg);
+ case F2FS_IOC_GET_FEATURES:
+ return f2fs_ioc_get_features(filp, arg);
default:
return -ENOTTY;
}
@@ -2491,6 +2503,7 @@ long f2fs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
case F2FS_IOC_DEFRAGMENT:
case F2FS_IOC_MOVE_RANGE:
case F2FS_IOC_FLUSH_DEVICE:
+ case F2FS_IOC_GET_FEATURES:
break;
default:
return -ENOIOCTLCMD;
--
2.13.0.rc1.294.g07d810a77f-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] f2fs: add ioctl to expose current features
2017-07-21 20:11 [PATCH] f2fs: add ioctl to expose current features Jaegeuk Kim
@ 2017-07-21 21:20 ` Andreas Dilger
2017-07-21 23:01 ` Jaegeuk Kim
2017-07-26 14:02 ` [f2fs-dev] " Chao Yu
2017-07-26 14:06 ` Chao Yu
2 siblings, 1 reply; 5+ messages in thread
From: Andreas Dilger @ 2017-07-21 21:20 UTC (permalink / raw)
To: Jaegeuk Kim; +Cc: lkml, linux-fsdevel, linux-f2fs-devel
[-- Attachment #1: Type: text/plain, Size: 3276 bytes --]
> On Jul 21, 2017, at 2:11 PM, Jaegeuk Kim <jaegeuk@kernel.org> wrote:
>
> This patch adds an ioctl to provide feature information to user.
> For exapmle, SQLite can use this ioctl to detect whether f2fs support atomic
> write or not.
Just for reference, ext4 exposes functionality that the kernel supports via
a file in /sys/fs/ext4/features/{feature_name} so that it is possible to
check [ -e /sys/fs/ext4/features/lazy_itable_init ] in a shell script also.
There are also per-filesystem tunables in /sys/fs/ext4/{device}/ and it
wouldn't be a bad idea to expose per-filesystem features something like
/sys/fs/{fstype}/{device}/features/{feature_name} so that it is easily
checked by userspace tools using [ -e $feature ] in bash or access()
in programs rather than an ioctl.
Cheers, Andreas
>
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> ---
> fs/f2fs/f2fs.h | 2 ++
> fs/f2fs/file.c | 13 +++++++++++++
> 2 files changed, 15 insertions(+)
>
> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> index e06d4e4b4579..5c46a462b56e 100644
> --- a/fs/f2fs/f2fs.h
> +++ b/fs/f2fs/f2fs.h
> @@ -112,6 +112,7 @@ struct f2fs_mount_info {
>
> #define F2FS_FEATURE_ENCRYPT 0x0001
> #define F2FS_FEATURE_BLKZONED 0x0002
> +#define F2FS_FEATURE_ATOMIC_WRITE 0x0004
>
> #define F2FS_HAS_FEATURE(sb, mask) \
> ((F2FS_SB(sb)->raw_super->feature & cpu_to_le32(mask)) != 0)
> @@ -308,6 +309,7 @@ static inline bool __has_cursum_space(struct f2fs_journal *journal,
> struct f2fs_flush_device)
> #define F2FS_IOC_GARBAGE_COLLECT_RANGE _IOW(F2FS_IOCTL_MAGIC, 11, \
> struct f2fs_gc_range)
> +#define F2FS_IOC_GET_FEATURES _IOR(F2FS_IOCTL_MAGIC, 12, __u32)
>
> #define F2FS_IOC_SET_ENCRYPTION_POLICY FS_IOC_SET_ENCRYPTION_POLICY
> #define F2FS_IOC_GET_ENCRYPTION_POLICY FS_IOC_GET_ENCRYPTION_POLICY
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index 2706130c261b..0e07b5b18cfa 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -2384,6 +2384,16 @@ static int f2fs_ioc_flush_device(struct file *filp, unsigned long arg)
> return ret;
> }
>
> +static int f2fs_ioc_get_features(struct file *filp, unsigned long arg)
> +{
> + struct inode *inode = file_inode(filp);
> + u32 sb_feature = le32_to_cpu(F2FS_I_SB(inode)->raw_super->feature);
> +
> + /* Must validate to set it with SQLite behavior in Android. */
> + sb_feature |= F2FS_FEATURE_ATOMIC_WRITE;
> +
> + return put_user(sb_feature, (u32 __user *)arg);
> +}
>
> long f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
> {
> @@ -2426,6 +2436,8 @@ long f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
> return f2fs_ioc_move_range(filp, arg);
> case F2FS_IOC_FLUSH_DEVICE:
> return f2fs_ioc_flush_device(filp, arg);
> + case F2FS_IOC_GET_FEATURES:
> + return f2fs_ioc_get_features(filp, arg);
> default:
> return -ENOTTY;
> }
> @@ -2491,6 +2503,7 @@ long f2fs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
> case F2FS_IOC_DEFRAGMENT:
> case F2FS_IOC_MOVE_RANGE:
> case F2FS_IOC_FLUSH_DEVICE:
> + case F2FS_IOC_GET_FEATURES:
> break;
> default:
> return -ENOIOCTLCMD;
> --
> 2.13.0.rc1.294.g07d810a77f-goog
>
Cheers, Andreas
[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] f2fs: add ioctl to expose current features
2017-07-21 21:20 ` Andreas Dilger
@ 2017-07-21 23:01 ` Jaegeuk Kim
0 siblings, 0 replies; 5+ messages in thread
From: Jaegeuk Kim @ 2017-07-21 23:01 UTC (permalink / raw)
To: Andreas Dilger; +Cc: lkml, linux-fsdevel, linux-f2fs-devel
On 07/21, Andreas Dilger wrote:
> > On Jul 21, 2017, at 2:11 PM, Jaegeuk Kim <jaegeuk@kernel.org> wrote:
> >
> > This patch adds an ioctl to provide feature information to user.
> > For exapmle, SQLite can use this ioctl to detect whether f2fs support atomic
> > write or not.
>
> Just for reference, ext4 exposes functionality that the kernel supports via
> a file in /sys/fs/ext4/features/{feature_name} so that it is possible to
> check [ -e /sys/fs/ext4/features/lazy_itable_init ] in a shell script also.
Thank you for the info. I'll write a patch to expose sysfs entries as well. :)
For sqlite in Android, I think ioctl would be a simpler interface to check the
feature flag rather than to open another sysfs files, regarding to latency and
additional selinux changes.
>
> There are also per-filesystem tunables in /sys/fs/ext4/{device}/ and it
> wouldn't be a bad idea to expose per-filesystem features something like
> /sys/fs/{fstype}/{device}/features/{feature_name} so that it is easily
> checked by userspace tools using [ -e $feature ] in bash or access()
> in programs rather than an ioctl.
Yeah, agreed.
Thanks,
>
> Cheers, Andreas
>
> >
> > Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> > ---
> > fs/f2fs/f2fs.h | 2 ++
> > fs/f2fs/file.c | 13 +++++++++++++
> > 2 files changed, 15 insertions(+)
> >
> > diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> > index e06d4e4b4579..5c46a462b56e 100644
> > --- a/fs/f2fs/f2fs.h
> > +++ b/fs/f2fs/f2fs.h
> > @@ -112,6 +112,7 @@ struct f2fs_mount_info {
> >
> > #define F2FS_FEATURE_ENCRYPT 0x0001
> > #define F2FS_FEATURE_BLKZONED 0x0002
> > +#define F2FS_FEATURE_ATOMIC_WRITE 0x0004
> >
> > #define F2FS_HAS_FEATURE(sb, mask) \
> > ((F2FS_SB(sb)->raw_super->feature & cpu_to_le32(mask)) != 0)
> > @@ -308,6 +309,7 @@ static inline bool __has_cursum_space(struct f2fs_journal *journal,
> > struct f2fs_flush_device)
> > #define F2FS_IOC_GARBAGE_COLLECT_RANGE _IOW(F2FS_IOCTL_MAGIC, 11, \
> > struct f2fs_gc_range)
> > +#define F2FS_IOC_GET_FEATURES _IOR(F2FS_IOCTL_MAGIC, 12, __u32)
> >
> > #define F2FS_IOC_SET_ENCRYPTION_POLICY FS_IOC_SET_ENCRYPTION_POLICY
> > #define F2FS_IOC_GET_ENCRYPTION_POLICY FS_IOC_GET_ENCRYPTION_POLICY
> > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> > index 2706130c261b..0e07b5b18cfa 100644
> > --- a/fs/f2fs/file.c
> > +++ b/fs/f2fs/file.c
> > @@ -2384,6 +2384,16 @@ static int f2fs_ioc_flush_device(struct file *filp, unsigned long arg)
> > return ret;
> > }
> >
> > +static int f2fs_ioc_get_features(struct file *filp, unsigned long arg)
> > +{
> > + struct inode *inode = file_inode(filp);
> > + u32 sb_feature = le32_to_cpu(F2FS_I_SB(inode)->raw_super->feature);
> > +
> > + /* Must validate to set it with SQLite behavior in Android. */
> > + sb_feature |= F2FS_FEATURE_ATOMIC_WRITE;
> > +
> > + return put_user(sb_feature, (u32 __user *)arg);
> > +}
> >
> > long f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
> > {
> > @@ -2426,6 +2436,8 @@ long f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
> > return f2fs_ioc_move_range(filp, arg);
> > case F2FS_IOC_FLUSH_DEVICE:
> > return f2fs_ioc_flush_device(filp, arg);
> > + case F2FS_IOC_GET_FEATURES:
> > + return f2fs_ioc_get_features(filp, arg);
> > default:
> > return -ENOTTY;
> > }
> > @@ -2491,6 +2503,7 @@ long f2fs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
> > case F2FS_IOC_DEFRAGMENT:
> > case F2FS_IOC_MOVE_RANGE:
> > case F2FS_IOC_FLUSH_DEVICE:
> > + case F2FS_IOC_GET_FEATURES:
> > break;
> > default:
> > return -ENOIOCTLCMD;
> > --
> > 2.13.0.rc1.294.g07d810a77f-goog
> >
>
>
> Cheers, Andreas
>
>
>
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [f2fs-dev] [PATCH] f2fs: add ioctl to expose current features
2017-07-21 20:11 [PATCH] f2fs: add ioctl to expose current features Jaegeuk Kim
2017-07-21 21:20 ` Andreas Dilger
@ 2017-07-26 14:02 ` Chao Yu
2017-07-26 14:06 ` Chao Yu
2 siblings, 0 replies; 5+ messages in thread
From: Chao Yu @ 2017-07-26 14:02 UTC (permalink / raw)
To: Jaegeuk Kim, linux-kernel, linux-fsdevel, linux-f2fs-devel
On 2017/7/22 4:11, Jaegeuk Kim wrote:
> This patch adds an ioctl to provide feature information to user.
> For exapmle, SQLite can use this ioctl to detect whether f2fs support atomic
> write or not.
>
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Thanks,
> ---
> fs/f2fs/f2fs.h | 2 ++
> fs/f2fs/file.c | 13 +++++++++++++
> 2 files changed, 15 insertions(+)
>
> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> index e06d4e4b4579..5c46a462b56e 100644
> --- a/fs/f2fs/f2fs.h
> +++ b/fs/f2fs/f2fs.h
> @@ -112,6 +112,7 @@ struct f2fs_mount_info {
>
> #define F2FS_FEATURE_ENCRYPT 0x0001
> #define F2FS_FEATURE_BLKZONED 0x0002
> +#define F2FS_FEATURE_ATOMIC_WRITE 0x0004
>
> #define F2FS_HAS_FEATURE(sb, mask) \
> ((F2FS_SB(sb)->raw_super->feature & cpu_to_le32(mask)) != 0)
> @@ -308,6 +309,7 @@ static inline bool __has_cursum_space(struct f2fs_journal *journal,
> struct f2fs_flush_device)
> #define F2FS_IOC_GARBAGE_COLLECT_RANGE _IOW(F2FS_IOCTL_MAGIC, 11, \
> struct f2fs_gc_range)
> +#define F2FS_IOC_GET_FEATURES _IOR(F2FS_IOCTL_MAGIC, 12, __u32)
>
> #define F2FS_IOC_SET_ENCRYPTION_POLICY FS_IOC_SET_ENCRYPTION_POLICY
> #define F2FS_IOC_GET_ENCRYPTION_POLICY FS_IOC_GET_ENCRYPTION_POLICY
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index 2706130c261b..0e07b5b18cfa 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -2384,6 +2384,16 @@ static int f2fs_ioc_flush_device(struct file *filp, unsigned long arg)
> return ret;
> }
>
> +static int f2fs_ioc_get_features(struct file *filp, unsigned long arg)
> +{
> + struct inode *inode = file_inode(filp);
> + u32 sb_feature = le32_to_cpu(F2FS_I_SB(inode)->raw_super->feature);
> +
> + /* Must validate to set it with SQLite behavior in Android. */
> + sb_feature |= F2FS_FEATURE_ATOMIC_WRITE;
> +
> + return put_user(sb_feature, (u32 __user *)arg);
> +}
>
> long f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
> {
> @@ -2426,6 +2436,8 @@ long f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
> return f2fs_ioc_move_range(filp, arg);
> case F2FS_IOC_FLUSH_DEVICE:
> return f2fs_ioc_flush_device(filp, arg);
> + case F2FS_IOC_GET_FEATURES:
> + return f2fs_ioc_get_features(filp, arg);
> default:
> return -ENOTTY;
> }
> @@ -2491,6 +2503,7 @@ long f2fs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
> case F2FS_IOC_DEFRAGMENT:
> case F2FS_IOC_MOVE_RANGE:
> case F2FS_IOC_FLUSH_DEVICE:
> + case F2FS_IOC_GET_FEATURES:
> break;
> default:
> return -ENOIOCTLCMD;
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [f2fs-dev] [PATCH] f2fs: add ioctl to expose current features
2017-07-21 20:11 [PATCH] f2fs: add ioctl to expose current features Jaegeuk Kim
2017-07-21 21:20 ` Andreas Dilger
2017-07-26 14:02 ` [f2fs-dev] " Chao Yu
@ 2017-07-26 14:06 ` Chao Yu
2 siblings, 0 replies; 5+ messages in thread
From: Chao Yu @ 2017-07-26 14:06 UTC (permalink / raw)
To: Jaegeuk Kim, linux-kernel, linux-fsdevel, linux-f2fs-devel
Hi Jaegeuk,
I noted that the patch ("f2fs: give a try to do atomic write in -ENOMEM case")
hasn't been sent to mailing list before been merged.
Could you please send it out, and please add:
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Thanks,
On 2017/7/22 4:11, Jaegeuk Kim wrote:
> This patch adds an ioctl to provide feature information to user.
> For exapmle, SQLite can use this ioctl to detect whether f2fs support atomic
> write or not.
>
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> ---
> fs/f2fs/f2fs.h | 2 ++
> fs/f2fs/file.c | 13 +++++++++++++
> 2 files changed, 15 insertions(+)
>
> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> index e06d4e4b4579..5c46a462b56e 100644
> --- a/fs/f2fs/f2fs.h
> +++ b/fs/f2fs/f2fs.h
> @@ -112,6 +112,7 @@ struct f2fs_mount_info {
>
> #define F2FS_FEATURE_ENCRYPT 0x0001
> #define F2FS_FEATURE_BLKZONED 0x0002
> +#define F2FS_FEATURE_ATOMIC_WRITE 0x0004
>
> #define F2FS_HAS_FEATURE(sb, mask) \
> ((F2FS_SB(sb)->raw_super->feature & cpu_to_le32(mask)) != 0)
> @@ -308,6 +309,7 @@ static inline bool __has_cursum_space(struct f2fs_journal *journal,
> struct f2fs_flush_device)
> #define F2FS_IOC_GARBAGE_COLLECT_RANGE _IOW(F2FS_IOCTL_MAGIC, 11, \
> struct f2fs_gc_range)
> +#define F2FS_IOC_GET_FEATURES _IOR(F2FS_IOCTL_MAGIC, 12, __u32)
>
> #define F2FS_IOC_SET_ENCRYPTION_POLICY FS_IOC_SET_ENCRYPTION_POLICY
> #define F2FS_IOC_GET_ENCRYPTION_POLICY FS_IOC_GET_ENCRYPTION_POLICY
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index 2706130c261b..0e07b5b18cfa 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -2384,6 +2384,16 @@ static int f2fs_ioc_flush_device(struct file *filp, unsigned long arg)
> return ret;
> }
>
> +static int f2fs_ioc_get_features(struct file *filp, unsigned long arg)
> +{
> + struct inode *inode = file_inode(filp);
> + u32 sb_feature = le32_to_cpu(F2FS_I_SB(inode)->raw_super->feature);
> +
> + /* Must validate to set it with SQLite behavior in Android. */
> + sb_feature |= F2FS_FEATURE_ATOMIC_WRITE;
> +
> + return put_user(sb_feature, (u32 __user *)arg);
> +}
>
> long f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
> {
> @@ -2426,6 +2436,8 @@ long f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
> return f2fs_ioc_move_range(filp, arg);
> case F2FS_IOC_FLUSH_DEVICE:
> return f2fs_ioc_flush_device(filp, arg);
> + case F2FS_IOC_GET_FEATURES:
> + return f2fs_ioc_get_features(filp, arg);
> default:
> return -ENOTTY;
> }
> @@ -2491,6 +2503,7 @@ long f2fs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
> case F2FS_IOC_DEFRAGMENT:
> case F2FS_IOC_MOVE_RANGE:
> case F2FS_IOC_FLUSH_DEVICE:
> + case F2FS_IOC_GET_FEATURES:
> break;
> default:
> return -ENOIOCTLCMD;
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-07-26 14:07 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-21 20:11 [PATCH] f2fs: add ioctl to expose current features Jaegeuk Kim
2017-07-21 21:20 ` Andreas Dilger
2017-07-21 23:01 ` Jaegeuk Kim
2017-07-26 14:02 ` [f2fs-dev] " Chao Yu
2017-07-26 14:06 ` Chao Yu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).