From patchwork Fri Oct 5 13:03:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Maiolino X-Patchwork-Id: 10627981 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C6F7E1515 for ; Fri, 5 Oct 2018 13:03:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D5E4285FF for ; Fri, 5 Oct 2018 13:03:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0F9EF2863C; Fri, 5 Oct 2018 13:03:23 +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 A73BD285FF for ; Fri, 5 Oct 2018 13:03:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728181AbeJEUB7 (ORCPT ); Fri, 5 Oct 2018 16:01:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45210 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727701AbeJEUB7 (ORCPT ); Fri, 5 Oct 2018 16:01:59 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AA28D804ED; Fri, 5 Oct 2018 13:03:21 +0000 (UTC) Received: from odin.usersys.redhat.com (unknown [10.40.205.83]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9AA721001F41; Fri, 5 Oct 2018 13:03:20 +0000 (UTC) From: Carlos Maiolino To: linux-fsdevel@vger.kernel.org Cc: okozina@redhat.com, hch@lst.de Subject: [RFC PATCH] iomap: Enable alignment check for iomap DIO in holes Date: Fri, 5 Oct 2018 15:03:16 +0200 Message-Id: <20181005130316.4869-1-cmaiolino@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 05 Oct 2018 13:03:21 +0000 (UTC) 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 Commit 09230435dffdb13de507e5e40b524b0069fc5c7b refactor iomap_dio_actor into two different helpers for bio based IO and hole IO, although, the latter doesn't check for IO alignment anymore. Move the DIO alignment check up into the caller, so all iomap DIO has alignment checked. Fixes: 09230435d iomap: refactor iomap_dio_actor Reported-by: Ondrej Kozina Signed-off-by: Carlos Maiolino --- Christoph, I tagged this patch as RFC, because I couldn't really identify if you intentionally dropped the alignment check for holes and inline actors, if you didn't drop the alignment check intentionally, please consider it as a normal patch. fs/iomap.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/iomap.c b/fs/iomap.c index 90c2febc93ac..347e31512268 100644 --- a/fs/iomap.c +++ b/fs/iomap.c @@ -1574,9 +1574,7 @@ static loff_t iomap_dio_bio_actor(struct inode *inode, loff_t pos, loff_t length, struct iomap_dio *dio, struct iomap *iomap) { - unsigned int blkbits = blksize_bits(bdev_logical_block_size(iomap->bdev)); unsigned int fs_block_size = i_blocksize(inode), pad; - unsigned int align = iov_iter_alignment(dio->submit.iter); struct iov_iter iter; struct bio *bio; bool need_zeroout = false; @@ -1584,9 +1582,6 @@ iomap_dio_bio_actor(struct inode *inode, loff_t pos, loff_t length, int nr_pages, ret; size_t copied = 0; - if ((pos | length | align) & ((1 << blkbits) - 1)) - return -EINVAL; - if (iomap->type == IOMAP_UNWRITTEN) { dio->flags |= IOMAP_DIO_UNWRITTEN; need_zeroout = true; @@ -1726,6 +1721,11 @@ iomap_dio_actor(struct inode *inode, loff_t pos, loff_t length, void *data, struct iomap *iomap) { struct iomap_dio *dio = data; + unsigned int blkbits = blksize_bits(bdev_logical_block_size(iomap->bdev)); + unsigned int align = iov_iter_alignment(dio->submit.iter); + + if ((pos | length | align) & ((1 << blkbits) - 1)) + return -EINVAL; switch (iomap->type) { case IOMAP_HOLE: