{"id":807111,"url":"http://patchwork.ozlabs.org/api/1.0/patches/807111/?format=json","project":{"id":8,"url":"http://patchwork.ozlabs.org/api/1.0/projects/8/?format=json","name":"Linux ext4 filesystem development","link_name":"linux-ext4","list_id":"linux-ext4.vger.kernel.org","list_email":"linux-ext4@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null},"msgid":"<20170829142942.21594-2-agruenba@redhat.com>","date":"2017-08-29T14:29:39","name":"[1/4] iomap: Switch from blkno to disk offset","commit_ref":null,"pull_url":null,"state":"accepted","archived":true,"hash":"7b1454df7cf9863592452d6ca304c1449d2fc4c6","submitter":{"id":67290,"url":"http://patchwork.ozlabs.org/api/1.0/people/67290/?format=json","name":"Andreas Gruenbacher","email":"agruenba@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-ext4/patch/20170829142942.21594-2-agruenba@redhat.com/mbox/","series":[{"id":378,"url":"http://patchwork.ozlabs.org/api/1.0/series/378/?format=json","date":"2017-08-29T14:29:38","name":"ext4: SEEK_HOLE / SEEK_DATA via iomap","version":1,"mbox":"http://patchwork.ozlabs.org/series/378/mbox/"}],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/807111/checks/","tags":{},"headers":{"Return-Path":"<linux-ext4-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=linux-ext4-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","ext-mx09.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx09.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=agruenba@redhat.com"],"Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xhWHn3s7Pz9t38\n\tfor <patchwork-incoming@ozlabs.org>;\n\tWed, 30 Aug 2017 00:29:57 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1754357AbdH2O3x (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tTue, 29 Aug 2017 10:29:53 -0400","from mx1.redhat.com ([209.132.183.28]:56410 \"EHLO mx1.redhat.com\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1753591AbdH2O3u (ORCPT <rfc822;linux-ext4@vger.kernel.org>);\n\tTue, 29 Aug 2017 10:29:50 -0400","from smtp.corp.redhat.com\n\t(int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 2227968DA;\n\tTue, 29 Aug 2017 14:29:50 +0000 (UTC)","from max.home.com (ovpn-116-105.ams2.redhat.com [10.36.116.105])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 902C9692A5;\n\tTue, 29 Aug 2017 14:29:46 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 2227968DA","From":"Andreas Gruenbacher <agruenba@redhat.com>","To":"linux-fsdevel@vger.kernel.org","Cc":"linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org,\n\tJan Kara <jack@suse.cz>, Christoph Hellwig <hch@lst.de>,\n\tAndreas Gruenbacher <agruenba@redhat.com>","Subject":"[PATCH 1/4] iomap: Switch from blkno to disk offset","Date":"Tue, 29 Aug 2017 16:29:39 +0200","Message-Id":"<20170829142942.21594-2-agruenba@redhat.com>","In-Reply-To":"<20170829142942.21594-1-agruenba@redhat.com>","References":"<20170829142942.21594-1-agruenba@redhat.com>","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.16","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.38]);\n\tTue, 29 Aug 2017 14:29:50 +0000 (UTC)","Sender":"linux-ext4-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<linux-ext4.vger.kernel.org>","X-Mailing-List":"linux-ext4@vger.kernel.org"},"content":"Replace iomap->blkno, the sector number, with iomap->addr, the disk\noffset in bytes.  For invalid disk offsets, use the special value\nIOMAP_NULL_ADDR instead of IOMAP_NULL_BLOCK.  This allows to use iomap\nfor mappings which are not block aligned, such as inline data on ext4\nand stuffed inodes on gfs2.\n\nTested on xfs and ext4 with xfstests; seems to be working correctly.\n\nSigned-off-by: Andreas Gruenbacher <agruenba@redhat.com>\n---\n fs/buffer.c           |  4 ++--\n fs/dax.c              |  2 +-\n fs/ext2/inode.c       |  4 ++--\n fs/ext4/inode.c       |  4 ++--\n fs/iomap.c            | 11 +++++------\n fs/nfsd/blocklayout.c |  4 ++--\n fs/xfs/xfs_iomap.c    |  6 +++---\n include/linux/iomap.h | 10 +++++-----\n 8 files changed, 22 insertions(+), 23 deletions(-)","diff":"diff --git a/fs/buffer.c b/fs/buffer.c\nindex 5715dac7821f..b9d20076bb8f 100644\n--- a/fs/buffer.c\n+++ b/fs/buffer.c\n@@ -1979,8 +1979,8 @@ iomap_to_bh(struct inode *inode, sector_t block, struct buffer_head *bh,\n \tcase IOMAP_MAPPED:\n \t\tif (offset >= i_size_read(inode))\n \t\t\tset_buffer_new(bh);\n-\t\tbh->b_blocknr = (iomap->blkno >> (inode->i_blkbits - 9)) +\n-\t\t\t\t((offset - iomap->offset) >> inode->i_blkbits);\n+\t\tbh->b_blocknr = (iomap->addr + offset - iomap->offset) >>\n+\t\t\t\tinode->i_blkbits;\n \t\tset_buffer_mapped(bh);\n \t\tbreak;\n \t}\ndiff --git a/fs/dax.c b/fs/dax.c\nindex 865d42c63e23..539aaa0b9c45 100644\n--- a/fs/dax.c\n+++ b/fs/dax.c\n@@ -987,7 +987,7 @@ EXPORT_SYMBOL_GPL(__dax_zero_page_range);\n \n static sector_t dax_iomap_sector(struct iomap *iomap, loff_t pos)\n {\n-\treturn iomap->blkno + (((pos & PAGE_MASK) - iomap->offset) >> 9);\n+\treturn (iomap->addr + (pos & PAGE_MASK) - iomap->offset) >> 9;\n }\n \n static loff_t\ndiff --git a/fs/ext2/inode.c b/fs/ext2/inode.c\nindex 30163d007b2f..e7d8925d0140 100644\n--- a/fs/ext2/inode.c\n+++ b/fs/ext2/inode.c\n@@ -824,11 +824,11 @@ static int ext2_iomap_begin(struct inode *inode, loff_t offset, loff_t length,\n \n \tif (ret == 0) {\n \t\tiomap->type = IOMAP_HOLE;\n-\t\tiomap->blkno = IOMAP_NULL_BLOCK;\n+\t\tiomap->addr = IOMAP_NULL_ADDR;\n \t\tiomap->length = 1 << blkbits;\n \t} else {\n \t\tiomap->type = IOMAP_MAPPED;\n-\t\tiomap->blkno = (sector_t)bno << (blkbits - 9);\n+\t\tiomap->addr = (u64)bno << blkbits;\n \t\tiomap->length = (u64)ret << blkbits;\n \t\tiomap->flags |= IOMAP_F_MERGED;\n \t}\ndiff --git a/fs/ext4/inode.c b/fs/ext4/inode.c\nindex c774bdc22759..429f0afde9f2 100644\n--- a/fs/ext4/inode.c\n+++ b/fs/ext4/inode.c\n@@ -3483,7 +3483,7 @@ static int ext4_iomap_begin(struct inode *inode, loff_t offset, loff_t length,\n \n \tif (ret == 0) {\n \t\tiomap->type = IOMAP_HOLE;\n-\t\tiomap->blkno = IOMAP_NULL_BLOCK;\n+\t\tiomap->addr = IOMAP_NULL_ADDR;\n \t\tiomap->length = (u64)map.m_len << blkbits;\n \t} else {\n \t\tif (map.m_flags & EXT4_MAP_MAPPED) {\n@@ -3494,7 +3494,7 @@ static int ext4_iomap_begin(struct inode *inode, loff_t offset, loff_t length,\n \t\t\tWARN_ON_ONCE(1);\n \t\t\treturn -EIO;\n \t\t}\n-\t\tiomap->blkno = (sector_t)map.m_pblk << (blkbits - 9);\n+\t\tiomap->addr = (u64)map.m_pblk << blkbits;\n \t\tiomap->length = (u64)map.m_len << blkbits;\n \t}\n \ndiff --git a/fs/iomap.c b/fs/iomap.c\nindex 59cc98ad7577..7bc1797c2292 100644\n--- a/fs/iomap.c\n+++ b/fs/iomap.c\n@@ -350,8 +350,8 @@ static int iomap_zero(struct inode *inode, loff_t pos, unsigned offset,\n static int iomap_dax_zero(loff_t pos, unsigned offset, unsigned bytes,\n \t\tstruct iomap *iomap)\n {\n-\tsector_t sector = iomap->blkno +\n-\t\t(((pos & ~(PAGE_SIZE - 1)) - iomap->offset) >> 9);\n+\tsector_t sector = (iomap->addr +\n+\t\t\t   (pos & PAGE_MASK) - iomap->offset) >> 9;\n \n \treturn __dax_zero_page_range(iomap->bdev, iomap->dax_dev, sector,\n \t\t\toffset, bytes);\n@@ -512,9 +512,8 @@ static int iomap_to_fiemap(struct fiemap_extent_info *fi,\n \t\tflags |= FIEMAP_EXTENT_SHARED;\n \n \treturn fiemap_fill_next_extent(fi, iomap->offset,\n-\t\t\tiomap->blkno != IOMAP_NULL_BLOCK ? iomap->blkno << 9: 0,\n+\t\t\tiomap->addr != IOMAP_NULL_ADDR ? iomap->addr : 0,\n \t\t\tiomap->length, flags);\n-\n }\n \n static loff_t\n@@ -807,7 +806,7 @@ iomap_dio_zero(struct iomap_dio *dio, struct iomap *iomap, loff_t pos,\n \tbio = bio_alloc(GFP_KERNEL, 1);\n \tbio->bi_bdev = iomap->bdev;\n \tbio->bi_iter.bi_sector =\n-\t\tiomap->blkno + ((pos - iomap->offset) >> 9);\n+\t\t(iomap->addr + pos - iomap->offset) >> 9;\n \tbio->bi_private = dio;\n \tbio->bi_end_io = iomap_dio_bio_end_io;\n \n@@ -886,7 +885,7 @@ iomap_dio_actor(struct inode *inode, loff_t pos, loff_t length,\n \t\tbio = bio_alloc(GFP_KERNEL, nr_pages);\n \t\tbio->bi_bdev = iomap->bdev;\n \t\tbio->bi_iter.bi_sector =\n-\t\t\tiomap->blkno + ((pos - iomap->offset) >> 9);\n+\t\t\t(iomap->addr + pos - iomap->offset) >> 9;\n \t\tbio->bi_write_hint = dio->iocb->ki_hint;\n \t\tbio->bi_private = dio;\n \t\tbio->bi_end_io = iomap_dio_bio_end_io;\ndiff --git a/fs/nfsd/blocklayout.c b/fs/nfsd/blocklayout.c\nindex c862c2489df0..2d1d37b27dc7 100644\n--- a/fs/nfsd/blocklayout.c\n+++ b/fs/nfsd/blocklayout.c\n@@ -65,7 +65,7 @@ nfsd4_block_proc_layoutget(struct inode *inode, const struct svc_fh *fhp,\n \t\t\tbex->es = PNFS_BLOCK_READ_DATA;\n \t\telse\n \t\t\tbex->es = PNFS_BLOCK_READWRITE_DATA;\n-\t\tbex->soff = (iomap.blkno << 9);\n+\t\tbex->soff = iomap.addr;\n \t\tbreak;\n \tcase IOMAP_UNWRITTEN:\n \t\tif (seg->iomode & IOMODE_RW) {\n@@ -78,7 +78,7 @@ nfsd4_block_proc_layoutget(struct inode *inode, const struct svc_fh *fhp,\n \t\t\t}\n \n \t\t\tbex->es = PNFS_BLOCK_INVALID_DATA;\n-\t\t\tbex->soff = (iomap.blkno << 9);\n+\t\t\tbex->soff = iomap.addr;\n \t\t\tbreak;\n \t\t}\n \t\t/*FALLTHRU*/\ndiff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c\nindex 813394c62849..1bcc5d0373a5 100644\n--- a/fs/xfs/xfs_iomap.c\n+++ b/fs/xfs/xfs_iomap.c\n@@ -54,13 +54,13 @@ xfs_bmbt_to_iomap(\n \tstruct xfs_mount\t*mp = ip->i_mount;\n \n \tif (imap->br_startblock == HOLESTARTBLOCK) {\n-\t\tiomap->blkno = IOMAP_NULL_BLOCK;\n+\t\tiomap->addr = IOMAP_NULL_ADDR;\n \t\tiomap->type = IOMAP_HOLE;\n \t} else if (imap->br_startblock == DELAYSTARTBLOCK) {\n-\t\tiomap->blkno = IOMAP_NULL_BLOCK;\n+\t\tiomap->addr = IOMAP_NULL_ADDR;\n \t\tiomap->type = IOMAP_DELALLOC;\n \t} else {\n-\t\tiomap->blkno = xfs_fsb_to_db(ip, imap->br_startblock);\n+\t\tiomap->addr = (u64)xfs_fsb_to_db(ip, imap->br_startblock) << 9;\n \t\tif (imap->br_state == XFS_EXT_UNWRITTEN)\n \t\t\tiomap->type = IOMAP_UNWRITTEN;\n \t\telse\ndiff --git a/include/linux/iomap.h b/include/linux/iomap.h\nindex f64dc6ce5161..7b8a615fa021 100644\n--- a/include/linux/iomap.h\n+++ b/include/linux/iomap.h\n@@ -15,8 +15,8 @@ struct vm_fault;\n  */\n #define IOMAP_HOLE\t0x01\t/* no blocks allocated, need allocation */\n #define IOMAP_DELALLOC\t0x02\t/* delayed allocation blocks */\n-#define IOMAP_MAPPED\t0x03\t/* blocks allocated @blkno */\n-#define IOMAP_UNWRITTEN\t0x04\t/* blocks allocated @blkno in unwritten state */\n+#define IOMAP_MAPPED\t0x03\t/* blocks allocated at @addr */\n+#define IOMAP_UNWRITTEN\t0x04\t/* blocks allocated at @addr in unwritten state */\n \n /*\n  * Flags for all iomap mappings:\n@@ -30,12 +30,12 @@ struct vm_fault;\n #define IOMAP_F_SHARED\t0x20\t/* block shared with another file */\n \n /*\n- * Magic value for blkno:\n+ * Magic value for addr:\n  */\n-#define IOMAP_NULL_BLOCK -1LL\t/* blkno is not valid */\n+#define IOMAP_NULL_ADDR -1ULL\t/* addr is not valid */\n \n struct iomap {\n-\tsector_t\t\tblkno;\t/* 1st sector of mapping, 512b units */\n+\tu64\t\t\taddr; /* disk offset of mapping, bytes */\n \tloff_t\t\t\toffset;\t/* file offset of mapping, bytes */\n \tu64\t\t\tlength;\t/* length of mapping, bytes */\n \tu16\t\t\ttype;\t/* type of mapping */\n","prefixes":["1/4"]}