aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nilfs2/btnode.c
diff options
context:
space:
mode:
authorRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2010-07-17 21:42:23 -0400
committerRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2010-07-22 21:02:15 -0400
commit26dfdd8e29f28c08aa67861b3c83d0f3f7d30cee (patch)
tree3cc14a71010b454f6524006e973147837f040a39 /fs/nilfs2/btnode.c
parentf8e6cc013b896d75d6ce4ec9e168014af1257fd8 (diff)
nilfs2: add read ahead mode to nilfs_btnode_submit_block
This adds mode argument to nilfs_btnode_submit_block() function and allows it to issue a read-ahead request. An optional submit_ptr argument is also added to store the actual block address for which bio is sent. submit_ptr is used for a series of read-ahead requests, and helps to decide if each requested block is continous to the previous one on disk. Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Diffstat (limited to 'fs/nilfs2/btnode.c')
-rw-r--r--fs/nilfs2/btnode.c17
1 files changed, 14 insertions, 3 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
98int nilfs_btnode_submit_block(struct address_space *btnc, __u64 blocknr, 98int 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;
144found: 155found:
145 *pbh = bh; 156 *pbh = bh;