From patchwork Fri Mar 5 19:42:18 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jim owens X-Patchwork-Id: 83828 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 o25JgP80024091 for ; Fri, 5 Mar 2010 19:42:25 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755488Ab0CETmY (ORCPT ); Fri, 5 Mar 2010 14:42:24 -0500 Received: from mail-fx0-f219.google.com ([209.85.220.219]:59674 "EHLO mail-fx0-f219.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755350Ab0CETmX (ORCPT ); Fri, 5 Mar 2010 14:42:23 -0500 Received: by mail-fx0-f219.google.com with SMTP id 19so4515087fxm.21 for ; Fri, 05 Mar 2010 11:42:23 -0800 (PST) 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=SZft2gHvlaLUY+cguSrsy3PPGf1UboXA/+xu0/XSyVM=; b=ts1nabN2KvYPvBFWlPsvk2dbEGz9zunil19Myke7WJqmbpjB+ygu2eosmIhclQSBqA ljXeDMHwbTny35sbNjLPSznzoqe/3wCSJJtlykkzWHcLGhoSEArTY80VaXXY+TTiQxUf vVy1mY5oFUqf7jj/PIfSi8I4ip4Nk+f4HkyT8= 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=jd0ex23pLQ+K6Tk5Jka0+dsQ7rcKLNZUz74XljACglOGHBT6uVjkOBw0Ue/N0Ov1qw e6fdnzbhpPEquJ7EHtGBprdi+0w4pz3tvW38V9JtEyGWosLkPQeVRxJUJrpAiGRW6ra7 9sqp8Sy7te440rSVnUUsHdomq8hkGLI6qY4/8= Received: by 10.223.77.91 with SMTP id f27mr1565664fak.60.1267818142502; Fri, 05 Mar 2010 11:42:22 -0800 (PST) Received: from [192.168.0.99] (c-24-147-40-65.hsd1.nh.comcast.net [24.147.40.65]) by mx.google.com with ESMTPS id 15sm1454903fxm.4.2010.03.05.11.42.20 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 05 Mar 2010 11:42:21 -0800 (PST) Message-ID: <4B915E9A.8070507@gmail.com> Date: Fri, 05 Mar 2010 14:42:18 -0500 From: jim owens User-Agent: Thunderbird 2.0.0.23 (X11/20090817) MIME-Version: 1.0 To: linux-btrfs , Chris Mason , Josef Bacik Subject: [PATCH 1/2] 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]); Fri, 05 Mar 2010 19:42:25 +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 d1a1b8d..5ff9878 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -573,10 +573,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; @@ -627,6 +631,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: @@ -646,6 +652,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; } @@ -1126,6 +1133,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); @@ -1277,6 +1285,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: @@ -1556,6 +1572,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 {