From patchwork Tue Nov 1 21:06:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 9408109 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 6086560585 for ; Tue, 1 Nov 2016 21:22:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4B46E29A50 for ; Tue, 1 Nov 2016 21:22:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3FB3129A9E; Tue, 1 Nov 2016 21:22:15 +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=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C3D3629A50 for ; Tue, 1 Nov 2016 21:22:14 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id D7B5D81CC1; Tue, 1 Nov 2016 14:22:12 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id BD77281D11 for ; Tue, 1 Nov 2016 14:22:11 -0700 (PDT) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 0EE87AC52; Tue, 1 Nov 2016 21:22:11 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 42B541E0F40; Tue, 1 Nov 2016 22:06:27 +0100 (CET) From: Jan Kara To: linux-ext4@vger.kernel.org Subject: [PATCH 02/11] ext4: Allow unaligned unlocked DAX IO Date: Tue, 1 Nov 2016 22:06:12 +0100 Message-Id: <1478034381-19037-3-git-send-email-jack@suse.cz> X-Mailer: git-send-email 2.6.6 In-Reply-To: <1478034381-19037-1-git-send-email-jack@suse.cz> References: <1478034381-19037-1-git-send-email-jack@suse.cz> X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fsdevel@vger.kernel.org, Dave Chinner , Jan Kara , Ted Tso , linux-nvdimm@lists.01.org MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP Currently we don't allow unaligned writes without inode_lock. This is because zeroing of partial blocks could cause data corruption for racing unaligned writes to the same block. However DAX handles zeroing during block allocation and thus zeroing of partial blocks cannot race. Allow DAX unaligned IO to run without inode_lock. Signed-off-by: Jan Kara --- fs/ext4/file.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/ext4/file.c b/fs/ext4/file.c index a6a7becb9465..55f8b922b76d 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -161,7 +161,8 @@ ext4_file_write_iter(struct kiocb *iocb, struct iov_iter *from) iocb->private = &overwrite; /* Check whether we do a DIO overwrite or not */ - if (o_direct && ext4_should_dioread_nolock(inode) && !unaligned_aio && + if (((o_direct && !unaligned_aio) || IS_DAX(inode)) && + ext4_should_dioread_nolock(inode) && ext4_overwrite_io(inode, iocb->ki_pos, iov_iter_count(from))) overwrite = 1;