Merge branch 'kvm-updates/2.6.36' of git://git.kernel.org/pub/scm/virt/kvm/kvm
[firefly-linux-kernel-4.4.55.git] / fs / nilfs2 / gcinode.c
index 145f03cd7d3e0299cda6786313804f1f1bf009ce..bed3a783129bfceb611106699d04914db5c1063e 100644 (file)
@@ -48,6 +48,8 @@
 #include <linux/slab.h>
 #include <linux/swap.h>
 #include "nilfs.h"
+#include "btree.h"
+#include "btnode.h"
 #include "page.h"
 #include "mdt.h"
 #include "dat.h"
@@ -149,8 +151,10 @@ int nilfs_gccache_submit_read_data(struct inode *inode, sector_t blkoff,
 int nilfs_gccache_submit_read_node(struct inode *inode, sector_t pbn,
                                   __u64 vbn, struct buffer_head **out_bh)
 {
-       int ret = nilfs_btnode_submit_block(&NILFS_I(inode)->i_btnode_cache,
-                                           vbn ? : pbn, pbn, out_bh);
+       int ret;
+
+       ret = nilfs_btnode_submit_block(&NILFS_I(inode)->i_btnode_cache,
+                                       vbn ? : pbn, pbn, READ, out_bh, &pbn);
        if (ret == -EEXIST) /* internal code (cache hit) */
                ret = 0;
        return ret;
@@ -164,10 +168,15 @@ int nilfs_gccache_wait_and_mark_dirty(struct buffer_head *bh)
        if (buffer_dirty(bh))
                return -EEXIST;
 
-       if (buffer_nilfs_node(bh))
+       if (buffer_nilfs_node(bh)) {
+               if (nilfs_btree_broken_node_block(bh)) {
+                       clear_buffer_uptodate(bh);
+                       return -EIO;
+               }
                nilfs_btnode_mark_dirty(bh);
-       else
+       } else {
                nilfs_mdt_mark_buffer_dirty(bh);
+       }
        return 0;
 }