From patchwork Wed Mar 3 18:55:16 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jim owens X-Patchwork-Id: 83412 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 o23IteH2003697 for ; Wed, 3 Mar 2010 18:55:40 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752504Ab0CCSzX (ORCPT ); Wed, 3 Mar 2010 13:55:23 -0500 Received: from mail-iw0-f182.google.com ([209.85.223.182]:33638 "EHLO mail-iw0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752454Ab0CCSzT (ORCPT ); Wed, 3 Mar 2010 13:55:19 -0500 Received: by mail-iw0-f182.google.com with SMTP id 12so1488185iwn.21 for ; Wed, 03 Mar 2010 10:55:19 -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=0y13DLfNTPisJpv2i/cTNXzzIGu6sOz5opdXYvLIfyQ=; b=qj5BKAKIzLriKLDUZ3ea9xyO5EbtpA48bnDOmgsmDYIN885p3pa/d8giVEw+Zi/lVb bFM0m1pC9VkpESOKt6mL6EPZ1zo4Ecfzo0m2oxYu3nq+/0E56/opfyYtT9E1U7casVNa TSHIlE7rVjigX/vArU1qFFOwBNRSGDhmtrSiU= 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=N0EhENtZ5tLEf6gM+3SfUrxHAB1Osp9qfvUP27cGNXDFkDSATTNHdczcviO2HHG5zW yBwKTlcQ+Y5eQ/HfkN6XCwQ1Adw9B9GxFZL+rWde92R/oHGGfljyhqce1FOJc9CkYnfN Nw6z6hKC081Ffx8kk7s9ebUY4ROEYPfWZNPqY= Received: by 10.231.144.15 with SMTP id x15mr455567ibu.99.1267642518887; Wed, 03 Mar 2010 10:55:18 -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 cx9sm219082ibb.13.2010.03.03.10.55.17 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 03 Mar 2010 10:55:18 -0800 (PST) Message-ID: <4B8EB094.3050904@gmail.com> Date: Wed, 03 Mar 2010 13:55:16 -0500 From: jim owens User-Agent: Thunderbird 2.0.0.23 (X11/20090817) MIME-Version: 1.0 To: linux-btrfs Subject: [PATCH dio.c V2 4/6] Btrfs: remove blocksize from diocb. 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]); Wed, 03 Mar 2010 18:55:40 +0000 (UTC) diff --git a/fs/btrfs/dio.c b/fs/btrfs/dio.c index 9f53577..ad9b58f 100644 --- a/fs/btrfs/dio.c +++ b/fs/btrfs/dio.c @@ -135,7 +135,6 @@ struct btrfs_diocb { struct workspace *workspace; char *csum_buf; - u32 blocksize; int rw; int error; int sleeping; @@ -261,7 +260,6 @@ ssize_t btrfs_direct_IO(int rw, struct kiocb *kiocb, diocb->begin = offset; diocb->terminate = offset + done; diocb->inode = inode; - diocb->blocksize = BTRFS_I(diocb->inode)->root->sectorsize; diocb->umc.user_iov = iov; diocb->umc.work_iov = *iov; @@ -436,10 +434,11 @@ static void btrfs_dio_read(struct btrfs_diocb *diocb) u64 data_len; int err = 0; int loop = 0; + u32 blocksize = BTRFS_I(diocb->inode)->root->sectorsize; /* expand lock region to include what we read to validate checksum */ - diocb->lockstart = diocb->start & ~(diocb->blocksize-1); - diocb->lockend = ALIGN(diocb->terminate, diocb->blocksize) - 1; + diocb->lockstart = diocb->start & ~(blocksize - 1); + diocb->lockend = ALIGN(diocb->terminate, blocksize) - 1; getlock: mutex_lock(&diocb->inode->i_mutex); @@ -465,7 +464,7 @@ getlock: if (!loop) { loop++; diocb->terminate = end; - diocb->lockend = ALIGN(diocb->terminate, diocb->blocksize) - 1; + diocb->lockend = ALIGN(diocb->terminate, blocksize) - 1; } lock_extent(io_tree, diocb->lockstart, diocb->lockend, GFP_NOFS); @@ -686,12 +685,13 @@ static int btrfs_dio_extent_read(struct btrfs_diocb *diocb, int csum = !(BTRFS_I(diocb->inode)->flags & BTRFS_INODE_NODATASUM); u64 csum_before = 0; u64 csum_after = 0; - u32 filetail = (data_start + data_len) & (diocb->blocksize - 1); + u32 blocksize = BTRFS_I(diocb->inode)->root->sectorsize; + u32 filetail = (data_start + data_len) & (blocksize - 1); if (csum) { - csum_before = data_start & (diocb->blocksize - 1); + csum_before = data_start & (blocksize - 1); if (filetail) - csum_after = diocb->blocksize - filetail; + csum_after = blocksize - filetail; } /* make post-eof consistent between inline/compressed/normal extents */ @@ -767,9 +767,9 @@ static int btrfs_dio_extent_read(struct btrfs_diocb *diocb, * extent as "tail checksum" and recalculate what we * have remaining for next loop. */ - if (csum && (extcb->iolen & (diocb->blocksize - 1))) { - u64 align_size = diocb->blocksize - - (extcb->iolen & (diocb->blocksize - 1)); + if (csum && (extcb->iolen & (blocksize - 1))) { + u64 align_size = blocksize - + (extcb->iolen & (blocksize - 1)); data_len += filetail; if (data_len <= align_size) { @@ -778,10 +778,10 @@ static int btrfs_dio_extent_read(struct btrfs_diocb *diocb, } else { extcb->filetail = align_size; filetail = (data_start + data_len) & - (diocb->blocksize - 1); + (blocksize - 1); data_len -= align_size; if (csum && filetail) - csum_after = diocb->blocksize - + csum_after = blocksize - filetail; else csum_after = 0; @@ -1641,14 +1641,15 @@ static int btrfs_dio_read_csum(struct btrfs_dio_extcb *extcb) struct bio_vec ivec; struct btrfs_root *root = BTRFS_I(extcb->diocb->inode)->root->fs_info->csum_root; - u32 iolen_per_csum_buf = extcb->diocb->blocksize * (extcb->tmpbuf_size + u32 blocksize = BTRFS_I(extcb->diocb->inode)->root->sectorsize; + u32 iolen_per_csum_buf = blocksize * (extcb->tmpbuf_size / btrfs_super_csum_size(&root->fs_info->super_copy)); - if (extcb->iolen & (extcb->diocb->blocksize - 1)) { + if (extcb->iolen & (blocksize - 1)) { printk(KERN_WARNING "btrfs directIO unaligned checksum for ino %lu\n", extcb->diocb->inode->i_ino); - extcb->iolen &= ~(extcb->diocb->blocksize - 1); + extcb->iolen &= ~(blocksize - 1); } ivec.bv_len = 0; @@ -1671,7 +1672,7 @@ static int btrfs_dio_read_csum(struct btrfs_dio_extcb *extcb) } while (len) { - u32 csum_len = extcb->diocb->blocksize; + u32 csum_len = blocksize; /* each checksum block is a filesystem block and on the * same device, but user memory can be 512 byte aligned @@ -1709,31 +1710,29 @@ static int btrfs_dio_read_csum(struct btrfs_dio_extcb *extcb) extcb->retry_csum = *fs_csum; extcb->retry_start = extcb->iostart; extcb->retry_mirror = 0; - extcb->retry_len = extcb->diocb->blocksize; + extcb->retry_len = blocksize; /* need to give back vector remaining * length and the length of checksum block * so we are at correct input spot for retry */ - ivec.bv_len += extcb->diocb->blocksize; + ivec.bv_len += blocksize; btrfs_dio_put_next_in(&ivec, extcb); return btrfs_dio_retry_block(extcb); } - extcb->iostart += extcb->diocb->blocksize; - extcb->iolen -= extcb->diocb->blocksize; + extcb->iostart += blocksize; + extcb->iolen -= blocksize; if (!extcb->compressed) { if (!extcb->iolen && extcb->filetail) { extcb->filestart += extcb->filetail; } else { - extcb->filestart += - extcb->diocb->blocksize; + extcb->filestart += blocksize; /* 1st extent can start inside block */ - extcb->filestart &= - ~(extcb->diocb->blocksize - 1); + extcb->filestart &= ~(blocksize - 1); } } - len -= extcb->diocb->blocksize; + len -= blocksize; fs_csum++; cond_resched(); } @@ -1767,7 +1766,7 @@ static void btrfs_dio_free_retry(struct btrfs_dio_extcb *extcb) static int btrfs_dio_retry_block(struct btrfs_dio_extcb *extcb) { struct btrfs_stripe_info stripe_info; - u64 len = extcb->diocb->blocksize; + u64 len = BTRFS_I(extcb->diocb->inode)->root->sectorsize; u64 physical; struct backing_dev_info *bdi; int pages = ALIGN(len, PAGE_SIZE) / PAGE_SIZE; @@ -1872,6 +1871,8 @@ static int btrfs_dio_bad_bio_scan(struct btrfs_dio_extcb *extcb) static int btrfs_dio_read_retry(struct btrfs_dio_extcb *extcb) { + u32 blocksize = BTRFS_I(extcb->diocb->inode)->root->sectorsize; + /* begin with first I/O error from bios sent by initial extent submit */ if (!extcb->retry_bio) { extcb->retry_start = extcb->iostart; @@ -1913,11 +1914,11 @@ static int btrfs_dio_read_retry(struct btrfs_dio_extcb *extcb) if (!extcb->compressed) { struct bio_vec *retry = extcb->retry_bio->bi_io_vec; struct bio_vec bad; - u32 bad_len = min(extcb->retry_len, extcb->diocb->blocksize); + u32 bad_len = min(extcb->retry_len, blocksize); u32 offset; /* user file position can start inside logical block */ - offset = extcb->retry_start & (extcb->diocb->blocksize-1); + offset = extcb->retry_start & (blocksize - 1); retry->bv_offset += offset; retry->bv_len -= offset; @@ -1953,26 +1954,25 @@ static int btrfs_dio_read_retry(struct btrfs_dio_extcb *extcb) btrfs_dio_free_retry(extcb); if (extcb->retry_csum) { - extcb->iostart += extcb->diocb->blocksize; - extcb->iolen -= extcb->diocb->blocksize; + extcb->iostart += blocksize; + extcb->iolen -= blocksize; if (!extcb->compressed) { if (!extcb->iolen && extcb->filetail) { extcb->filestart += extcb->filetail; } else { - extcb->filestart += extcb->diocb->blocksize; - extcb->filestart &= - ~(extcb->diocb->blocksize - 1); + extcb->filestart += blocksize; + extcb->filestart &= ~(blocksize - 1); } } return 0; } /* we are still processing bad bios from I/O submit */ - extcb->retry_start += extcb->diocb->blocksize; + extcb->retry_start += blocksize; extcb->retry_mirror = 0; /* do we have any more blocks to do in this bio */ - extcb->retry_len -= extcb->diocb->blocksize; + extcb->retry_len -= blocksize; if (extcb->retry_len) return btrfs_dio_retry_block(extcb);