linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Btrfs: skip checksum verification if IO error occurs
@ 2017-04-14  1:11 Liu Bo
  2017-06-06 13:52 ` David Sterba
  0 siblings, 1 reply; 2+ messages in thread
From: Liu Bo @ 2017-04-14  1:11 UTC (permalink / raw)
  To: linux-btrfs

Currently dio read also goes to verify checksum if -EIO has been returned,
although it usually fails on checksum, it's not necessary at all, we could
directly check if there is another copy to read.

And with this, the behavior of dio read is now consistent with that of
buffered read.

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
---
 fs/btrfs/inode.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 5e71f1e..632b616 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -8030,6 +8030,7 @@ static int __btrfs_subio_endio_read(struct inode *inode,
 	unsigned int pgoff;
 	int csum_pos;
 	int i;
+	int uptodate = !!(err == 0);
 	int ret;
 
 	fs_info = BTRFS_I(inode)->root->fs_info;
@@ -8044,12 +8045,14 @@ static int __btrfs_subio_endio_read(struct inode *inode,
 
 		pgoff = bvec->bv_offset;
 next_block:
-		csum_pos = BTRFS_BYTES_TO_BLKS(fs_info, offset);
-		ret = __readpage_endio_check(inode, io_bio, csum_pos,
-					bvec->bv_page, pgoff, start,
-					sectorsize);
-		if (likely(!ret))
-			goto next;
+		if (uptodate) {
+			csum_pos = BTRFS_BYTES_TO_BLKS(fs_info, offset);
+			ret = __readpage_endio_check(inode, io_bio, csum_pos,
+						     bvec->bv_page, pgoff,
+						     start, sectorsize);
+			if (likely(!ret))
+				goto next;
+		}
 try_again:
 		done.uptodate = 0;
 		done.start = start;
-- 
2.5.5


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Btrfs: skip checksum verification if IO error occurs
  2017-04-14  1:11 [PATCH] Btrfs: skip checksum verification if IO error occurs Liu Bo
@ 2017-06-06 13:52 ` David Sterba
  0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2017-06-06 13:52 UTC (permalink / raw)
  To: Liu Bo; +Cc: linux-btrfs

On Thu, Apr 13, 2017 at 06:11:48PM -0700, Liu Bo wrote:
> Currently dio read also goes to verify checksum if -EIO has been returned,
> although it usually fails on checksum, it's not necessary at all, we could
> directly check if there is another copy to read.
> 
> And with this, the behavior of dio read is now consistent with that of
> buffered read.
> 
> Signed-off-by: Liu Bo <bo.li.liu@oracle.com>

Reviewed-by: David Sterba <dsterba@suse.com>

> @@ -8030,6 +8030,7 @@ static int __btrfs_subio_endio_read(struct inode *inode,
>  	unsigned int pgoff;
>  	int csum_pos;
>  	int i;
> +	int uptodate = !!(err == 0);

I've switched that to bool and dropped !!.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-06-06 13:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-14  1:11 [PATCH] Btrfs: skip checksum verification if IO error occurs Liu Bo
2017-06-06 13:52 ` David Sterba

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).