Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1464642 > unrolled thread

[PATCH] ext4: allow DAX writeback for hole punch

Started byRoss Zwisler <ross.zwisler@linux.intel.com>
First post2016-08-17 18:20 +0200
Last post2016-08-17 20:30 +0200
Articles 4 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] ext4: allow DAX writeback for hole punch Ross Zwisler <ross.zwisler@linux.intel.com> - 2016-08-17 18:20 +0200
    Re: [PATCH] ext4: allow DAX writeback for hole punch Jan Kara <jack@suse.cz> - 2016-08-17 19:30 +0200
      Re: [PATCH] ext4: allow DAX writeback for hole punch Ross Zwisler <ross.zwisler@linux.intel.com> - 2016-08-17 20:20 +0200
      [PATCH v2] ext4: allow DAX writeback for hole punch Ross Zwisler <ross.zwisler@linux.intel.com> - 2016-08-17 20:30 +0200

#1464642 — [PATCH] ext4: allow DAX writeback for hole punch

FromRoss Zwisler <ross.zwisler@linux.intel.com>
Date2016-08-17 18:20 +0200
Subject[PATCH] ext4: allow DAX writeback for hole punch
Message-ID<s7bJo-3pe-17@gated-at.bofh.it>
Currently when doing a DAX hole punch with ext4 we fail to do a writeback.
This is because the logic around filemap_write_and_wait_range() in
ext4_punch_hole() only looks for dirty page cache pages in the radix tree,
not for dirty DAX exceptional entries.

Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
---

I found this while testing my PMD patches
(https://lkml.org/lkml/2016/8/15/613), but this fix applies equally to the
4k-only case.  I'm sending this separately from that series because I think
that this should probably be merged for v4.8 as it corrects an existing bug
and should have very low risk.

Regarding the other two supported DAX filesystems, XFS already properly
does this writeback and ext2 doesn't support hole punch so it doesn't have
to worry about this issue.

---
 fs/ext4/inode.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 3131747..8550416 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3890,7 +3890,7 @@ int ext4_update_disksize_before_punch(struct inode *inode, loff_t offset,
 }
 
 /*
- * ext4_punch_hole: punches a hole in a file by releaseing the blocks
+ * ext4_punch_hole: punches a hole in a file by releasing the blocks
  * associated with the given offset and length
  *
  * @inode:  File inode
@@ -3919,7 +3919,9 @@ int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t length)
 	 * Write out all dirty pages to avoid race conditions
 	 * Then release them.
 	 */
-	if (mapping->nrpages && mapping_tagged(mapping, PAGECACHE_TAG_DIRTY)) {
+	if (mapping_tagged(mapping, PAGECACHE_TAG_DIRTY) &&
+	    ((!dax_mapping(mapping) && mapping->nrpages) ||
+	     (dax_mapping(mapping) && mapping->nrexceptional))) {
 		ret = filemap_write_and_wait_range(mapping, offset,
 						   offset + length - 1);
 		if (ret)
-- 
2.9.0

[toc] | [next] | [standalone]


#1464675

FromJan Kara <jack@suse.cz>
Date2016-08-17 19:30 +0200
Message-ID<s7cP7-469-13@gated-at.bofh.it>
In reply to#1464642
On Wed 17-08-16 10:11:02, Ross Zwisler wrote:
> Currently when doing a DAX hole punch with ext4 we fail to do a writeback.
> This is because the logic around filemap_write_and_wait_range() in
> ext4_punch_hole() only looks for dirty page cache pages in the radix tree,
> not for dirty DAX exceptional entries.
> 
> Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>

Thanks. The patch looks correct, you can add:

Reviewed-by: Jan Kara <jack@suse.cz>

Although why don't we just simplify the test below to
mapping_tagged(mapping, PAGECACHE_TAG_DIRTY)? After all the mapping should
not have the dirty tag set if there are no pages / no entries?

								Honza

> @@ -3919,7 +3919,9 @@ int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t length)
>  	 * Write out all dirty pages to avoid race conditions
>  	 * Then release them.
>  	 */
> -	if (mapping->nrpages && mapping_tagged(mapping, PAGECACHE_TAG_DIRTY)) {
> +	if (mapping_tagged(mapping, PAGECACHE_TAG_DIRTY) &&
> +	    ((!dax_mapping(mapping) && mapping->nrpages) ||
> +	     (dax_mapping(mapping) && mapping->nrexceptional))) {
>  		ret = filemap_write_and_wait_range(mapping, offset,
>  						   offset + length - 1);
>  		if (ret)
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

[toc] | [prev] | [next] | [standalone]


#1464700

FromRoss Zwisler <ross.zwisler@linux.intel.com>
Date2016-08-17 20:20 +0200
Message-ID<s7dBv-4DV-7@gated-at.bofh.it>
In reply to#1464675
On Wed, Aug 17, 2016 at 07:19:55PM +0200, Jan Kara wrote:
> On Wed 17-08-16 10:11:02, Ross Zwisler wrote:
> > Currently when doing a DAX hole punch with ext4 we fail to do a writeback.
> > This is because the logic around filemap_write_and_wait_range() in
> > ext4_punch_hole() only looks for dirty page cache pages in the radix tree,
> > not for dirty DAX exceptional entries.
> > 
> > Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
> 
> Thanks. The patch looks correct, you can add:
> 
> Reviewed-by: Jan Kara <jack@suse.cz>
> 
> Although why don't we just simplify the test below to
> mapping_tagged(mapping, PAGECACHE_TAG_DIRTY)? After all the mapping should
> not have the dirty tag set if there are no pages / no entries?

Sure, that works.  I'll update to that in V2, and I'll add stable.  Thanks!

[toc] | [prev] | [next] | [standalone]


#1464711 — [PATCH v2] ext4: allow DAX writeback for hole punch

FromRoss Zwisler <ross.zwisler@linux.intel.com>
Date2016-08-17 20:30 +0200
Subject[PATCH v2] ext4: allow DAX writeback for hole punch
Message-ID<s7dLb-4HE-19@gated-at.bofh.it>
In reply to#1464675
Currently when doing a DAX hole punch with ext4 we fail to do a writeback.
This is because the logic around filemap_write_and_wait_range() in
ext4_punch_hole() only looks for dirty page cache pages in the radix tree,
not for dirty DAX exceptional entries.

Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Cc: stable@vger.kernel.org
---
This should be applied to stable kernels v4.5 and beyond.
---
 fs/ext4/inode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 3131747..0900cb4 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3890,7 +3890,7 @@ int ext4_update_disksize_before_punch(struct inode *inode, loff_t offset,
 }
 
 /*
- * ext4_punch_hole: punches a hole in a file by releaseing the blocks
+ * ext4_punch_hole: punches a hole in a file by releasing the blocks
  * associated with the given offset and length
  *
  * @inode:  File inode
@@ -3919,7 +3919,7 @@ int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t length)
 	 * Write out all dirty pages to avoid race conditions
 	 * Then release them.
 	 */
-	if (mapping->nrpages && mapping_tagged(mapping, PAGECACHE_TAG_DIRTY)) {
+	if (mapping_tagged(mapping, PAGECACHE_TAG_DIRTY)) {
 		ret = filemap_write_and_wait_range(mapping, offset,
 						   offset + length - 1);
 		if (ret)
-- 
2.9.0

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web