diff options
author | Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> | 2009-09-06 04:49:49 -0400 |
---|---|---|
committer | Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> | 2009-09-14 05:27:13 -0400 |
commit | 143511046765504d2d1be633efd710f8d84e0407 (patch) | |
tree | bd9b8570880cfda44a9fad7a2567b977ab53f631 /fs/nilfs2 | |
parent | 027d6404eb4327878454db72a006adfcb8001bb8 (diff) |
nilfs2: always lookup disk block address before reading metadata block
The current metadata file code skips disk address lookup for its data
block if the buffer has a mapped flag.
This has a potential risk to cause read request to be performed
against the stale block address that GC moved, and it may lead to meta
data corruption. The mapped flag is safe if the buffer has an
uptodate flag, otherwise it may prevent necessary update of disk
address in the next read.
This will avoid the potential problem by ensuring disk address lookup
before reading metadata block even for buffers with the mapped flag.
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Diffstat (limited to 'fs/nilfs2')
-rw-r--r-- | fs/nilfs2/mdt.c | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/fs/nilfs2/mdt.c b/fs/nilfs2/mdt.c index a5cd80162dc5..1ae8d56052c3 100644 --- a/fs/nilfs2/mdt.c +++ b/fs/nilfs2/mdt.c | |||
@@ -103,15 +103,12 @@ static int nilfs_mdt_create_block(struct inode *inode, unsigned long block, | |||
103 | goto failed_unlock; | 103 | goto failed_unlock; |
104 | 104 | ||
105 | err = -EEXIST; | 105 | err = -EEXIST; |
106 | if (buffer_uptodate(bh) || buffer_mapped(bh)) | 106 | if (buffer_uptodate(bh)) |
107 | goto failed_bh; | 107 | goto failed_bh; |
108 | #if 0 | 108 | |
109 | /* The uptodate flag is not protected by the page lock, but | ||
110 | the mapped flag is. Thus, we don't have to wait the buffer. */ | ||
111 | wait_on_buffer(bh); | 109 | wait_on_buffer(bh); |
112 | if (buffer_uptodate(bh)) | 110 | if (buffer_uptodate(bh)) |
113 | goto failed_bh; | 111 | goto failed_bh; |
114 | #endif | ||
115 | 112 | ||
116 | bh->b_bdev = nilfs->ns_bdev; | 113 | bh->b_bdev = nilfs->ns_bdev; |
117 | err = nilfs_mdt_insert_new_block(inode, block, bh, init_block); | 114 | err = nilfs_mdt_insert_new_block(inode, block, bh, init_block); |
@@ -162,17 +159,15 @@ nilfs_mdt_submit_block(struct inode *inode, unsigned long blkoff, | |||
162 | unlock_buffer(bh); | 159 | unlock_buffer(bh); |
163 | goto out; | 160 | goto out; |
164 | } | 161 | } |
165 | if (!buffer_mapped(bh)) { /* unused buffer */ | 162 | |
166 | ret = nilfs_bmap_lookup(NILFS_I(inode)->i_bmap, blkoff, | 163 | ret = nilfs_bmap_lookup(NILFS_I(inode)->i_bmap, blkoff, &blknum); |
167 | &blknum); | 164 | if (unlikely(ret)) { |
168 | if (unlikely(ret)) { | 165 | unlock_buffer(bh); |
169 | unlock_buffer(bh); | 166 | goto failed_bh; |
170 | goto failed_bh; | ||
171 | } | ||
172 | bh->b_bdev = NILFS_MDT(inode)->mi_nilfs->ns_bdev; | ||
173 | bh->b_blocknr = blknum; | ||
174 | set_buffer_mapped(bh); | ||
175 | } | 167 | } |
168 | bh->b_bdev = NILFS_MDT(inode)->mi_nilfs->ns_bdev; | ||
169 | bh->b_blocknr = blknum; | ||
170 | set_buffer_mapped(bh); | ||
176 | 171 | ||
177 | bh->b_end_io = end_buffer_read_sync; | 172 | bh->b_end_io = end_buffer_read_sync; |
178 | get_bh(bh); | 173 | get_bh(bh); |