]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
dm: use i_size_read
authorMikulas Patocka <mpatocka@redhat.com>
Mon, 22 Jun 2009 09:12:14 +0000 (10:12 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 2 Jul 2009 23:50:51 +0000 (16:50 -0700)
commit 5657e8fa45cf230df278040c420fb80e06309d8f upstream.

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).

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/md/dm-exception-store.h
drivers/md/dm-log.c
drivers/md/dm-table.c

index 0a2e6e7f67b3c5b6ac4c4cbd7dc2ca6811eaa30c..96a796be7c77ce416e51e0eb5848b0b7102e61a8 100644 (file)
@@ -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,
index be233bc4d91787a2729ef8ca740a946ddc782332..5eaa9542d5db962d434f2809b47f1ca88140d82a 100644 (file)
@@ -415,7 +415,7 @@ static int create_log_context(struct dm_dirty_log *log, struct dm_target *ti,
                buf_size = dm_round_up((LOG_OFFSET << SECTOR_SHIFT) +
                                       bitset_size, ti->limits.hardsect_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);
index 429b50b975d5a14af8c8e97412425ae9169784d3..c5c4a0d44e12908a4bf7bb22ab49f9b4bd1a6dc0 100644 (file)
@@ -387,7 +387,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;