linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Btrfs: replace: cache rbio when rebuild data on missing device
@ 2018-03-02 23:10 Liu Bo
  2018-03-06 11:28 ` David Sterba
  2018-03-22  1:20 ` [PATCH V2] " Liu Bo
  0 siblings, 2 replies; 5+ messages in thread
From: Liu Bo @ 2018-03-02 23:10 UTC (permalink / raw)
  To: linux-btrfs

Rebuild on missing device is as same as recover, after it's done, rbio
has data which is consistent with on-disk data, so it can be cached to
avoid further reads.

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
---
 fs/btrfs/raid56.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c
index dec0907..bb8a3c5 100644
--- a/fs/btrfs/raid56.c
+++ b/fs/btrfs/raid56.c
@@ -1986,7 +1986,8 @@ static void __raid_recover_end_io(struct btrfs_raid_bio *rbio)
 	kfree(pointers);
 
 cleanup_io:
-	if (rbio->operation == BTRFS_RBIO_READ_REBUILD) {
+	if (rbio->operation == BTRFS_RBIO_READ_REBUILD ||
+	    rbio->operation == BTRFS_RBIO_REBUILD_MISSING) {
 		/*
 		 * - In case of two failures, where rbio->failb != -1:
 		 *
@@ -2008,8 +2009,6 @@ static void __raid_recover_end_io(struct btrfs_raid_bio *rbio)
 			clear_bit(RBIO_CACHE_READY_BIT, &rbio->flags);
 
 		rbio_orig_end_io(rbio, err);
-	} else if (rbio->operation == BTRFS_RBIO_REBUILD_MISSING) {
-		rbio_orig_end_io(rbio, err);
 	} else if (err == BLK_STS_OK) {
 		rbio->faila = -1;
 		rbio->failb = -1;
-- 
2.9.4


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

* Re: [PATCH] Btrfs: replace: cache rbio when rebuild data on missing device
  2018-03-02 23:10 [PATCH] Btrfs: replace: cache rbio when rebuild data on missing device Liu Bo
@ 2018-03-06 11:28 ` David Sterba
  2018-03-09  5:40   ` Liu Bo
  2018-03-22  1:20 ` [PATCH V2] " Liu Bo
  1 sibling, 1 reply; 5+ messages in thread
From: David Sterba @ 2018-03-06 11:28 UTC (permalink / raw)
  To: Liu Bo; +Cc: linux-btrfs

On Fri, Mar 02, 2018 at 04:10:38PM -0700, Liu Bo wrote:
> Rebuild on missing device is as same as recover, after it's done, rbio
> has data which is consistent with on-disk data, so it can be cached to
> avoid further reads.

Please add a comment that describes why the READ and REBUILD can be
merged together, it's not obvious from the code.

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

* Re: [PATCH] Btrfs: replace: cache rbio when rebuild data on missing device
  2018-03-06 11:28 ` David Sterba
@ 2018-03-09  5:40   ` Liu Bo
  0 siblings, 0 replies; 5+ messages in thread
From: Liu Bo @ 2018-03-09  5:40 UTC (permalink / raw)
  To: dsterba, linux-btrfs

On Tue, Mar 06, 2018 at 12:28:18PM +0100, David Sterba wrote:
> On Fri, Mar 02, 2018 at 04:10:38PM -0700, Liu Bo wrote:
> > Rebuild on missing device is as same as recover, after it's done, rbio
> > has data which is consistent with on-disk data, so it can be cached to
> > avoid further reads.
> 
> Please add a comment that describes why the READ and REBUILD can be
> merged together, it's not obvious from the code.

Will update it.

Thanks,

-liubo

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

* [PATCH V2] Btrfs: replace: cache rbio when rebuild data on missing device
  2018-03-02 23:10 [PATCH] Btrfs: replace: cache rbio when rebuild data on missing device Liu Bo
  2018-03-06 11:28 ` David Sterba
@ 2018-03-22  1:20 ` Liu Bo
  2018-03-22 14:13   ` David Sterba
  1 sibling, 1 reply; 5+ messages in thread
From: Liu Bo @ 2018-03-22  1:20 UTC (permalink / raw)
  To: linux-btrfs

Rebuild on missing device is as same as recover, after it's done, rbio
has data which is consistent with on-disk data, so it can be cached to
avoid further reads.

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: Liu Bo <bo.liu@linux.alibaba.com>
---
v2: Add comments to explain why REBUILD needs to be merged.

 fs/btrfs/raid56.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c
index fcfc20de2df3..154318249265 100644
--- a/fs/btrfs/raid56.c
+++ b/fs/btrfs/raid56.c
@@ -1987,7 +1987,13 @@ static void __raid_recover_end_io(struct btrfs_raid_bio *rbio)
 	kfree(pointers);
 
 cleanup_io:
-	if (rbio->operation == BTRFS_RBIO_READ_REBUILD) {
+	/*
+	 * Similar to READ_REBUILD, REBUILD_MISSING at this point also has a
+	 * valid rbio which is consistent with ondisk content, thus such a valid
+	 * rbio can be cached to avoid further disk reads.
+	 */
+	if (rbio->operation == BTRFS_RBIO_READ_REBUILD ||
+	    rbio->operation == BTRFS_RBIO_REBUILD_MISSING) {
 		/*
 		 * - In case of two failures, where rbio->failb != -1:
 		 *
@@ -2008,8 +2014,6 @@ static void __raid_recover_end_io(struct btrfs_raid_bio *rbio)
 		else
 			clear_bit(RBIO_CACHE_READY_BIT, &rbio->flags);
 
-		rbio_orig_end_io(rbio, err);
-	} else if (rbio->operation == BTRFS_RBIO_REBUILD_MISSING) {
 		rbio_orig_end_io(rbio, err);
 	} else if (err == BLK_STS_OK) {
 		rbio->faila = -1;
-- 
2.14.1.40.g8e62ba1


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

* Re: [PATCH V2] Btrfs: replace: cache rbio when rebuild data on missing device
  2018-03-22  1:20 ` [PATCH V2] " Liu Bo
@ 2018-03-22 14:13   ` David Sterba
  0 siblings, 0 replies; 5+ messages in thread
From: David Sterba @ 2018-03-22 14:13 UTC (permalink / raw)
  To: Liu Bo; +Cc: linux-btrfs

On Thu, Mar 22, 2018 at 09:20:11AM +0800, Liu Bo wrote:
> Rebuild on missing device is as same as recover, after it's done, rbio
> has data which is consistent with on-disk data, so it can be cached to
> avoid further reads.
> 
> Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
> Signed-off-by: Liu Bo <bo.liu@linux.alibaba.com>

Added to next, thanks.

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

end of thread, other threads:[~2018-03-22 14:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-02 23:10 [PATCH] Btrfs: replace: cache rbio when rebuild data on missing device Liu Bo
2018-03-06 11:28 ` David Sterba
2018-03-09  5:40   ` Liu Bo
2018-03-22  1:20 ` [PATCH V2] " Liu Bo
2018-03-22 14:13   ` 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).