]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: fail _dir_open when readahead fails
authorDarrick J. Wong <darrick.wong@oracle.com>
Tue, 4 Apr 2017 20:37:43 +0000 (15:37 -0500)
committerEric Sandeen <sandeen@redhat.com>
Tue, 4 Apr 2017 20:37:43 +0000 (15:37 -0500)
Source kernel commit: 7a652bbe366464267190c2792a32ce4fff5595ef

When we open a directory, we try to readahead block 0 of the directory
on the assumption that we're going to need it soon.  If the bmbt is
corrupt, the directory will never be usable and the readahead fails
immediately, so we might as well prevent the directory from being opened
at all.  This prevents a subsequent read or modify operation from
hitting it and taking the fs offline.

NOTE: We're only checking for early failures in the block mapping, not
the readahead directory block itself.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/xfs_da_btree.c
libxfs/xfs_da_btree.h

index efcf1baab2e34da496afda7ed595432ed29a3b45..bc12f58f587e207ff18e92ec51e312a7e4c0640d 100644 (file)
@@ -2628,7 +2628,7 @@ out_free:
 /*
  * Readahead the dir/attr block.
  */
-xfs_daddr_t
+int
 xfs_da_reada_buf(
        struct xfs_inode        *dp,
        xfs_dablk_t             bno,
@@ -2659,7 +2659,5 @@ out_free:
        if (mapp != &map)
                kmem_free(mapp);
 
-       if (error)
-               return -1;
-       return mappedbno;
+       return error;
 }
index 98c75cbe6ac2ec6063bf381cead3cea002a87dff..4e29cb6a36279515e3807de7be0d3b2d55cac8a2 100644 (file)
@@ -201,7 +201,7 @@ int xfs_da_read_buf(struct xfs_trans *trans, struct xfs_inode *dp,
                               xfs_dablk_t bno, xfs_daddr_t mappedbno,
                               struct xfs_buf **bpp, int whichfork,
                               const struct xfs_buf_ops *ops);
-xfs_daddr_t    xfs_da_reada_buf(struct xfs_inode *dp, xfs_dablk_t bno,
+int    xfs_da_reada_buf(struct xfs_inode *dp, xfs_dablk_t bno,
                                xfs_daddr_t mapped_bno, int whichfork,
                                const struct xfs_buf_ops *ops);
 int    xfs_da_shrink_inode(xfs_da_args_t *args, xfs_dablk_t dead_blkno,