From patchwork Mon Mar 22 03:31:35 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jim owens X-Patchwork-Id: 87346 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o2M3VdZ1019628 for ; Mon, 22 Mar 2010 03:31:39 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754019Ab0CVDbi (ORCPT ); Sun, 21 Mar 2010 23:31:38 -0400 Received: from qw-out-2122.google.com ([74.125.92.26]:35834 "EHLO qw-out-2122.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753711Ab0CVDbi (ORCPT ); Sun, 21 Mar 2010 23:31:38 -0400 Received: by qw-out-2122.google.com with SMTP id 8so1064010qwh.37 for ; Sun, 21 Mar 2010 20:31:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:content-type :content-transfer-encoding; bh=EUFAjjsHKB5GTV3j+96IfW4j3RcrP151EmoMsGZw4ug=; b=XX0iiVhUiyMYIZERSIIMP09uhCp8MzRZSwmKZ+w/zqjV/tE6fm0Giqa2CizR1x3/R9 R4KkHKYstD6XNbmbccH2adOp/SKuo14rgucHJ+TA4MwJ4oqiQnJHcpeJJrUGiteCNls6 c/ii87jfuBa0UfR/N7NPtbI6ftUdwO0hVPMhU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; b=xLDeT+cvJRnUoEP3rXuI6gDZhjAJXhZY2tMtQyM5+5xCzClFzY/GIf7jhfH6DGBTm1 mVGiOJ9Thk17MJVmhm2RDWP1c+36t/hw0kh98mYM2/F0F273PP5C7LVkJmnvmqZnwp2u SWGAxecNRWZrfDw/PINnyGJroGzjHZ311FnvI= Received: by 10.224.123.75 with SMTP id o11mr2099617qar.368.1269228697256; Sun, 21 Mar 2010 20:31:37 -0700 (PDT) Received: from [192.168.0.97] (c-24-147-40-65.hsd1.nh.comcast.net [24.147.40.65]) by mx.google.com with ESMTPS id 7sm7579424qwb.39.2010.03.21.20.31.36 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 21 Mar 2010 20:31:36 -0700 (PDT) Message-ID: <4BA6E497.5080801@gmail.com> Date: Sun, 21 Mar 2010 23:31:35 -0400 From: jim owens User-Agent: Thunderbird 2.0.0.24 (X11/20100317) MIME-Version: 1.0 To: linux-btrfs Subject: [PATCH V3 14/18] Btrfs: add multi-device minimum logical block size for direct I/O. Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Mon, 22 Mar 2010 03:31:39 +0000 (UTC) different block sizes, as in 512, 1024, 2048, 4096. DirectIO read will check user request alignment is valid for at least one device. Signed-off-by: jim owens --- fs/btrfs/volumes.c | 24 +++++++++++++++++++++++- fs/btrfs/volumes.h | 3 +++ 2 files changed, 26 insertions(+), 1 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index aedef39..a7697ef 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -580,10 +580,14 @@ static int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices, u64 devid; int seeding = 1; int ret = 0; + u32 dio_min_blocksize = PAGE_SIZE; list_for_each_entry(device, head, dev_list) { - if (device->bdev) + if (device->bdev) { + dio_min_blocksize = min_t(u32, dio_min_blocksize, + bdev_logical_block_size(device->bdev)); continue; + } if (!device->name) continue; @@ -634,6 +638,8 @@ static int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices, list_add(&device->dev_alloc_list, &fs_devices->alloc_list); } + dio_min_blocksize = min_t(u32, dio_min_blocksize, + bdev_logical_block_size(device->bdev)); continue; error_brelse: @@ -653,6 +659,7 @@ error: fs_devices->latest_devid = latest_devid; fs_devices->latest_trans = latest_transid; fs_devices->total_rw_bytes = 0; + fs_devices->dio_min_blocksize = dio_min_blocksize; out: return ret; } @@ -1133,6 +1140,7 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path) u64 num_devices; u8 *dev_uuid; int ret = 0; + u32 dio_min_blocksize; mutex_lock(&uuid_mutex); mutex_lock(&root->fs_info->volume_mutex); @@ -1284,6 +1292,14 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path) kfree(device); ret = 0; + dio_min_blocksize = PAGE_SIZE; + list_for_each_entry(device, + &root->fs_info->fs_devices->devices, dev_list) + if (device->bdev) + dio_min_blocksize = min_t(u32, dio_min_blocksize, + bdev_logical_block_size(device->bdev)); + root->fs_info->fs_devices->dio_min_blocksize = dio_min_blocksize; + error_brelse: brelse(bh); error_close: @@ -1563,6 +1579,12 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path) ret = btrfs_relocate_sys_chunks(root); BUG_ON(ret); } + + if (!ret) + root->fs_info->fs_devices->dio_min_blocksize = min_t(u32, + root->fs_info->fs_devices->dio_min_blocksize, + bdev_logical_block_size(bdev)); + out: mutex_unlock(&root->fs_info->volume_mutex); return ret; diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index 732c8c5..cce6039 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -117,6 +117,9 @@ struct btrfs_fs_devices { * nonrot flag set */ int rotating; + + /* smallest logical blocksize possible in file system for direct IO */ + u32 dio_min_blocksize; }; struct btrfs_bio_stripe {