From patchwork Mon Jun 4 12:37:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Gruenbacher X-Patchwork-Id: 10446555 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D2DB4603D7 for ; Mon, 4 Jun 2018 12:37:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BFC1F28E2E for ; Mon, 4 Jun 2018 12:37:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B49EF28E4B; Mon, 4 Jun 2018 12:37:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1759528E2E for ; Mon, 4 Jun 2018 12:37:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753074AbeFDMhw (ORCPT ); Mon, 4 Jun 2018 08:37:52 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:57664 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752722AbeFDMht (ORCPT ); Mon, 4 Jun 2018 08:37:49 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E6EA468819; Mon, 4 Jun 2018 12:37:48 +0000 (UTC) Received: from max.home.com (unknown [10.36.118.91]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0F07C111AF34; Mon, 4 Jun 2018 12:37:47 +0000 (UTC) From: Andreas Gruenbacher To: cluster-devel@redhat.com, Christoph Hellwig Cc: linux-fsdevel@vger.kernel.org, Andreas Gruenbacher Subject: [PATCH v7 12/12] iomap: Put struct iomap_ops into struct iomap Date: Mon, 4 Jun 2018 14:37:29 +0200 Message-Id: <20180604123729.23414-13-agruenba@redhat.com> In-Reply-To: <20180604123729.23414-1-agruenba@redhat.com> References: <20180604123729.23414-1-agruenba@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 04 Jun 2018 12:37:48 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 04 Jun 2018 12:37:48 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'agruenba@redhat.com' RCPT:'' Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We need access to the struct iomap_ops in iomap_write_end to call the (optional) page_write_end hook, so instead of passing the operators to iomap_write_end differently depending on the code path, add an ops field to struct iomap. Signed-off-by: Andreas Gruenbacher --- fs/dax.c | 8 ++++-- fs/gfs2/bmap.c | 4 ++- fs/gfs2/file.c | 4 ++- fs/iomap.c | 58 ++++++++++++++----------------------------- include/linux/iomap.h | 2 ++ 5 files changed, 32 insertions(+), 44 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index aaec72ded1b6..806bd53129aa 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -1140,7 +1140,9 @@ static int dax_iomap_pte_fault(struct vm_fault *vmf, pfn_t *pfnp, struct inode *inode = mapping->host; unsigned long vaddr = vmf->address; loff_t pos = (loff_t)vmf->pgoff << PAGE_SHIFT; - struct iomap iomap = { 0 }; + struct iomap iomap = { + .ops = ops + }; unsigned flags = IOMAP_FAULT; int error, major = 0; bool write = vmf->flags & FAULT_FLAG_WRITE; @@ -1359,7 +1361,9 @@ static int dax_iomap_pmd_fault(struct vm_fault *vmf, pfn_t *pfnp, unsigned int iomap_flags = (write ? IOMAP_WRITE : 0) | IOMAP_FAULT; struct inode *inode = mapping->host; int result = VM_FAULT_FALLBACK; - struct iomap iomap = { 0 }; + struct iomap iomap = { + .ops = ops + }; pgoff_t max_pgoff, pgoff; void *entry; loff_t pos; diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c index 703390824200..e4eeab7b6d52 100644 --- a/fs/gfs2/bmap.c +++ b/fs/gfs2/bmap.c @@ -1192,7 +1192,9 @@ int gfs2_block_map(struct inode *inode, sector_t lblock, loff_t pos = (loff_t)lblock << inode->i_blkbits; loff_t length = bh_map->b_size; struct metapath mp = { .mp_aheight = 1, }; - struct iomap iomap = { }; + struct iomap iomap = { + /* no need to initialize .ops here */ + }; int ret; clear_buffer_mapped(bh_map); diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c index 8de92708f18b..02ccb2d49900 100644 --- a/fs/gfs2/file.c +++ b/fs/gfs2/file.c @@ -883,7 +883,9 @@ static int fallocate_chunk(struct inode *inode, loff_t offset, loff_t len, struct gfs2_inode *ip = GFS2_I(inode); loff_t end = offset + len; struct buffer_head *dibh; - struct iomap iomap = { }; + struct iomap iomap = { + /* no need to initialize .ops here */ + }; int error; error = gfs2_meta_inode_buffer(ip, &dibh); diff --git a/fs/iomap.c b/fs/iomap.c index 34ba1be1d600..571214a6ffaa 100644 --- a/fs/iomap.c +++ b/fs/iomap.c @@ -45,7 +45,9 @@ loff_t iomap_apply(struct inode *inode, loff_t pos, loff_t length, unsigned flags, const struct iomap_ops *ops, void *data, iomap_actor_t actor) { - struct iomap iomap = { 0 }; + struct iomap iomap = { + .ops = ops + }; loff_t written = 0, ret; /* @@ -180,8 +182,7 @@ iomap_write_begin(struct inode *inode, loff_t pos, unsigned len, unsigned flags, static int iomap_write_end(struct inode *inode, loff_t pos, unsigned len, - unsigned copied, struct page *page, struct iomap *iomap, - const struct iomap_ops *ops) + unsigned copied, struct page *page, struct iomap *iomap) { int ret; @@ -191,8 +192,8 @@ iomap_write_end(struct inode *inode, loff_t pos, unsigned len, return copied; } - if (ops->page_write_end) - ops->page_write_end(inode, pos, copied, page); + if (iomap->ops->page_write_end) + iomap->ops->page_write_end(inode, pos, copied, page); ret = generic_write_end(NULL, inode->i_mapping, pos, len, copied, page, NULL); @@ -201,17 +202,11 @@ iomap_write_end(struct inode *inode, loff_t pos, unsigned len, return ret; } -struct iomap_write_args { - const struct iomap_ops *ops; - struct iov_iter *iter; -}; - static loff_t iomap_write_actor(struct inode *inode, loff_t pos, loff_t length, void *data, struct iomap *iomap) { - struct iomap_write_args *args = data; - struct iov_iter *i = args->iter; + struct iov_iter *i = data; long status = 0; ssize_t written = 0; unsigned int flags = AOP_FLAG_NOFS; @@ -257,7 +252,7 @@ iomap_write_actor(struct inode *inode, loff_t pos, loff_t length, void *data, flush_dcache_page(page); status = iomap_write_end(inode, pos, bytes, copied, page, - iomap, args->ops); + iomap); if (unlikely(status < 0)) break; copied = status; @@ -294,14 +289,10 @@ iomap_file_buffered_write(struct kiocb *iocb, struct iov_iter *iter, { struct inode *inode = iocb->ki_filp->f_mapping->host; loff_t pos = iocb->ki_pos, ret = 0, written = 0; - struct iomap_write_args args = { - .ops = ops, - .iter = iter, - }; while (iov_iter_count(iter)) { ret = iomap_apply(inode, pos, iov_iter_count(iter), - IOMAP_WRITE, ops, &args, iomap_write_actor); + IOMAP_WRITE, ops, iter, iomap_write_actor); if (ret <= 0) break; pos += ret; @@ -332,7 +323,6 @@ static loff_t iomap_dirty_actor(struct inode *inode, loff_t pos, loff_t length, void *data, struct iomap *iomap) { - const struct iomap_ops *ops = data; long status = 0; ssize_t written = 0; @@ -356,8 +346,7 @@ iomap_dirty_actor(struct inode *inode, loff_t pos, loff_t length, void *data, WARN_ON_ONCE(!PageUptodate(page)); - status = iomap_write_end(inode, pos, bytes, bytes, page, iomap, - ops); + status = iomap_write_end(inode, pos, bytes, bytes, page, iomap); if (unlikely(status <= 0)) { if (WARN_ON_ONCE(status == 0)) return -EIO; @@ -384,7 +373,7 @@ iomap_file_dirty(struct inode *inode, loff_t pos, loff_t len, while (len) { ret = iomap_apply(inode, pos, len, IOMAP_WRITE, ops, - (void *)ops, iomap_dirty_actor); + NULL, iomap_dirty_actor); if (ret <= 0) return ret; pos += ret; @@ -396,8 +385,7 @@ iomap_file_dirty(struct inode *inode, loff_t pos, loff_t len, EXPORT_SYMBOL_GPL(iomap_file_dirty); static int iomap_zero(struct inode *inode, loff_t pos, unsigned offset, - unsigned bytes, const struct iomap_ops *ops, - struct iomap *iomap) + unsigned bytes, struct iomap *iomap) { struct page *page; int status; @@ -410,8 +398,7 @@ static int iomap_zero(struct inode *inode, loff_t pos, unsigned offset, zero_user(page, offset, bytes); mark_page_accessed(page); - return iomap_write_end(inode, pos, bytes, bytes, page, iomap, - ops); + return iomap_write_end(inode, pos, bytes, bytes, page, iomap); } static int iomap_dax_zero(loff_t pos, unsigned offset, unsigned bytes, @@ -424,16 +411,11 @@ static int iomap_dax_zero(loff_t pos, unsigned offset, unsigned bytes, offset, bytes); } -struct iomap_zero_range_args { - const struct iomap_ops *ops; - bool *did_zero; -}; - static loff_t iomap_zero_range_actor(struct inode *inode, loff_t pos, loff_t count, void *data, struct iomap *iomap) { - struct iomap_zero_range_args *args = data; + bool *did_zero = data; loff_t written = 0; int status; @@ -451,15 +433,15 @@ iomap_zero_range_actor(struct inode *inode, loff_t pos, loff_t count, status = iomap_dax_zero(pos, offset, bytes, iomap); else status = iomap_zero(inode, pos, offset, bytes, - args->ops, iomap); + iomap); if (status < 0) return status; pos += bytes; count -= bytes; written += bytes; - if (args->did_zero) - *args->did_zero = true; + if (did_zero) + *did_zero = true; } while (count > 0); return written; @@ -469,15 +451,11 @@ int iomap_zero_range(struct inode *inode, loff_t pos, loff_t len, bool *did_zero, const struct iomap_ops *ops) { - struct iomap_zero_range_args args = { - .ops = ops, - .did_zero = did_zero, - }; loff_t ret; while (len > 0) { ret = iomap_apply(inode, pos, len, IOMAP_ZERO, - ops, &args, iomap_zero_range_actor); + ops, did_zero, iomap_zero_range_actor); if (ret <= 0) return ret; diff --git a/include/linux/iomap.h b/include/linux/iomap.h index 88ea8b970a95..98426cdfcc2e 100644 --- a/include/linux/iomap.h +++ b/include/linux/iomap.h @@ -6,6 +6,7 @@ struct fiemap_extent_info; struct inode; +struct iomap_ops; struct iov_iter; struct kiocb; struct page; @@ -43,6 +44,7 @@ struct vm_fault; #define IOMAP_NULL_ADDR -1ULL /* addr is not valid */ struct iomap { + const struct iomap_ops *ops; u64 addr; /* disk offset of mapping, bytes */ loff_t offset; /* file offset of mapping, bytes */ u64 length; /* length of mapping, bytes */