Skip to contentSkip to conversation

btrfs direct-io using iomap

PATCH Superseded Goldwyn Rodrigues 6 participants 22 messages Dec 5, 2019 – Dec 7, 2019

Subsystems (5)

v3 of 11 Superseded Latest is v11 →

lore
Share & tools
lore
#0 lore raw

v3 cover btrfs direct-io using iomap

This is an effort to use iomap for direct I/O in btrfs. This would change the call from __blockdev_direct_io() to iomap_dio_rw().

The main objective is to lose the buffer head and use bio defined by iomap code, and hopefully to use more of generic-FS codebase.

These patches are based on xfs/iomap-for-next, though I tested it against the patches on xfs/iomap-for-next on top of v5.4.1 (there are no changes to existing patches). The tree is available at
https://github.com/goldwynr/linux/tree/btrfs-iomap-dio

I have tested it against xfstests/btrfs.

Changes since v1
- Incorporated back the efficiency change for inode locking
- Review comments about coding style and git comments
- Merge related patches into one
- Direct read to go through btrfs_direct_IO()
- Removal of no longer used function dio_end_io()

Changes since v2
- aligning iomap offset/length to the position/length of I/O
- Removed btrfs_dio_data
- Removed BTRFS_INODE_READDIO_NEED_LOCK
- Re-incorporating write efficiency changes caused lockdep_assert() in iomap to be triggered, remove that code.

 fs/btrfs/btrfs_inode.h |   18 ---
 fs/btrfs/ctree.h       |    1 
 fs/btrfs/extent_io.c   |   37 ++----
 fs/btrfs/extent_io.h   |    2 
 fs/btrfs/file.c        |   21 +++
 fs/btrfs/inode.c       |  267 ++++++++++++++++---------------------------------
 fs/direct-io.c         |   19 ---
 fs/iomap/direct-io.c   |   16 +-
 include/linux/fs.h     |    3 
 include/linux/iomap.h  |    2 
 mm/filemap.c           |   13 +-
 11 files changed, 149 insertions(+), 250 deletions(-)
Signature · 1 line
Goldwyn
#1 lore raw

PATCH v3 1/8 fs: Export generic_file_buffered_read()

From: Goldwyn Rodrigues <[email protected]>

Export generic_file_buffered_read() to be used to
supplement incomplete direct reads.

While we are at it, correct the comments and variable names.

---
 include/linux/fs.h |  2 ++
 mm/filemap.c       | 13 +++++++------
 2 files changed, 9 insertions(+), 6 deletions(-)
include/linux/fs.h +2 -0
index e0d909d35763..5bc75cff3536 100644
@@ -3095,6 +3095,8 @@ extern int generic_file_rw_checks(struct file *file_in, struct file *file_out);
 extern int generic_copy_file_checks(struct file *file_in, loff_t pos_in,
 				    struct file *file_out, loff_t pos_out,
 				    size_t *count, unsigned int flags);
+extern ssize_t generic_file_buffered_read(struct kiocb *iocb,
+		struct iov_iter *to, ssize_t already_read);
 extern ssize_t generic_file_read_iter(struct kiocb *, struct iov_iter *);
 extern ssize_t __generic_file_write_iter(struct kiocb *, struct iov_iter *);
 extern ssize_t generic_file_write_iter(struct kiocb *, struct iov_iter *);
mm/filemap.c +7 -6
index 85b7d087eb45..ffabcb71e5ff 100644
@@ -1994,7 +1994,7 @@ static void shrink_readahead_size_eio(struct file *filp,
  * generic_file_buffered_read - generic file read routine
  * @iocb:	the iocb to read
  * @iter:	data destination
- * @written:	already copied
+ * @copied:	already copied
  *
  * This is a generic file read routine, and uses the
  * mapping->a_ops->readpage() function for the actual low-level stuff.
@@ -2003,11 +2003,11 @@ static void shrink_readahead_size_eio(struct file *filp,
  * of the logic when it comes to error handling etc.
  *
  * Return:
- * * total number of bytes copied, including those the were already @written
+ * * total number of bytes copied, including those that were @copied
  * * negative error code if nothing was copied
  */
-static ssize_t generic_file_buffered_read(struct kiocb *iocb,
-		struct iov_iter *iter, ssize_t written)
+ssize_t generic_file_buffered_read(struct kiocb *iocb,
+		struct iov_iter *iter, ssize_t copied)
 {
 	struct file *filp = iocb->ki_filp;
 	struct address_space *mapping = filp->f_mapping;
@@ -2148,7 +2148,7 @@ static ssize_t generic_file_buffered_read(struct kiocb *iocb,
 		prev_offset = offset;
 
 		put_page(page);
-		written += ret;
+		copied += ret;
 		if (!iov_iter_count(iter))
 			goto out;
 		if (ret < nr) {
@@ -2256,8 +2256,9 @@ static ssize_t generic_file_buffered_read(struct kiocb *iocb,
 
 	*ppos = ((loff_t)index << PAGE_SHIFT) + offset;
 	file_accessed(filp);
-	return written ? written : error;
+	return copied ? copied : error;
 }
+EXPORT_SYMBOL_GPL(generic_file_buffered_read);
 
 /**
  * generic_file_read_iter - generic filesystem read routine
Signature · 1 line
2.16.4
#2 lore raw

PATCH v3 2/8 iomap: add a filesystem hook for direct I/O bio submission

In reply to Goldwyn Rodrigues

From: Goldwyn Rodrigues <[email protected]>

This helps filesystems to perform tasks on the bio while submitting for I/O. This could be post-write operations such as data CRC or data replication for fs-handled RAID.

---
 fs/iomap/direct-io.c  | 14 +++++++++-----
 include/linux/iomap.h |  2 ++
 2 files changed, 11 insertions(+), 5 deletions(-)
fs/iomap/direct-io.c +9 -5
index b77ec2acb066..2dac380f88a0 100644
@@ -59,7 +59,7 @@ int iomap_dio_iopoll(struct kiocb *kiocb, bool spin)
 EXPORT_SYMBOL_GPL(iomap_dio_iopoll);
 
 static void iomap_dio_submit_bio(struct iomap_dio *dio, struct iomap *iomap,
-		struct bio *bio)
+		struct bio *bio, loff_t pos)
 {
 	atomic_inc(&dio->ref);
 
@@ -67,7 +67,11 @@ static void iomap_dio_submit_bio(struct iomap_dio *dio, struct iomap *iomap,
 		bio_set_polled(bio, dio->iocb);
 
 	dio->submit.last_queue = bdev_get_queue(iomap->bdev);
-	dio->submit.cookie = submit_bio(bio);
+	if (dio->dops && dio->dops->submit_io)
+		dio->submit.cookie = dio->dops->submit_io(bio,
+				dio->iocb->ki_filp, pos);
+	else
+		dio->submit.cookie = submit_bio(bio);
 }
 
 static ssize_t iomap_dio_complete(struct iomap_dio *dio)
@@ -191,7 +195,7 @@ iomap_dio_zero(struct iomap_dio *dio, struct iomap *iomap, loff_t pos,
 	get_page(page);
 	__bio_add_page(bio, page, len, 0);
 	bio_set_op_attrs(bio, REQ_OP_WRITE, flags);
-	iomap_dio_submit_bio(dio, iomap, bio);
+	iomap_dio_submit_bio(dio, iomap, bio, pos);
 }
 
 static loff_t
@@ -297,11 +301,11 @@ iomap_dio_bio_actor(struct inode *inode, loff_t pos, loff_t length,
 		iov_iter_advance(dio->submit.iter, n);
 
 		dio->size += n;
-		pos += n;
 		copied += n;
 
 		nr_pages = iov_iter_npages(&iter, BIO_MAX_PAGES);
-		iomap_dio_submit_bio(dio, iomap, bio);
+		iomap_dio_submit_bio(dio, iomap, bio, pos);
+		pos += n;
 	} while (nr_pages);
 
 	/*
include/linux/iomap.h +2 -0
index 8b09463dae0d..2b093a23ef1c 100644
@@ -252,6 +252,8 @@ int iomap_writepages(struct address_space *mapping,
 struct iomap_dio_ops {
 	int (*end_io)(struct kiocb *iocb, ssize_t size, int error,
 		      unsigned flags);
+	blk_qc_t (*submit_io)(struct bio *bio, struct file *file,
+			  loff_t file_offset);
 };
 
 ssize_t iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
Signature · 1 line
2.16.4
#3 lore raw

PATCH v3 3/8 iomap: Remove lockdep_assert_held()

In reply to Goldwyn Rodrigues

From: Goldwyn Rodrigues <[email protected]>

Filesystems such as btrfs can perform direct I/O without holding the inode->i_rwsem in some of the cases like writing within i_size. So, remove the check for lockdep_assert_held().

---
 fs/iomap/direct-io.c | 2 --
 1 file changed, 2 deletions(-)
fs/iomap/direct-io.c +0 -2
index 2dac380f88a0..dc420cb13878 100644
@@ -410,8 +410,6 @@ iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
 	struct blk_plug plug;
 	struct iomap_dio *dio;
 
-	lockdep_assert_held(&inode->i_rwsem);
-
 	if (!count)
 		return 0;
 
Signature · 1 line
2.16.4
#4 lore raw

PATCH v3 4/8 btrfs: Switch to iomap_dio_rw() for dio

In reply to Goldwyn Rodrigues

From: Goldwyn Rodrigues <[email protected]>

Switch from __blockdev_direct_IO() to iomap_dio_rw(). Rename btrfs_get_blocks_direct() to btrfs_dio_iomap_begin() and use it as iomap_begin() for iomap direct I/O functions. This function allocates and locks all the blocks required for the I/O. btrfs_submit_direct() is used as the submit_io() hook for direct I/O ops.

Since we need direct I/O reads to go through iomap_dio_rw(), we change file_operations.read_iter() to a btrfs_file_read_iter() which calls btrfs_direct_IO() for direct reads and falls back to generic_file_buffered_read() for incomplete reads and buffered reads.

We don't need address_space.direct_IO() anymore so set it to noop. Similarly, we don't need flags used in __blockdev_direct_IO(). iomap is capable of direct I/O reads from a hole, so we don't need to return -ENOENT.

---
 fs/btrfs/ctree.h |   1 +
 fs/btrfs/file.c  |  21 ++++++-
 fs/btrfs/inode.c | 182 ++++++++++++++++++++++++++-----------------------------
 3 files changed, 107 insertions(+), 97 deletions(-)
fs/btrfs/ctree.h +1 -0
index fe2b8765d9e6..cde8423673fc 100644
@@ -2903,6 +2903,7 @@ int btrfs_writepage_cow_fixup(struct page *page, u64 start, u64 end);
 void btrfs_writepage_endio_finish_ordered(struct page *page, u64 start,
 					  u64 end, int uptodate);
 extern const struct dentry_operations btrfs_dentry_operations;
+ssize_t btrfs_direct_IO(struct kiocb *iocb, struct iov_iter *iter);
 
 /* ioctl.c */
 long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
fs/btrfs/file.c +19 -2
index 435a502a3226..c9c83a1711ee 100644
@@ -1834,7 +1834,7 @@ static ssize_t __btrfs_direct_write(struct kiocb *iocb, struct iov_iter *from)
 	loff_t endbyte;
 	int err;
 
-	written = generic_file_direct_write(iocb, from);
+	written = btrfs_direct_IO(iocb, from);
 
 	if (written < 0 || !iov_iter_count(from))
 		return written;
@@ -3452,9 +3452,26 @@ static int btrfs_file_open(struct inode *inode, struct file *filp)
 	return generic_file_open(inode, filp);
 }
 
+static ssize_t btrfs_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
+{
+	ssize_t ret = 0;
+
+	if (iocb->ki_flags & IOCB_DIRECT) {
+		struct inode *inode = file_inode(iocb->ki_filp);
+
+		inode_lock_shared(inode);
+		ret = btrfs_direct_IO(iocb, to);
+		inode_unlock_shared(inode);
+		if (ret < 0)
+			return ret;
+	}
+
+	return generic_file_buffered_read(iocb, to, ret);
+}
+
 const struct file_operations btrfs_file_operations = {
 	.llseek		= btrfs_file_llseek,
-	.read_iter      = generic_file_read_iter,
+	.read_iter      = btrfs_file_read_iter,
 	.splice_read	= generic_file_splice_read,
 	.write_iter	= btrfs_file_write_iter,
 	.mmap		= btrfs_file_mmap,
fs/btrfs/inode.c +87 -95

338 lines not on this page · raw message

Signature · 1 line
2.16.4
#5 lore raw

Re: [PATCH 4/8] btrfs: Switch to iomap_dio_rw() for dio

On Thu, Dec 05, 2019 at 09:56:26AM -0600, Goldwyn Rodrigues wrote:
[...]

Quoted 5 lines
fs/btrfs/file.c +5 -0
+static ssize_t btrfs_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
+{
+	ssize_t ret = 0;
+
+	if (iocb->ki_flags & IOCB_DIRECT) {

fs/btrfs/file.c static int btrfs_file_open(struct inode *inode, struct file *filp) · line 3469

Quoted 10 lines
fs/btrfs/file.c +10 -0
+		struct inode *inode = file_inode(iocb->ki_filp);
+
+		inode_lock_shared(inode);
+		ret = btrfs_direct_IO(iocb, to);
+		inode_unlock_shared(inode);
+		if (ret < 0)
+			return ret;
+	}
+
+	return generic_file_buffered_read(iocb, to, ret);

This could as well call generic_file_read_iter() and would thus make patch 1 of this series obsolete. I think this is cleaner.

Thanks,
Johannes

#6 lore raw

Re: [PATCH 4/8] btrfs: Switch to iomap_dio_rw() for dio

Quoted 5 lines · Johannes Thumshirn

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+	return generic_file_buffered_read(iocb, to, ret);

This could as well call generic_file_read_iter() and would thus make patch 1 of this series obsolete. I think this is cleaner.

I actually much prefer exporting generic_file_buffered_read and will gladly switch other callers not needing the messy direct I/O handling in generic_file_read_iter over to generic_file_buffered_read once this series is merged.

#7 lore raw

Re: [PATCH 4/8] btrfs: Switch to iomap_dio_rw() for dio

Quoted 4 lines · Christoph Hellwig

I actually much prefer exporting generic_file_buffered_read and will gladly switch other callers not needing the messy direct I/O handling in generic_file_read_iter over to generic_file_buffered_read once this series is merged.

I think you misunderstood me here, I meant the code to be:

static ssize_t btrfs_file_read_iter(struct kiocb *iocb, struct iov_iter *to)

{
	ssize_t ret = 0;

	if (iocb->ki_flags & IOCB_DIRECT) {
		struct inode *inode = file_inode(iocb->ki_filp);

		inode_lock_shared(inode);
		ret = btrfs_direct_IO(iocb, to);
		inode_unlock_shared(inode);
		if (ret < 0)
			return ret;
		}
	}

	return generic_file_read_iter(icob, to);
}

This way an iocb that is no dio will end in generic_file_read_iter():

generic_file_read_iter(iocb, to)

{
	size_t count = iov_iter_count(iter);
        ssize_t retval = 0;

        if (!count)
                goto out; /* skip atime */

	if (iocb->ki_flags & IOCB_DIRECT) {
		skipped as flag is not set
	}

	retval = generic_file_buffered_read(iocb, iter, retval);
out:
	return retval;
}

Meaning we do not need to export generic_file_buffered_read() and still can skip the generic DIO madness.

Makes sense?

Johannes

#8 lore raw

Re: [PATCH 4/8] btrfs: Switch to iomap_dio_rw() for dio

Quoted 2 lines · Johannes Thumshirn

Meaning we do not need to export generic_file_buffered_read() and still can skip the generic DIO madness.

But why not export it? That way we call the function we want directly instead of through a wrapper that is entirely pointless for this case.

#9 lore raw

Re: [PATCH 4/8] btrfs: Switch to iomap_dio_rw() for dio

Quoted 6 lines · Christoph Hellwig
Quoted 2 lines · Johannes Thumshirn

Meaning we do not need to export generic_file_buffered_read() and still can skip the generic DIO madness.

But why not export it? That way we call the function we want directly instead of through a wrapper that is entirely pointless for this case.

To hide the implementation details and not provoke someone yelling layering violation?

#10 lore raw

Re: [PATCH 4/8] btrfs: Switch to iomap_dio_rw() for dio

Quoted 2 lines · Johannes Thumshirn

To hide the implementation details and not provoke someone yelling layering violation?

The only layering is ->direct_IO, and this is a step to get rid of that junk..

#11 lore raw

Re: [PATCH 4/8] btrfs: Switch to iomap_dio_rw() for dio

Quoted 6 lines · Christoph Hellwig
Quoted 2 lines · Johannes Thumshirn

To hide the implementation details and not provoke someone yelling layering violation?

The only layering is ->direct_IO, and this is a step to get rid of that junk..

s/layering/layering violation/

#12 lore raw

Re: [PATCH 4/8] btrfs: Switch to iomap_dio_rw() for dio

Quoted 9 lines · Christoph Hellwig
Quoted 6 lines · Christoph Hellwig
Quoted 2 lines · Johannes Thumshirn

To hide the implementation details and not provoke someone yelling layering violation?

The only layering is ->direct_IO, and this is a step to get rid of that junk..

s/layering/layering violation/

OK I admit defeat.

Byte,
Johannes

#13 lore raw

Re: [PATCH 4/8] btrfs: Switch to iomap_dio_rw() for dio

In reply to Johannes Thumshirn
Quoted 45 lines · Johannes Thumshirn
Quoted 4 lines · Christoph Hellwig

I actually much prefer exporting generic_file_buffered_read and will gladly switch other callers not needing the messy direct I/O handling in generic_file_read_iter over to generic_file_buffered_read once this series is merged.

I think you misunderstood me here, I meant the code to be:

static ssize_t btrfs_file_read_iter(struct kiocb *iocb, struct iov_iter *to)

{
	ssize_t ret = 0;

	if (iocb->ki_flags & IOCB_DIRECT) {
		struct inode *inode = file_inode(iocb->ki_filp);

		inode_lock_shared(inode);
		ret = btrfs_direct_IO(iocb, to);
		inode_unlock_shared(inode);
		if (ret < 0)
			return ret;
		}
	}

	return generic_file_read_iter(icob, to);
}

This way an iocb that is no dio will end in generic_file_read_iter():

generic_file_read_iter(iocb, to)

{
	size_t count = iov_iter_count(iter);
        ssize_t retval = 0;

        if (!count)
                goto out; /* skip atime */

	if (iocb->ki_flags & IOCB_DIRECT) {
		skipped as flag is not set
	}

	retval = generic_file_buffered_read(iocb, iter, retval);
out:
	return retval;
}
Quoted 4 lines

Meaning we do not need to export generic_file_buffered_read() and still can skip the generic DIO madness.

Makes sense?

For btrfs, DIO and buffered I/O is not mutually exclusive, since we fall back to buffered I/O in case of incomplete Direct I/O. In this case, the control will not skip IOCB_DIRECT branch.

Signature · 1 line
Goldwyn
#14 lore raw

Re: [PATCH 4/8] btrfs: Switch to iomap_dio_rw() for dio

In reply to Goldwyn Rodrigues
Quoted 14 lines · Goldwyn Rodrigues

From: Goldwyn Rodrigues <[email protected]>

Switch from __blockdev_direct_IO() to iomap_dio_rw(). Rename btrfs_get_blocks_direct() to btrfs_dio_iomap_begin() and use it as iomap_begin() for iomap direct I/O functions. This function allocates and locks all the blocks required for the I/O. btrfs_submit_direct() is used as the submit_io() hook for direct I/O ops.

Since we need direct I/O reads to go through iomap_dio_rw(), we change file_operations.read_iter() to a btrfs_file_read_iter() which calls btrfs_direct_IO() for direct reads and falls back to generic_file_buffered_read() for incomplete reads and buffered reads.

Quoted 4 lines

We don't need address_space.direct_IO() anymore so set it to noop. Similarly, we don't need flags used in __blockdev_direct_IO(). iomap is capable of direct I/O reads from a hole, so we don't need to return -ENOENT.

IMO it will be good to document in the changelog the lock context of the current scheme. E.g. it's done with inode lock held shared meaning it allows other DIO reads but not writes/truncates. (This is different than what we had up until now).

<nit>

#15 lore raw

Re: [PATCH 4/8] btrfs: Switch to iomap_dio_rw() for dio

In reply to Goldwyn Rodrigues
Thank you for the patch! Yet something to improve:

Hi Goldwyn,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on v5.4-rc8]
[cannot apply to xfs-linux/for-next btrfs/next linus/master next-20191207] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Goldwyn-Rodrigues/btrfs-direct-io-using-iomap/20191207-133923
base:    af42d3466bdc8f39806b26f593604fdc54140bcb
config: sh-allmodconfig (attached as .config)
compiler: sh4-linux-gcc (GCC) 7.5.0

reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.5.0 make.cross ARCH=sh

If you fix the issue, kindly add following tag

All errors (new ones prefixed by >>):

>> fs//btrfs/inode.c:8631:28: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
     .iomap_begin            = btrfs_dio_iomap_begin,
                               ^~~~~~~~~~~~~~~~~~~~~
   fs//btrfs/inode.c:8631:28: note: (near initialization for 'btrfs_dio_iomap_ops.iomap_begin')
   fs//btrfs/inode.c: In function 'btrfs_direct_IO':
>> fs//btrfs/inode.c:8694:8: error: too many arguments to function 'iomap_dio_rw'

ret = iomap_dio_rw(iocb, iter, &btrfs_dio_iomap_ops, &btrfs_dops,
^~~~~~~~~~~~
In file included from fs//btrfs/inode.c:32:0:
include/linux/iomap.h:199:9: note: declared here
ssize_t iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
^~~~~~~~~~~~
cc1: some warnings being treated as errors

vim +/iomap_dio_rw +8694 fs//btrfs/inode.c

8629
8630 static const struct iomap_ops btrfs_dio_iomap_ops = {

> 8631		.iomap_begin            = btrfs_dio_iomap_begin,
  8632	};
  8633	
  8634	static const struct iomap_dio_ops btrfs_dops = {
  8635		.submit_io		= btrfs_submit_direct,
  8636	};
  8637	
  8638	
  8639	/*
  8640	 * btrfs_direct_IO - perform direct I/O
  8641	 * inode->i_rwsem must be locked before calling this function, shared or exclusive.
  8642	 * @iocb - kernel iocb
  8643	 * @iter - iter to/from data is copied
  8644	 */
  8645	
  8646	ssize_t btrfs_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
  8647	{
  8648		struct file *file = iocb->ki_filp;
  8649		struct inode *inode = file->f_mapping->host;
  8650		struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
  8651		struct btrfs_dio_data dio_data = { 0 };
  8652		struct extent_changeset *data_reserved = NULL;
  8653		loff_t offset = iocb->ki_pos;
  8654		size_t count = 0;
  8655		bool relock = false;
  8656		ssize_t ret;
  8657	
  8658		if (check_direct_IO(fs_info, iter, offset))
  8659			return 0;
  8660	
  8661		count = iov_iter_count(iter);
  8662		if (iov_iter_rw(iter) == WRITE) {
  8663			/*
  8664			 * If the write DIO is beyond the EOF, we need update
  8665			 * the isize, but it is protected by i_mutex. So we can
  8666			 * not unlock the i_mutex at this case.
  8667			 */
  8668			if (offset + count <= inode->i_size) {
  8669				dio_data.overwrite = 1;
  8670				inode_unlock(inode);
  8671				relock = true;
  8672			} else if (iocb->ki_flags & IOCB_NOWAIT) {
  8673				ret = -EAGAIN;
  8674				goto out;
  8675			}
  8676			ret = btrfs_delalloc_reserve_space(inode, &data_reserved,
  8677							   offset, count);
  8678			if (ret)
  8679				goto out;
  8680	
  8681			/*
  8682			 * We need to know how many extents we reserved so that we can
  8683			 * do the accounting properly if we go over the number we
  8684			 * originally calculated.  Abuse current->journal_info for this.
  8685			 */
  8686			dio_data.reserve = round_up(count,
  8687						    fs_info->sectorsize);
  8688			dio_data.unsubmitted_oe_range_start = (u64)offset;
  8689			dio_data.unsubmitted_oe_range_end = (u64)offset;
  8690			current->journal_info = &dio_data;
  8691			down_read(&BTRFS_I(inode)->dio_sem);
  8692		}
  8693	
> 8694		ret = iomap_dio_rw(iocb, iter, &btrfs_dio_iomap_ops, &btrfs_dops,

8695 is_sync_kiocb(iocb));
8696
8697 if (iov_iter_rw(iter) == WRITE) {
8698 up_read(&BTRFS_I(inode)->dio_sem);
8699 current->journal_info = NULL;
8700 if (ret < 0 && ret != -EIOCBQUEUED) {
8701 if (dio_data.reserve)
8702 btrfs_delalloc_release_space(inode, data_reserved,
8703 offset, dio_data.reserve, true);
8704 /*
8705 * On error we might have left some ordered extents
8706 * without submitting corresponding bios for them, so
8707 * cleanup them up to avoid other tasks getting them
8708 * and waiting for them to complete forever.
8709 */
8710 if (dio_data.unsubmitted_oe_range_start <
8711 dio_data.unsubmitted_oe_range_end)
8712 __endio_write_update_ordered(inode,
8713 dio_data.unsubmitted_oe_range_start,
8714 dio_data.unsubmitted_oe_range_end -
8715 dio_data.unsubmitted_oe_range_start,
8716 false);
8717 } else if (ret >= 0 && (size_t)ret < count)
8718 btrfs_delalloc_release_space(inode, data_reserved,
8719 offset, count - (size_t)ret, true);
8720 btrfs_delalloc_release_extents(BTRFS_I(inode), count);
8721 }
8722 out:
8723 if (relock)
8724 inode_lock(inode);
8725 extent_changeset_free(data_reserved);
8726 return ret;
8727 }
8728

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/[email protected] Intel Corporation

#16 lore raw

PATCH v3 5/8 fs: Remove dio_end_io()

In reply to Goldwyn Rodrigues

From: Goldwyn Rodrigues <[email protected]>

Since we removed the last user of dio_end_io(), remove the helper function dio_end_io().

---
 fs/direct-io.c     | 19 -------------------
 include/linux/fs.h |  1 -
 2 files changed, 20 deletions(-)
fs/direct-io.c +0 -19
index 9329ced91f1d..9d6fc6467d9c 100644
@@ -405,25 +405,6 @@ static void dio_bio_end_io(struct bio *bio)
 	spin_unlock_irqrestore(&dio->bio_lock, flags);
 }
 
-/**
- * dio_end_io - handle the end io action for the given bio
- * @bio: The direct io bio thats being completed
- *
- * This is meant to be called by any filesystem that uses their own dio_submit_t
- * so that the DIO specific endio actions are dealt with after the filesystem
- * has done it's completion work.
- */
-void dio_end_io(struct bio *bio)
-{
-	struct dio *dio = bio->bi_private;
-
-	if (dio->is_async)
-		dio_bio_end_aio(bio);
-	else
-		dio_bio_end_io(bio);
-}
-EXPORT_SYMBOL_GPL(dio_end_io);
-
 static inline void
 dio_bio_alloc(struct dio *dio, struct dio_submit *sdio,
 	      struct block_device *bdev,
include/linux/fs.h +0 -1
index 5bc75cff3536..eab2c26fb32a 100644
@@ -3154,7 +3154,6 @@ enum {
 	DIO_SKIP_HOLES	= 0x02,
 };
 
-void dio_end_io(struct bio *bio);
 void dio_warn_stale_pagecache(struct file *filp);
 
 ssize_t __blockdev_direct_IO(struct kiocb *iocb, struct inode *inode,
Signature · 1 line
2.16.4
#17 lore raw

PATCH v3 6/8 btrfs: Wait for extent bits to release page

In reply to Goldwyn Rodrigues

From: Goldwyn Rodrigues <[email protected]>

While trying to release a page, the extent containing the page may be locked which would stop the page from being released. Wait for the extent lock to be cleared, if blocking is allowed and then clear the bits.

While we are at it, clean the code of try_release_extent_state() to make it simpler.

---
 fs/btrfs/extent_io.c | 37 ++++++++++++++++---------------------
 fs/btrfs/extent_io.h |  2 +-
 fs/btrfs/inode.c     |  4 ++--
 3 files changed, 19 insertions(+), 24 deletions(-)
fs/btrfs/extent_io.c +16 -21
index cceaf05aada2..153f78be973f 100644
@@ -4362,33 +4362,28 @@ int extent_invalidatepage(struct extent_io_tree *tree,
  * are locked or under IO and drops the related state bits if it is safe
  * to drop the page.
  */
-static int try_release_extent_state(struct extent_io_tree *tree,
+static bool try_release_extent_state(struct extent_io_tree *tree,
 				    struct page *page, gfp_t mask)
 {
 	u64 start = page_offset(page);
 	u64 end = start + PAGE_SIZE - 1;
-	int ret = 1;
 
 	if (test_range_bit(tree, start, end, EXTENT_LOCKED, 0, NULL)) {
-		ret = 0;
-	} else {
-		/*
-		 * at this point we can safely clear everything except the
-		 * locked bit and the nodatasum bit
-		 */
-		ret = __clear_extent_bit(tree, start, end,
-				 ~(EXTENT_LOCKED | EXTENT_NODATASUM),
-				 0, 0, NULL, mask, NULL);
-
-		/* if clear_extent_bit failed for enomem reasons,
-		 * we can't allow the release to continue.
-		 */
-		if (ret < 0)
-			ret = 0;
-		else
-			ret = 1;
+		if (!gfpflags_allow_blocking(mask))
+			return false;
+		wait_extent_bit(tree, start, end, EXTENT_LOCKED);
 	}
-	return ret;
+	/*
+	 * At this point we can safely clear everything except the locked and
+	 * nodatasum bits. If clear_extent_bit failed due to -ENOMEM,
+	 * don't allow release.
+	 */
+	if (__clear_extent_bit(tree, start, end,
+				~(EXTENT_LOCKED | EXTENT_NODATASUM), 0, 0,
+				NULL, mask, NULL) < 0)
+		return false;
+
+	return true;
 }
 
 /*
@@ -4396,7 +4391,7 @@ static int try_release_extent_state(struct extent_io_tree *tree,
  * in the range corresponding to the page, both state records and extent
  * map records are removed
  */
-int try_release_extent_mapping(struct page *page, gfp_t mask)
+bool try_release_extent_mapping(struct page *page, gfp_t mask)
 {
 	struct extent_map *em;
 	u64 start = page_offset(page);
fs/btrfs/extent_io.h +1 -1
index cf3424d58fec..0735cadb5e55 100644
@@ -263,7 +263,7 @@ void extent_io_tree_init(struct btrfs_fs_info *fs_info,
 			 struct extent_io_tree *tree, unsigned int owner,
 			 void *private_data);
 void extent_io_tree_release(struct extent_io_tree *tree);
-int try_release_extent_mapping(struct page *page, gfp_t mask);
+bool try_release_extent_mapping(struct page *page, gfp_t mask);
 int try_release_extent_buffer(struct page *page);
 int lock_extent_bits(struct extent_io_tree *tree, u64 start, u64 end,
 		     struct extent_state **cached);
fs/btrfs/inode.c +2 -2
index b4a297407672..f619b5f6a095 100644
@@ -8787,8 +8787,8 @@ btrfs_readpages(struct file *file, struct address_space *mapping,
 
 static int __btrfs_releasepage(struct page *page, gfp_t gfp_flags)
 {
-	int ret = try_release_extent_mapping(page, gfp_flags);
-	if (ret == 1) {
+	bool ret = try_release_extent_mapping(page, gfp_flags);
+	if (ret) {
 		ClearPagePrivate(page);
 		set_page_private(page, 0);
 		put_page(page);
Signature · 1 line
2.16.4
#18 lore raw

PATCH v3 7/8 btrfs: Remove btrfs_dio_data

In reply to Goldwyn Rodrigues

From: Goldwyn Rodrigues <[email protected]>

Since, we are using iomap, we don't get multiple calls for get_blocks(), and there is no incomplete ordered extents. So, remove btrfs_dio_data and all its manipulations. The bonus is we don't abuse current->journal_info anymore.

This reverts f28a49287817 ("Btrfs: fix leaking of ordered extents after direct IO write error")

---
 fs/btrfs/inode.c | 76 +++-----------------------------------------------------
 1 file changed, 3 insertions(+), 73 deletions(-)
fs/btrfs/inode.c +3 -73
index f619b5f6a095..fedbbcf108cf 100644
@@ -56,13 +56,6 @@ struct btrfs_iget_args {
 	struct btrfs_root *root;
 };
 
-struct btrfs_dio_data {
-	u64 reserve;
-	u64 unsubmitted_oe_range_start;
-	u64 unsubmitted_oe_range_end;
-	int overwrite;
-};
-
 static const struct inode_operations btrfs_dir_inode_operations;
 static const struct inode_operations btrfs_symlink_inode_operations;
 static const struct inode_operations btrfs_dir_ro_inode_operations;
@@ -7622,7 +7615,6 @@ static struct extent_map *create_io_em(struct inode *inode, u64 start, u64 len,
 
 static int btrfs_get_blocks_direct_write(struct extent_map **map,
 					 struct inode *inode,
-					 struct btrfs_dio_data *dio_data,
 					 u64 start, u64 len)
 {
 	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
@@ -7696,13 +7688,9 @@ static int btrfs_get_blocks_direct_write(struct extent_map **map,
 	 * Need to update the i_size under the extent lock so buffered
 	 * readers will get the updated i_size when we unlock.
 	 */
-	if (!dio_data->overwrite && start + len > i_size_read(inode))
+	if (start + len > i_size_read(inode))
 		i_size_write(inode, start + len);
 
-	WARN_ON(dio_data->reserve < len);
-	dio_data->reserve -= len;
-	dio_data->unsubmitted_oe_range_end = start + len;
-	current->journal_info = dio_data;
 out:
 	return ret;
 }
@@ -7714,7 +7702,6 @@ static int btrfs_dio_iomap_begin(struct inode *inode, loff_t start,
 	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
 	struct extent_map *em;
 	struct extent_state *cached_state = NULL;
-	struct btrfs_dio_data *dio_data = NULL;
 	u64 lockstart, lockend;
 	bool write = !!(flags & IOMAP_WRITE);
 	int ret = 0;
@@ -7738,16 +7725,6 @@ static int btrfs_dio_iomap_begin(struct inode *inode, loff_t start,
 		ret = filemap_fdatawrite_range(inode->i_mapping, start,
 					 start + length - 1);
 
-	if (current->journal_info) {
-		/*
-		 * Need to pull our outstanding extents and set journal_info to NULL so
-		 * that anything that needs to check if there's a transaction doesn't get
-		 * confused.
-		 */
-		dio_data = current->journal_info;
-		current->journal_info = NULL;
-	}
-
 	/*
 	 * If this errors out it's because we couldn't invalidate pagecache for
 	 * this range and we need to fallback to buffered.
@@ -7788,7 +7765,7 @@ static int btrfs_dio_iomap_begin(struct inode *inode, loff_t start,
 	len = min(len, em->len - (start - em->start));
 	if (write) {
 		ret = btrfs_get_blocks_direct_write(&em, inode,
-						    dio_data, start, len);
+						    start, len);
 		if (ret < 0)
 			goto unlock_err;
 		unlock_extents = true;
@@ -7840,8 +7817,6 @@ static int btrfs_dio_iomap_begin(struct inode *inode, loff_t start,
 	unlock_extent_cached(&BTRFS_I(inode)->io_tree, lockstart, lockend,
 			     &cached_state);
 err:
-	if (dio_data)
-		current->journal_info = dio_data;
 	return ret;
 }
 
@@ -8531,21 +8506,6 @@ static blk_qc_t btrfs_submit_direct(struct bio *dio_bio, struct file *file,
 		dip->subio_endio = btrfs_subio_endio_read;
 	}
 
-	/*
-	 * Reset the range for unsubmitted ordered extents (to a 0 length range)
-	 * even if we fail to submit a bio, because in such case we do the
-	 * corresponding error handling below and it must not be done a second
-	 * time by btrfs_direct_IO().
-	 */
-	if (write) {
-		struct btrfs_dio_data *dio_data = current->journal_info;
-
-		dio_data->unsubmitted_oe_range_end = dip->logical_offset +
-			dip->bytes;
-		dio_data->unsubmitted_oe_range_start =
-			dio_data->unsubmitted_oe_range_end;
-	}
-
 	ret = btrfs_submit_direct_hook(dip);
 	if (!ret)
 		return BLK_QC_T_NONE;
@@ -8648,7 +8608,6 @@ ssize_t btrfs_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
 	struct file *file = iocb->ki_filp;
 	struct inode *inode = file->f_mapping->host;
 	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
-	struct btrfs_dio_data dio_data = { 0 };
 	struct extent_changeset *data_reserved = NULL;
 	loff_t offset = iocb->ki_pos;
 	size_t count = 0;
@@ -8666,7 +8625,6 @@ ssize_t btrfs_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
 		 * not unlock the i_mutex at this case.
 		 */
 		if (offset + count <= inode->i_size) {
-			dio_data.overwrite = 1;
 			inode_unlock(inode);
 			relock = true;
 		} else if (iocb->ki_flags & IOCB_NOWAIT) {
@@ -8678,16 +8636,6 @@ ssize_t btrfs_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
 		if (ret)
 			goto out;
 
-		/*
-		 * We need to know how many extents we reserved so that we can
-		 * do the accounting properly if we go over the number we
-		 * originally calculated.  Abuse current->journal_info for this.
-		 */
-		dio_data.reserve = round_up(count,
-					    fs_info->sectorsize);
-		dio_data.unsubmitted_oe_range_start = (u64)offset;
-		dio_data.unsubmitted_oe_range_end = (u64)offset;
-		current->journal_info = &dio_data;
 		down_read(&BTRFS_I(inode)->dio_sem);
 	}
 
@@ -8696,25 +8644,7 @@ ssize_t btrfs_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
 
 	if (iov_iter_rw(iter) == WRITE) {
 		up_read(&BTRFS_I(inode)->dio_sem);
-		current->journal_info = NULL;
-		if (ret < 0 && ret != -EIOCBQUEUED) {
-			if (dio_data.reserve)
-				btrfs_delalloc_release_space(inode, data_reserved,
-					offset, dio_data.reserve, true);
-			/*
-			 * On error we might have left some ordered extents
-			 * without submitting corresponding bios for them, so
-			 * cleanup them up to avoid other tasks getting them
-			 * and waiting for them to complete forever.
-			 */
-			if (dio_data.unsubmitted_oe_range_start <
-			    dio_data.unsubmitted_oe_range_end)
-				__endio_write_update_ordered(inode,
-					dio_data.unsubmitted_oe_range_start,
-					dio_data.unsubmitted_oe_range_end -
-					dio_data.unsubmitted_oe_range_start,
-					false);
-		} else if (ret >= 0 && (size_t)ret < count)
+		if (ret >= 0 && (size_t)ret < count)
 			btrfs_delalloc_release_space(inode, data_reserved,
 					offset, count - (size_t)ret, true);
 		btrfs_delalloc_release_extents(BTRFS_I(inode), count);
Signature · 1 line
2.16.4
#19 lore raw

PATCH v3 8/8 btrfs: remove BTRFS_INODE_READDIO_NEED_LOCK

In reply to Goldwyn Rodrigues

From: Goldwyn Rodrigues <[email protected]>

Since we now perform direct reads using i_rwsem, we can remove this inode flag used to co-ordinate unlocked reads.

---
 fs/btrfs/btrfs_inode.h | 18 ------------------
 fs/btrfs/inode.c       |  5 -----
 2 files changed, 23 deletions(-)
fs/btrfs/btrfs_inode.h +0 -18
index f853835c409c..31c327666a61 100644
@@ -27,7 +27,6 @@ enum {
 	BTRFS_INODE_NEEDS_FULL_SYNC,
 	BTRFS_INODE_COPY_EVERYTHING,
 	BTRFS_INODE_IN_DELALLOC_LIST,
-	BTRFS_INODE_READDIO_NEED_LOCK,
 	BTRFS_INODE_HAS_PROPS,
 	BTRFS_INODE_SNAPSHOT_FLUSH,
 };
@@ -320,23 +319,6 @@ struct btrfs_dio_private {
 			blk_status_t);
 };
 
-/*
- * Disable DIO read nolock optimization, so new dio readers will be forced
- * to grab i_mutex. It is used to avoid the endless truncate due to
- * nonlocked dio read.
- */
-static inline void btrfs_inode_block_unlocked_dio(struct btrfs_inode *inode)
-{
-	set_bit(BTRFS_INODE_READDIO_NEED_LOCK, &inode->runtime_flags);
-	smp_mb();
-}
-
-static inline void btrfs_inode_resume_unlocked_dio(struct btrfs_inode *inode)
-{
-	smp_mb__before_atomic();
-	clear_bit(BTRFS_INODE_READDIO_NEED_LOCK, &inode->runtime_flags);
-}
-
 /* Array of bytes with variable length, hexadecimal format 0x1234 */
 #define CSUM_FMT				"0x%*phN"
 #define CSUM_FMT_VALUE(size, bytes)		size, bytes
fs/btrfs/inode.c +0 -5
index fedbbcf108cf..71ba4b5503f0 100644
@@ -5238,11 +5238,6 @@ static int btrfs_setsize(struct inode *inode, struct iattr *attr)
 
 		truncate_setsize(inode, newsize);
 
-		/* Disable nonlocked read DIO to avoid the endless truncate */
-		btrfs_inode_block_unlocked_dio(BTRFS_I(inode));
-		inode_dio_wait(inode);
-		btrfs_inode_resume_unlocked_dio(BTRFS_I(inode));
-
 		ret = btrfs_truncate(inode, newsize == oldsize);
 		if (ret && inode->i_nlink) {
 			int err;
Signature · 1 line
2.16.4
Reviewed-by on v3 8/8
#20 lore raw

Re: [PATCH 8/8] btrfs: remove BTRFS_INODE_READDIO_NEED_LOCK

Quoted 6 lines · Goldwyn Rodrigues

From: Goldwyn Rodrigues <[email protected]>

Since we now perform direct reads using i_rwsem, we can remove this inode flag used to co-ordinate unlocked reads.

Truncate call chain is

do_truncate <-- calls inode_lock
notify_change
->setattr/btrfs_setattr
btrfs_setsize

So :

Quoted 58 lines
---
 fs/btrfs/btrfs_inode.h | 18 ------------------
 fs/btrfs/inode.c       |  5 -----
 2 files changed, 23 deletions(-)
fs/btrfs/btrfs_inode.h +0 -18
index f853835c409c..31c327666a61 100644
@@ -27,7 +27,6 @@ enum {
 	BTRFS_INODE_NEEDS_FULL_SYNC,
 	BTRFS_INODE_COPY_EVERYTHING,
 	BTRFS_INODE_IN_DELALLOC_LIST,
-	BTRFS_INODE_READDIO_NEED_LOCK,
 	BTRFS_INODE_HAS_PROPS,
 	BTRFS_INODE_SNAPSHOT_FLUSH,
 };
@@ -320,23 +319,6 @@ struct btrfs_dio_private {
 			blk_status_t);
 };
 
-/*
- * Disable DIO read nolock optimization, so new dio readers will be forced
- * to grab i_mutex. It is used to avoid the endless truncate due to
- * nonlocked dio read.
- */
-static inline void btrfs_inode_block_unlocked_dio(struct btrfs_inode *inode)
-{
-	set_bit(BTRFS_INODE_READDIO_NEED_LOCK, &inode->runtime_flags);
-	smp_mb();
-}
-
-static inline void btrfs_inode_resume_unlocked_dio(struct btrfs_inode *inode)
-{
-	smp_mb__before_atomic();
-	clear_bit(BTRFS_INODE_READDIO_NEED_LOCK, &inode->runtime_flags);
-}
-
 /* Array of bytes with variable length, hexadecimal format 0x1234 */
 #define CSUM_FMT				"0x%*phN"
 #define CSUM_FMT_VALUE(size, bytes)		size, bytes
fs/btrfs/inode.c +0 -5
index fedbbcf108cf..71ba4b5503f0 100644
@@ -5238,11 +5238,6 @@ static int btrfs_setsize(struct inode *inode, struct iattr *attr)
 
 		truncate_setsize(inode, newsize);
 
-		/* Disable nonlocked read DIO to avoid the endless truncate */
-		btrfs_inode_block_unlocked_dio(BTRFS_I(inode));
-		inode_dio_wait(inode);
-		btrfs_inode_resume_unlocked_dio(BTRFS_I(inode));
-
 		ret = btrfs_truncate(inode, newsize == oldsize);
 		if (ret && inode->i_nlink) {
 			int err;
#21 lore raw
In reply to Goldwyn Rodrigues
Quoted 10 lines · Goldwyn Rodrigues

This is an effort to use iomap for direct I/O in btrfs. This would change the call from __blockdev_direct_io() to iomap_dio_rw().

The main objective is to lose the buffer head and use bio defined by iomap code, and hopefully to use more of generic-FS codebase.

These patches are based on xfs/iomap-for-next, though I tested it against the patches on xfs/iomap-for-next on top of v5.4.1 (there are no changes to existing patches). The tree is available at
https://github.com/goldwynr/linux/tree/btrfs-iomap-dio

The iomap-for-next seems to be all merged to master, so I'd like to add the btrfs part to for-next early so we can have the full dev cycle to test.

Fstests got stuck at generic/095, in llseek on the inode mutex. In version 5.4.1 it's inode_lock while in master it's inode_lock_shared and only used for SEEK_DATA/HOLE.

I've also tested the rebased patchset on current master but due to the hangs caused by pipe changes when send is done it only gets to test btrfs/016 (way before the generic/095 starts).

generic/095 [21:12:03][ 9153.094902] run fstests generic/095 at 2019-12-05 21:12:03

[ 9153.355112] BTRFS info (device vda): using free space tree
[ 9153.357522] BTRFS info (device vda): has skinny extents
[ 9155.598524] BTRFS: device fsid 8f274c73-27d6-4a7c-96ad-4ae41fcd6916 devid 1 transid 5 /dev/vdb
[ 9155.626220] BTRFS info (device vdb): enabling free space tree
[ 9155.628257] BTRFS info (device vdb): using free space tree
[ 9155.630290] BTRFS info (device vdb): has skinny extents
[ 9155.632191] BTRFS info (device vdb): flagging fs with big metadata feature
[ 9155.640732] BTRFS info (device vdb): creating free space tree
[ 9155.643781] BTRFS info (device vdb): setting compat-ro feature flag for FREE_SPACE_TREE (0x1)
[ 9155.648664] BTRFS info (device vdb): setting compat-ro feature flag for FREE_SPACE_TREE_VALID (0x2)
[ 9155.652542] BTRFS info (device vdb): checking UUID tree
[ 9819.465520] INFO: task fio:19671 blocked for more than 491 seconds.
[ 9819.470928]       Tainted: G             L    5.4.1-default+ #889
[ 9819.475441] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[ 9819.480987] fio             D14632 19671  19669 0x00004000
[ 9819.483182] Call Trace:
[ 9819.484360]  ? __schedule+0x2d4/0x8f0
[ 9819.485779]  schedule+0x49/0xd0
[ 9819.487050]  rwsem_down_write_slowpath+0x3f6/0x7d0
[ 9819.488777]  ? down_write+0xa9/0x130
[ 9819.490203]  down_write+0xa9/0x130
[ 9819.491571]  btrfs_file_llseek+0x45/0x2b0 [btrfs]
[ 9819.493074]  ksys_lseek+0x63/0xb0
[ 9819.494153]  do_syscall_64+0x50/0x1f0
[ 9819.495122]  entry_SYSCALL_64_after_hwframe+0x49/0xbe
[ 9819.496328] RIP: 0033:0x7f6bce8c0627
[ 9819.503273] RSP: 002b:00007fffa3fdaab8 EFLAGS: 00000206 ORIG_RAX: 0000000000000008
[ 9819.505802] RAX: ffffffffffffffda RBX: 00007f6ba393f000 RCX: 00007f6bce8c0627
[ 9819.508045] RDX: 0000000000000000 RSI: 0000000000007800 RDI: 0000000000000003
[ 9819.510048] RBP: 00007f6ba393f000 R08: 0000000000000400 R09: 0000000000000000
[ 9819.512061] R10: fffffffffffffa85 R11: 0000000000000206 R12: 0000000000000000
[ 9819.514211] R13: 0000000000000400 R14: 00007f6ba393f000 R15: 000055fc96807b40
[ 9819.516181] INFO: task fio:19672 blocked for more than 491 seconds.
[ 9819.517970]       Tainted: G             L    5.4.1-default+ #889
[ 9819.519650] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[ 9819.522142] fio             D14712 19672  19669 0x00000000
[ 9819.523696] Call Trace:
[ 9819.524651]  ? __schedule+0x2d4/0x8f0
[ 9819.525871]  schedule+0x49/0xd0
[ 9819.527003]  rwsem_down_write_slowpath+0x3f6/0x7d0
[ 9819.528480]  ? down_write+0xa9/0x130
[ 9819.529705]  down_write+0xa9/0x130
[ 9819.530889]  btrfs_file_llseek+0x45/0x2b0 [btrfs]
[ 9819.532304]  ksys_lseek+0x63/0xb0
[ 9819.533482]  do_syscall_64+0x50/0x1f0
[ 9819.534721]  entry_SYSCALL_64_after_hwframe+0x49/0xbe
[ 9819.536567] RIP: 0033:0x7f6bce8c0627
[ 9819.544424] RSP: 002b:00007fffa3fdaab8 EFLAGS: 00000206 ORIG_RAX: 0000000000000008
[ 9819.547483] RAX: ffffffffffffffda RBX: 00007f6ba3958080 RCX: 00007f6bce8c0627
[ 9819.549937] RDX: 0000000000000000 RSI: 0000000000020800 RDI: 0000000000000003
[ 9819.552152] RBP: 00007f6ba3958080 R08: 0000000000000400 R09: 0000000000000000
[ 9819.554479] R10: fffffffffffffa85 R11: 0000000000000206 R12: 0000000000000000
[ 9819.556515] R13: 0000000000000400 R14: 00007f6ba3958080 R15: 000055fc96807b40
[ 9819.558536] INFO: task fio:19673 blocked for more than 491 seconds.
[ 9819.560332]       Tainted: G             L    5.4.1-default+ #889
[ 9819.562062] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[ 9819.564494] fio             D13480 19673  19669 0x00000000
[ 9819.566075] Call Trace:
[ 9819.567037]  ? __schedule+0x2d4/0x8f0
[ 9819.568325]  schedule+0x49/0xd0
[ 9819.569438]  rwsem_down_write_slowpath+0x3f6/0x7d0
[ 9819.570906]  ? down_write+0xa9/0x130
[ 9819.572072]  down_write+0xa9/0x130
[ 9819.573255]  btrfs_file_llseek+0x45/0x2b0 [btrfs]
[ 9819.574685]  ? vfs_read+0x14e/0x180
[ 9819.575871]  ksys_lseek+0x63/0xb0
[ 9819.577066]  do_syscall_64+0x50/0x1f0
[ 9819.578286]  entry_SYSCALL_64_after_hwframe+0x49/0xbe
[ 9819.579758] RIP: 0033:0x7f6bce8c0627