[06/28] ocfs2: clear the rest of the buffers on error
diff mbox

Message ID 55de3997.TTpLNRmdRzwV3er6%akpm@linux-foundation.org
State New
Headers show

Commit Message

Andrew Morton Aug. 26, 2015, 10:11 p.m. UTC
From: Goldwyn Rodrigues <rgoldwyn@suse.de>
Subject: ocfs2: clear the rest of the buffers on error

In case a validation fails, clear the rest of the buffers and return the
error to the calling function.

This also facilitates bubbling up the error originating from ocfs2_error
to calling functions.

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
Cc: Mark Fasheh <mfasheh@suse.com>
Cc: Joel Becker <jlbec@evilplan.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 fs/ocfs2/buffer_head_io.c |    6 ++++++
 1 file changed, 6 insertions(+)

Comments

Mark Fasheh Aug. 28, 2015, 11:23 p.m. UTC | #1
On Wed, Aug 26, 2015 at 03:11:35PM -0700, Andrew Morton wrote:
> From: Goldwyn Rodrigues <rgoldwyn@suse.de>
> Subject: ocfs2: clear the rest of the buffers on error
> 
> In case a validation fails, clear the rest of the buffers and return the
> error to the calling function.
> 
> This also facilitates bubbling up the error originating from ocfs2_error
> to calling functions.
> 
> Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
> Cc: Mark Fasheh <mfasheh@suse.com>
> Cc: Joel Becker <jlbec@evilplan.org>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Mark Fasheh <mfasheh@suse.de>

--
Mark Fasheh

Patch
diff mbox

diff -puN fs/ocfs2/buffer_head_io.c~clear-the-rest-of-the-buffers-on-error fs/ocfs2/buffer_head_io.c
--- a/fs/ocfs2/buffer_head_io.c~clear-the-rest-of-the-buffers-on-error
+++ a/fs/ocfs2/buffer_head_io.c
@@ -316,6 +316,12 @@  int ocfs2_read_blocks(struct ocfs2_cachi
 		bh = bhs[i];
 
 		if (!(flags & OCFS2_BH_READAHEAD)) {
+			if (status) {
+				/* Clear the rest of the buffers on error */
+				put_bh(bh);
+				bhs[i] = NULL;
+				continue;
+			}
 			/* We know this can't have changed as we hold the
 			 * owner sem. Avoid doing any work on the bh if the
 			 * journal has it. */