Re: [PATCH 2/5] iomap: add per-iomap_iter private data

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

 





On 4.05.22 г. 19:23 ч., Christoph Hellwig wrote:
Allow the file system to keep state for all iterations.  For now only
wire it up for direct I/O as there is an immediate need for it there.

Signed-off-by: Christoph Hellwig <hch@xxxxxx>
---
  fs/iomap/direct-io.c  | 8 ++++++++
  include/linux/iomap.h | 1 +
  2 files changed, 9 insertions(+)

diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c
index 15929690d89e3..355abe2eacc6a 100644
--- a/fs/iomap/direct-io.c
+++ b/fs/iomap/direct-io.c
@@ -520,6 +520,14 @@ __iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
  	dio->submit.waiter = current;
  	dio->submit.poll_bio = NULL;
+ /*
+	 * Transfer the private data that was passed by the caller to the
+	 * iomap_iter, and clear it in the iocb, as iocb->private will be
+	 * used for polled bio completion later.
+	 */
+	iomi.private = iocb->private;
+	WRITE_ONCE(iocb->private, NULL);

nit: Why use WRITE_ONCE here? Generaly when it's used it will suggest to the reader something funny is going on with accessing that variable without holding a particular lock?

+
  	if (iov_iter_rw(iter) == READ) {
  		if (iomi.pos >= dio->i_size)
  			goto out_free_dio;
diff --git a/include/linux/iomap.h b/include/linux/iomap.h
index a5483020dad41..109c055865f73 100644
--- a/include/linux/iomap.h
+++ b/include/linux/iomap.h
@@ -188,6 +188,7 @@ struct iomap_iter {
  	unsigned flags;
  	struct iomap iomap;
  	struct iomap srcmap;
+	void *private;
  };
int iomap_iter(struct iomap_iter *iter, const struct iomap_ops *ops);



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux