Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp248086ybn; Thu, 3 Oct 2019 04:37:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqwGQApEB3KzvhD4odoEZRQioWVspF6DjToQKOF/iGVt7qt8bqMhpv7o82/UGpvYB6K/NUyh X-Received: by 2002:aa7:c897:: with SMTP id p23mr8969746eds.199.1570102636728; Thu, 03 Oct 2019 04:37:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570102636; cv=none; d=google.com; s=arc-20160816; b=uDMlEmjUtbW4zHdNeE0KHZlnsLVL+k0KflKLpvXI5TuKCrxqAmsz6ZRqY33z/XviE3 LkQKg/fgNNZuqn7gggojq7o1QVY4E4Xn47kpNNyGntM2tRiOqyPyzTGYAK5SYTPGncEQ ugzsILFqatg8+83Nxopf4wT1iBba654vLHhz1scSUJ2rRPwSzWIIRSD2lUTiO9Ybsgen 6wk2XZZkUxn6t3cMKv4BxfYcrXwMCXikgDf3paiexV80U4E/jV/lRpz/DhbFDgEmJknq wE9pLFIqfX41YXqsPnj10nQMuR1/0sypG7AqnwP12GfNJXrd4OQCMuGZ9U5j1dqYUHVT llGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=YfMvwfleMXIJiuUDe83jEb4CHUSrNdjdWPZ/hSIRHEo=; b=gGx53Yoj5c+/8XnqEN99Z6xR023SxdTtUDgpmwz8AzNmLaDpGKS5hOFHWD7nvmxwQB tNf4xmiALZU2AStajalBj3Ym1/bjfA8WP3cLQMnVRhpC/X5Ju5mHQf7dMFBk0ps6zLem ifZKuxRt9BdUluM+LYR67l2iXfok/xSEalDlmm9D6OEmsi6IPIZqVrNH6iLmZiv7KPzH CARwUkMOLFukX6VHerawPousg+mtzW5GPURtN0N/xaZXHfc5CNmtKQ3L6NRxhxTuo9ne 3EGiKCKW/DvynSL38ExPhjK1zGZT7oJeieuZSB9lVgKxlJhSkS422aG6gxN7JUgyBFE3 0l9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mbobrowski-org.20150623.gappssmtp.com header.s=20150623 header.b="c5Jj/0iV"; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gh2si1088445ejb.330.2019.10.03.04.36.50; Thu, 03 Oct 2019 04:37:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@mbobrowski-org.20150623.gappssmtp.com header.s=20150623 header.b="c5Jj/0iV"; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730018AbfJCLe7 (ORCPT + 99 others); Thu, 3 Oct 2019 07:34:59 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:35942 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729741AbfJCLe6 (ORCPT ); Thu, 3 Oct 2019 07:34:58 -0400 Received: by mail-pl1-f194.google.com with SMTP id j11so1392327plk.3 for ; Thu, 03 Oct 2019 04:34:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mbobrowski-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=YfMvwfleMXIJiuUDe83jEb4CHUSrNdjdWPZ/hSIRHEo=; b=c5Jj/0iVAZj+4fvzM89CtFvkKxlu2mWVNqmgzV8BdUYmGtAkvZq0ticEwaFRCSnW9G Ih+Vvzy/nK/nMcnSDurf3ueBQv0/JUGF3jO4lkNy09qHZGyGVBbJ1OjOCL0znFFwzbyC ojWK9cqAuQBFc2751iQHItiH/YIl4B/uISgcOz+WqmlBdxZurlQA7ybtwgReqvreLg/f Hj44ZEbip9vezRxIqs6MkCXKlg8jJZgSBDZxTLgbUKkgnLv468O3plBkvVlj5y6YIyQE tiLX7DSXqvW6D/GY3x+dQPHmCAZwZoIY85obEbXCrcKUQ1GagJjE83gW1LaKfhQgxolI civg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=YfMvwfleMXIJiuUDe83jEb4CHUSrNdjdWPZ/hSIRHEo=; b=K9bz+5WJu+pi3lsfoqYvzFxO/NDz/vXhyk2GfNwGv6lBjYeY9pvscjord2Toi9y/bJ IXjlw6TGnfcdKQ4tUxGO2KhbvKKUxiLpnrcRVFUSRiRoAXh+4h89LKtJfqnxrSOKhr/M PLFep+c0sm8P/CutCgptMyY68Uv4RZrOQHkqfaqIulVD73xw5GDhzwHbpB0rNKAjNKcU TIBKE3KgF29TFB1rDpB3u0PUkkbqtP9lzWMg6ij0HexhZ7in1dXPeqRlMQkApuXQGuw8 H0CwH+r2O7NR1BxnkfENGHbLpvi4M0jaCk0DHAdavuFQkvSv6z1ScQJAtF6wcUL7/ZUi e5LQ== X-Gm-Message-State: APjAAAWO1JOjXkIkfKjBqChUoOOzgEGdpw/I63u0xIK1foSLETGS+6lU HDDjsqOWmbsOPy3y7vKOj2jc X-Received: by 2002:a17:902:d896:: with SMTP id b22mr8897779plz.140.1570102497827; Thu, 03 Oct 2019 04:34:57 -0700 (PDT) Received: from poseidon.bobrowski.net ([114.78.226.167]) by smtp.gmail.com with ESMTPSA id c16sm2292377pja.2.2019.10.03.04.34.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Oct 2019 04:34:57 -0700 (PDT) Date: Thu, 3 Oct 2019 21:34:51 +1000 From: Matthew Bobrowski To: tytso@mit.edu, jack@suse.cz, adilger.kernel@dilger.ca Cc: linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, hch@infradead.org, david@fromorbit.com, darrick.wong@oracle.com Subject: [PATCH v4 7/8] ext4: reorder map.m_flags checks in ext4_set_iomap() Message-ID: <3551610e53aa1984210a4de04ad6e1a89f5bf0a3.1570100361.git.mbobrowski@mbobrowski.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org For iomap direct IO write code path changes, we need to accommodate for the case where the block mapping flags passed to ext4_map_blocks() will result in m_flags having both EXT4_MAP_MAPPED and EXT4_MAP_UNWRITTEN bits set. In order for the allocated unwritten extents to be converted properly in the end_io handler, iomap->type must be set to IOMAP_UNWRITTEN, so we need to reshuffle the conditional statement in order to achieve this. This change is a no-op for DAX code path as the block mapping flag passed to ext4_map_blocks() when IS_DAX(inode) never results in EXT4_MAP_MAPPED and EXT4_MAP_UNWRITTEN being set at once. Signed-off-by: Matthew Bobrowski --- fs/ext4/inode.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index e133dda55063..63ad23ae05b8 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -3420,10 +3420,20 @@ static int ext4_set_iomap(struct inode *inode, struct iomap *iomap, u16 type, iomap->type = type; iomap->addr = IOMAP_NULL_ADDR; } else { - if (map->m_flags & EXT4_MAP_MAPPED) { - iomap->type = IOMAP_MAPPED; - } else if (map->m_flags & EXT4_MAP_UNWRITTEN) { + /* + * Flags passed to ext4_map_blocks() for direct I/O + * writes can result in map->m_flags having both + * EXT4_MAP_MAPPED and EXT4_MAP_UNWRITTEN bits set. In + * order for allocated extents to be converted to + * written extents in the ->end_io handler correctly, + * we need to ensure that the iomap->type is set + * approprately. Thus, we need to check whether + * EXT4_MAP_UNWRITTEN is set first. + */ + if (map->m_flags & EXT4_MAP_UNWRITTEN) { iomap->type = IOMAP_UNWRITTEN; + } else if (map->m_flags & EXT4_MAP_MAPPED) { + iomap->type = IOMAP_MAPPED; } else { WARN_ON_ONCE(1); return -EIO; -- 2.20.1