summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikulas Patocka <mpatocka@redhat.com>2009-06-22 10:12:14 +0100
committerAlasdair G Kergon <agk@redhat.com>2009-06-22 10:12:14 +0100
commit5657e8fa45cf230df278040c420fb80e06309d8f (patch)
tree7817e1bd6c9b721be85fe54a1aec6ef971d7d96b
parent8cbeb67ad50f7d68e5e83be2cb2284de8f9c03b5 (diff)
downloadop-kernel-dev-5657e8fa45cf230df278040c420fb80e06309d8f.zip
op-kernel-dev-5657e8fa45cf230df278040c420fb80e06309d8f.tar.gz
dm: use i_size_read
Use i_size_read() instead of reading i_size. If someone changes the size of the device simultaneously, i_size_read is guaranteed to return a valid value (either the old one or the new one). i_size can return some intermediate invalid value (on 32-bit computers with 64-bit i_size, the reads to both halves of i_size can be interleaved with updates to i_size, resulting in garbage being returned). Cc: stable@kernel.org Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com>
-rw-r--r--drivers/md/dm-exception-store.h2
-rw-r--r--drivers/md/dm-log.c2
-rw-r--r--drivers/md/dm-table.c3
3 files changed, 4 insertions, 3 deletions
diff --git a/drivers/md/dm-exception-store.h b/drivers/md/dm-exception-store.h
index c92701d..2442c8c 100644
--- a/drivers/md/dm-exception-store.h
+++ b/drivers/md/dm-exception-store.h
@@ -156,7 +156,7 @@ static inline void dm_consecutive_chunk_count_inc(struct dm_snap_exception *e)
*/
static inline sector_t get_dev_size(struct block_device *bdev)
{
- return bdev->bd_inode->i_size >> SECTOR_SHIFT;
+ return i_size_read(bdev->bd_inode) >> SECTOR_SHIFT;
}
static inline chunk_t sector_to_chunk(struct dm_exception_store *store,
diff --git a/drivers/md/dm-log.c b/drivers/md/dm-log.c
index 6fa8ccf..6352a9a 100644
--- a/drivers/md/dm-log.c
+++ b/drivers/md/dm-log.c
@@ -416,7 +416,7 @@ static int create_log_context(struct dm_dirty_log *log, struct dm_target *ti,
bitset_size,
ti->limits.logical_block_size);
- if (buf_size > dev->bdev->bd_inode->i_size) {
+ if (buf_size > i_size_read(dev->bdev->bd_inode)) {
DMWARN("log device %s too small: need %llu bytes",
dev->name, (unsigned long long)buf_size);
kfree(lc);
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index e9a73bb..0e2210c 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -388,7 +388,8 @@ static void close_dev(struct dm_dev_internal *d, struct mapped_device *md)
static int check_device_area(struct dm_dev_internal *dd, sector_t start,
sector_t len)
{
- sector_t dev_size = dd->dm_dev.bdev->bd_inode->i_size >> SECTOR_SHIFT;
+ sector_t dev_size = i_size_read(dd->dm_dev.bdev->bd_inode) >>
+ SECTOR_SHIFT;
if (!dev_size)
return 1;
OpenPOWER on IntegriCloud