ocfs2: clear the rest of the buffers on error
authorGoldwyn Rodrigues <rgoldwyn@suse.de>
Fri, 4 Sep 2015 22:44:20 +0000 (15:44 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 4 Sep 2015 23:54:41 +0000 (16:54 -0700)
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>
Reviewed-by: Mark Fasheh <mfasheh@suse.de>
Cc: Joel Becker <jlbec@evilplan.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/ocfs2/buffer_head_io.c

index 1edcb141f63930919a62d4a4e827c48954113cf1..fe50ded1b4ce763e33579ab54a982e64ed06003e 100644 (file)
@@ -316,6 +316,12 @@ int ocfs2_read_blocks(struct ocfs2_caching_info *ci, u64 block, int nr,
                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. */