diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/nilfs2/btnode.c | 17 | ||||
-rw-r--r-- | fs/nilfs2/btnode.h | 4 | ||||
-rw-r--r-- | fs/nilfs2/btree.c | 3 | ||||
-rw-r--r-- | fs/nilfs2/gcinode.c | 6 |
4 files changed, 22 insertions, 8 deletions
diff --git a/fs/nilfs2/btnode.c b/fs/nilfs2/btnode.c index 0a6834bb278e..f78ab1044d1d 100644 --- a/fs/nilfs2/btnode.c +++ b/fs/nilfs2/btnode.c | |||
@@ -96,7 +96,8 @@ nilfs_btnode_create_block(struct address_space *btnc, __u64 blocknr) | |||
96 | } | 96 | } |
97 | 97 | ||
98 | int nilfs_btnode_submit_block(struct address_space *btnc, __u64 blocknr, | 98 | int nilfs_btnode_submit_block(struct address_space *btnc, __u64 blocknr, |
99 | sector_t pblocknr, struct buffer_head **pbh) | 99 | sector_t pblocknr, int mode, |
100 | struct buffer_head **pbh, sector_t *submit_ptr) | ||
100 | { | 101 | { |
101 | struct buffer_head *bh; | 102 | struct buffer_head *bh; |
102 | struct inode *inode = NILFS_BTNC_I(btnc); | 103 | struct inode *inode = NILFS_BTNC_I(btnc); |
@@ -127,7 +128,16 @@ int nilfs_btnode_submit_block(struct address_space *btnc, __u64 blocknr, | |||
127 | } | 128 | } |
128 | } | 129 | } |
129 | } | 130 | } |
130 | lock_buffer(bh); | 131 | |
132 | if (mode == READA) { | ||
133 | if (pblocknr != *submit_ptr + 1 || !trylock_buffer(bh)) { | ||
134 | err = -EBUSY; /* internal code */ | ||
135 | brelse(bh); | ||
136 | goto out_locked; | ||
137 | } | ||
138 | } else { /* mode == READ */ | ||
139 | lock_buffer(bh); | ||
140 | } | ||
131 | if (buffer_uptodate(bh)) { | 141 | if (buffer_uptodate(bh)) { |
132 | unlock_buffer(bh); | 142 | unlock_buffer(bh); |
133 | err = -EEXIST; /* internal code */ | 143 | err = -EEXIST; /* internal code */ |
@@ -138,8 +148,9 @@ int nilfs_btnode_submit_block(struct address_space *btnc, __u64 blocknr, | |||
138 | bh->b_blocknr = pblocknr; /* set block address for read */ | 148 | bh->b_blocknr = pblocknr; /* set block address for read */ |
139 | bh->b_end_io = end_buffer_read_sync; | 149 | bh->b_end_io = end_buffer_read_sync; |
140 | get_bh(bh); | 150 | get_bh(bh); |
141 | submit_bh(READ, bh); | 151 | submit_bh(mode, bh); |
142 | bh->b_blocknr = blocknr; /* set back to the given block address */ | 152 | bh->b_blocknr = blocknr; /* set back to the given block address */ |
153 | *submit_ptr = pblocknr; | ||
143 | err = 0; | 154 | err = 0; |
144 | found: | 155 | found: |
145 | *pbh = bh; | 156 | *pbh = bh; |
diff --git a/fs/nilfs2/btnode.h b/fs/nilfs2/btnode.h index 07da83f07712..79037494f1e0 100644 --- a/fs/nilfs2/btnode.h +++ b/fs/nilfs2/btnode.h | |||
@@ -42,8 +42,8 @@ void nilfs_btnode_cache_init(struct address_space *, struct backing_dev_info *); | |||
42 | void nilfs_btnode_cache_clear(struct address_space *); | 42 | void nilfs_btnode_cache_clear(struct address_space *); |
43 | struct buffer_head *nilfs_btnode_create_block(struct address_space *btnc, | 43 | struct buffer_head *nilfs_btnode_create_block(struct address_space *btnc, |
44 | __u64 blocknr); | 44 | __u64 blocknr); |
45 | int nilfs_btnode_submit_block(struct address_space *, __u64, sector_t, | 45 | int nilfs_btnode_submit_block(struct address_space *, __u64, sector_t, int, |
46 | struct buffer_head **); | 46 | struct buffer_head **, sector_t *); |
47 | void nilfs_btnode_delete(struct buffer_head *); | 47 | void nilfs_btnode_delete(struct buffer_head *); |
48 | int nilfs_btnode_prepare_change_key(struct address_space *, | 48 | int nilfs_btnode_prepare_change_key(struct address_space *, |
49 | struct nilfs_btnode_chkey_ctxt *); | 49 | struct nilfs_btnode_chkey_ctxt *); |
diff --git a/fs/nilfs2/btree.c b/fs/nilfs2/btree.c index 6462c7026479..4669389bf686 100644 --- a/fs/nilfs2/btree.c +++ b/fs/nilfs2/btree.c | |||
@@ -71,9 +71,10 @@ static int nilfs_btree_get_block(const struct nilfs_bmap *btree, __u64 ptr, | |||
71 | { | 71 | { |
72 | struct address_space *btnc = &NILFS_BMAP_I(btree)->i_btnode_cache; | 72 | struct address_space *btnc = &NILFS_BMAP_I(btree)->i_btnode_cache; |
73 | struct buffer_head *bh; | 73 | struct buffer_head *bh; |
74 | sector_t pbn = 0; | ||
74 | int err; | 75 | int err; |
75 | 76 | ||
76 | err = nilfs_btnode_submit_block(btnc, ptr, 0, bhp); | 77 | err = nilfs_btnode_submit_block(btnc, ptr, pbn, READ, bhp, &pbn); |
77 | if (err) | 78 | if (err) |
78 | return err == -EEXIST ? 0 : err; | 79 | return err == -EEXIST ? 0 : err; |
79 | 80 | ||
diff --git a/fs/nilfs2/gcinode.c b/fs/nilfs2/gcinode.c index b6343825f91a..bed3a783129b 100644 --- a/fs/nilfs2/gcinode.c +++ b/fs/nilfs2/gcinode.c | |||
@@ -151,8 +151,10 @@ int nilfs_gccache_submit_read_data(struct inode *inode, sector_t blkoff, | |||
151 | int nilfs_gccache_submit_read_node(struct inode *inode, sector_t pbn, | 151 | int nilfs_gccache_submit_read_node(struct inode *inode, sector_t pbn, |
152 | __u64 vbn, struct buffer_head **out_bh) | 152 | __u64 vbn, struct buffer_head **out_bh) |
153 | { | 153 | { |
154 | int ret = nilfs_btnode_submit_block(&NILFS_I(inode)->i_btnode_cache, | 154 | int ret; |
155 | vbn ? : pbn, pbn, out_bh); | 155 | |
156 | ret = nilfs_btnode_submit_block(&NILFS_I(inode)->i_btnode_cache, | ||
157 | vbn ? : pbn, pbn, READ, out_bh, &pbn); | ||
156 | if (ret == -EEXIST) /* internal code (cache hit) */ | 158 | if (ret == -EEXIST) /* internal code (cache hit) */ |
157 | ret = 0; | 159 | ret = 0; |
158 | return ret; | 160 | return ret; |