Skip to contentSkip to conversation

Add kernel AIO support for CIFS

PATCH New Pavel Shilovsky 1 participant 4 messages Apr 25, 2017 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover Add kernel AIO support for CIFS

This patchset adds kernel AIO support for CIFS module. Currently the code processes all read and write requests synchronously regardless of existence of iocb->ki_complete() callback. It is not what kernel AIO expects when a user submits i/o calls through io_submit() interface. That's why new aio context was introduced: it allowed to process i/o responses in a separate thread and return to the caller immediately if ki_complete() is specified. For synchronous variants the code simply needs to wait in the current thread until aio context processing is completed.

The work scope is divided into two parts for reading and writing. With these patches applied i/o performance benefits from increasing of i/o queue depth size (e.g. in FIO).

The checkpatch.pl script shows 2 warnings related to using of ENOSYS error code but fixing this is out of scope of this patchset (we have plenty of places that use ENOSYS for the same logic and they all should be fixed at once).

Changes since v1:
- move async i/o context introduction to a separate patch
- use preallocated page array and iov_iter_get_pages
- call kmalloc for allocations less than 1MB and vmalloc for others
- minor cleanup

Pavel Shilovsky (3):
CIFS: Add asynchronous context to support kernel AIO
CIFS: Add asynchronous read support through kernel AIO
CIFS: Add asynchronous write support through kernel AIO

 fs/cifs/cifsglob.h  |  19 +++
 fs/cifs/cifsproto.h |   3 +
 fs/cifs/file.c      | 357 +++++++++++++++++++++++++++++++++++++++-------------
 fs/cifs/misc.c      | 120 ++++++++++++++++++
 4 files changed, 409 insertions(+), 90 deletions(-)
Signature · 1 line
2.7.4

A message that is not in the archive (sent off-list or not yet received): 1493146351-124933-1-git-send-email-pshilov-0li6OtcxBFHby3iVrkZq2A@public.gmane.org

#2 lore raw

PATCH v2 1/3 CIFS: Add asynchronous context to support kernel AIO

Currently the code doesn't recognize asynchronous calls passed by io_submit() and processes all calls synchronously. This is not what kernel AIO expects. This patch introduces a new async context that keeps track of all issued i/o requests and moves a response collecting procedure to a separate thread. This allows to return to a caller immediately for async calls and call iocb->ki_complete() once all requests are completed. For sync calls the current thread simply waits until all requests are completed.

---
 fs/cifs/cifsglob.h  |  16 +++++++
 fs/cifs/cifsproto.h |   3 ++
 fs/cifs/misc.c      | 120 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 139 insertions(+)
fs/cifs/cifsglob.h +16 -0
index 37f5a41..bb41226 100644
@@ -1115,6 +1115,22 @@ struct cifs_io_parms {
 	struct cifs_tcon *tcon;
 };
 
+struct cifs_aio_ctx {
+	struct kref		refcount;
+	struct list_head	list;
+	struct mutex		aio_mutex;
+	struct completion	done;
+	struct iov_iter		iter;
+	struct kiocb		*iocb;
+	struct cifsFileInfo	*cfile;
+	struct bio_vec		*bv;
+	unsigned int		npages;
+	ssize_t			rc;
+	unsigned int		len;
+	unsigned int		total_len;
+	bool			should_dirty;
+};
+
 struct cifs_readdata;
 
 /* asynchronous read support */
fs/cifs/cifsproto.h +3 -0
index 97e5d23..e49958c 100644
@@ -535,4 +535,7 @@ int __cifs_calc_signature(struct smb_rqst *rqst,
 			struct shash_desc *shash);
 enum securityEnum cifs_select_sectype(struct TCP_Server_Info *,
 					enum securityEnum);
+struct cifs_aio_ctx *cifs_aio_ctx_alloc(void);
+void cifs_aio_ctx_release(struct kref *refcount);
+int setup_aio_ctx_iter(struct cifs_aio_ctx *ctx, struct iov_iter *iter, int rw);
 #endif			/* _CIFSPROTO_H */
fs/cifs/misc.c +120 -0

129 lines not on this page · raw message

Signature · 1 line
2.7.4
#3 lore raw

PATCH v2 2/3 CIFS: Add asynchronous read support through kernel AIO

In reply to a message not in the archive

This patch adds support to process read calls passed by io_submit() asynchronously. It based on the previously introduced async context that allows to process i/o responses in a separate thread and return the caller immediately for asynchronous calls.

This improves reading performance of single threaded applications with increasing of i/o queue depth size.

---
 fs/cifs/cifsglob.h |   1 +
 fs/cifs/file.c     | 169 ++++++++++++++++++++++++++++++++++++++++-------------
 2 files changed, 131 insertions(+), 39 deletions(-)
fs/cifs/cifsglob.h +1 -0
index bb41226..9438c7c 100644
@@ -1140,6 +1140,7 @@ struct cifs_readdata {
 	struct completion		done;
 	struct cifsFileInfo		*cfile;
 	struct address_space		*mapping;
+	struct cifs_aio_ctx		*ctx;
 	__u64				offset;
 	unsigned int			bytes;
 	unsigned int			got_bytes;
fs/cifs/file.c +130 -39

234 lines not on this page · raw message

Signature · 1 line
2.7.4
#4 lore raw

PATCH v2 3/3 CIFS: Add asynchronous write support through kernel AIO

In reply to a message not in the archive

This patch adds support to process write calls passed by io_submit() asynchronously. It based on the previously introduced async context that allows to process i/o responses in a separate thread and return the caller immediately for asynchronous calls.

This improves writing performance of single threaded applications with increasing of i/o queue depth size.

---
 fs/cifs/cifsglob.h |   2 +
 fs/cifs/file.c     | 188 ++++++++++++++++++++++++++++++++++++++---------------
 2 files changed, 139 insertions(+), 51 deletions(-)
fs/cifs/cifsglob.h +2 -0
index 9438c7c..5c0e11a 100644
@@ -1124,6 +1124,7 @@ struct cifs_aio_ctx {
 	struct kiocb		*iocb;
 	struct cifsFileInfo	*cfile;
 	struct bio_vec		*bv;
+	loff_t			pos;
 	unsigned int		npages;
 	ssize_t			rc;
 	unsigned int		len;
@@ -1171,6 +1172,7 @@ struct cifs_writedata {
 	enum writeback_sync_modes	sync_mode;
 	struct work_struct		work;
 	struct cifsFileInfo		*cfile;
+	struct cifs_aio_ctx		*ctx;
 	__u64				offset;
 	pid_t				pid;
 	unsigned int			bytes;
fs/cifs/file.c +137 -51

261 lines not on this page · raw message

Signature · 1 line
2.7.4