From: Christoph Hellwig <hch@lst.de>
To: linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org,
linux-block@vger.kernel.org
Subject: [PATCH 05/12] fs: add a F_IOINFO fcntl
Date: Tue, 28 Feb 2017 06:57:30 -0800 [thread overview]
Message-ID: <20170228145737.19016-6-hch@lst.de> (raw)
In-Reply-To: <20170228145737.19016-1-hch@lst.de>
This fcntl can be used to query I/O parameters for the given file
descriptor. Initially it is used for the I/O alignment and atomic
write parameters.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/fcntl.c | 18 ++++++++++++++++++
include/linux/fs.h | 1 +
include/uapi/linux/fcntl.h | 16 ++++++++++++++++
3 files changed, 35 insertions(+)
diff --git a/fs/fcntl.c b/fs/fcntl.c
index ca5d228be7ea..248fb4cc66a6 100644
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -241,6 +241,21 @@ static int f_getowner_uids(struct file *filp, unsigned long arg)
}
#endif
+static int fcntl_ioinfo(struct file *file, void __user *argp)
+{
+ struct fcntl_ioinfo fio = { 0, };
+
+ if (file->f_op->ioinfo) {
+ int ret = file->f_op->ioinfo(file, &fio);
+ if (ret)
+ return ret;
+ }
+
+ if (copy_to_user(argp, &fio, sizeof(fio)))
+ return -EFAULT;
+ return 0;
+}
+
static long do_fcntl(int fd, unsigned int cmd, unsigned long arg,
struct file *filp)
{
@@ -335,6 +350,9 @@ static long do_fcntl(int fd, unsigned int cmd, unsigned long arg,
case F_GET_SEALS:
err = shmem_fcntl(filp, cmd, arg);
break;
+ case F_IOINFO:
+ err = fcntl_ioinfo(filp, (void __user *)arg);
+ break;
default:
break;
}
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 2ba074328894..33b08a8c2bc3 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1680,6 +1680,7 @@ struct file_operations {
u64);
ssize_t (*dedupe_file_range)(struct file *, u64, u64, struct file *,
u64);
+ int (*ioinfo)(struct file *, struct fcntl_ioinfo *);
};
struct inode_operations {
diff --git a/include/uapi/linux/fcntl.h b/include/uapi/linux/fcntl.h
index beed138bd359..6b0aaba7c623 100644
--- a/include/uapi/linux/fcntl.h
+++ b/include/uapi/linux/fcntl.h
@@ -42,6 +42,22 @@
#define F_SEAL_WRITE 0x0008 /* prevent writes */
/* (1U << 31) is reserved for signed error codes */
+
+#define F_IOINFO (F_LINUX_SPECIFIC_BASE + 11)
+
+struct fcntl_ioinfo {
+ __u16 fio_flags; /* FIO_FL_* */
+ __u16 fio_alignment; /* required I/O alignment on disk */
+ __u32 __reserved1; /* must be zero */
+ __u64 fio_max_atomic; /* max size for atomic writes */
+ __u64 __reserved2[14];/* must be zero */
+};
+
+/* supports atomic writes using O_(D)SYNC */
+#define FIO_FL_ATOMIC_OSYNC (1 << 0)
+/* supports atomic writes committed using fsync/fdatasync/msync */
+#define FIO_FL_ATOMIC_FSYNC (1 << 1)
+
/*
* Types of directory notifications that may be requested.
*/
--
2.11.0
next prev parent reply other threads:[~2017-02-28 14:58 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-28 14:57 [RFC] failure atomic writes for file systems and block devices Christoph Hellwig
2017-02-28 14:57 ` [PATCH 01/12] uapi/fs: add O_ATOMIC to the open flags Christoph Hellwig
2017-02-28 14:57 ` [PATCH 02/12] iomap: pass IOMAP_* flags to actors Christoph Hellwig
2017-02-28 14:57 ` [PATCH 03/12] iomap: add a IOMAP_ATOMIC flag Christoph Hellwig
2017-02-28 14:57 ` [PATCH 04/12] fs: add a BH_Atomic flag Christoph Hellwig
2017-02-28 14:57 ` Christoph Hellwig [this message]
2017-02-28 16:51 ` [PATCH 05/12] fs: add a F_IOINFO fcntl Darrick J. Wong
2017-03-01 15:11 ` Christoph Hellwig
2017-02-28 14:57 ` [PATCH 06/12] xfs: cleanup is_reflink checks Christoph Hellwig
2017-02-28 14:57 ` [PATCH 07/12] xfs: implement failure-atomic writes Christoph Hellwig
2017-02-28 23:09 ` Darrick J. Wong
2017-03-01 15:17 ` Christoph Hellwig
2017-02-28 14:57 ` [PATCH 08/12] xfs: implement the F_IOINFO fcntl Christoph Hellwig
2017-02-28 14:57 ` [PATCH 09/12] block: advertize max atomic write limit Christoph Hellwig
2017-02-28 14:57 ` [PATCH 10/12] block_dev: set REQ_NOMERGE for O_ATOMIC writes Christoph Hellwig
2017-02-28 14:57 ` [PATCH 11/12] block_dev: implement the F_IOINFO fcntl Christoph Hellwig
2017-02-28 14:57 ` [PATCH 12/12] nvme: export the atomic write limit Christoph Hellwig
2017-02-28 20:48 ` [RFC] failure atomic writes for file systems and block devices Chris Mason
2017-03-01 15:07 ` Christoph Hellwig
2017-02-28 23:22 ` Darrick J. Wong
2017-03-01 15:09 ` Christoph Hellwig
2017-03-01 11:21 ` Amir Goldstein
2017-03-01 15:07 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170228145737.19016-6-hch@lst.de \
--to=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).