From patchwork Mon May 18 15:35:51 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikulas Patocka X-Patchwork-Id: 24563 X-Patchwork-Delegate: agk@redhat.com Received: from hormel.redhat.com (hormel1.redhat.com [209.132.177.33]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n4IFZtpr024131 for ; Mon, 18 May 2009 15:35:55 GMT Received: from listman.util.phx.redhat.com (listman.util.phx.redhat.com [10.8.4.110]) by hormel.redhat.com (Postfix) with ESMTP id 86EB1618D9D; Mon, 18 May 2009 11:35:54 -0400 (EDT) Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by listman.util.phx.redhat.com (8.13.1/8.13.1) with ESMTP id n4IFZqNa016216 for ; Mon, 18 May 2009 11:35:52 -0400 Received: from hs20-bc2-1.build.redhat.com (hs20-bc2-1.build.redhat.com [10.10.28.34]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n4IFZpw0000682; Mon, 18 May 2009 11:35:51 -0400 Received: from hs20-bc2-1.build.redhat.com (localhost.localdomain [127.0.0.1]) by hs20-bc2-1.build.redhat.com (8.13.1/8.13.1) with ESMTP id n4IFZpFc026579; Mon, 18 May 2009 11:35:51 -0400 Received: from localhost (mpatocka@localhost) by hs20-bc2-1.build.redhat.com (8.13.1/8.13.1/Submit) with ESMTP id n4IFZpg3026573; Mon, 18 May 2009 11:35:51 -0400 X-Authentication-Warning: hs20-bc2-1.build.redhat.com: mpatocka owned process doing -bs Date: Mon, 18 May 2009 11:35:51 -0400 (EDT) From: Mikulas Patocka X-X-Sender: mpatocka@hs20-bc2-1.build.redhat.com To: "Jun'ichi Nomura" In-Reply-To: <4A093417.6050007@ce.jp.nec.com> Message-ID: References: <4A093417.6050007@ce.jp.nec.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 X-loop: dm-devel@redhat.com Cc: device-mapper development , Alasdair G Kergon Subject: [dm-devel] [PATCH] use i_size_read() instead of i_size X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.5 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com 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 --- drivers/md/dm-exception-store.h | 2 +- drivers/md/dm-log.c | 2 +- drivers/md/dm-table.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel Index: linux-2.6.30-rc5-fast/drivers/md/dm-exception-store.h =================================================================== --- linux-2.6.30-rc5-fast.orig/drivers/md/dm-exception-store.h 2009-05-18 17:29:01.000000000 +0200 +++ linux-2.6.30-rc5-fast/drivers/md/dm-exception-store.h 2009-05-18 17:29:24.000000000 +0200 @@ -156,7 +156,7 @@ static inline void dm_consecutive_chunk_ */ 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: linux-2.6.30-rc5-fast/drivers/md/dm-log.c =================================================================== --- linux-2.6.30-rc5-fast.orig/drivers/md/dm-log.c 2009-05-18 17:29:32.000000000 +0200 +++ linux-2.6.30-rc5-fast/drivers/md/dm-log.c 2009-05-18 17:29:42.000000000 +0200 @@ -431,7 +431,7 @@ static int create_log_context(struct dm_ 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: linux-2.6.30-rc5-fast/drivers/md/dm-table.c =================================================================== --- linux-2.6.30-rc5-fast.orig/drivers/md/dm-table.c 2009-05-18 17:29:46.000000000 +0200 +++ linux-2.6.30-rc5-fast/drivers/md/dm-table.c 2009-05-18 17:29:57.000000000 +0200 @@ -387,7 +387,7 @@ static void close_dev(struct dm_dev_inte static int device_area_is_valid(struct dm_target *ti, struct block_device *bdev, sector_t start, sector_t len) { - sector_t dev_size = bdev->bd_inode->i_size >> SECTOR_SHIFT; + sector_t dev_size = i_size_read(bdev->bd_inode) >> SECTOR_SHIFT; unsigned short hardsect_size_sectors = ti->limits.hardsect_size >> SECTOR_SHIFT; char b[BDEVNAME_SIZE];