From patchwork Tue Feb 28 14:57:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 9595917 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 1E11560574 for ; Tue, 28 Feb 2017 14:58:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 133F728497 for ; Tue, 28 Feb 2017 14:58:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 08331284FF; Tue, 28 Feb 2017 14:58:35 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 A9FEA284EF for ; Tue, 28 Feb 2017 14:58:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752107AbdB1O6c (ORCPT ); Tue, 28 Feb 2017 09:58:32 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:33162 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752010AbdB1O6E (ORCPT ); Tue, 28 Feb 2017 09:58:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:To:From:Sender:Reply-To:Cc:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=A9EJ4vpSgq4w8tUK/9ul6FyvcdM9X4eojrUYsijY5zo=; b=LcN7XvN0R15SsyCmx8V/+DtyP cd+J7w4go4Zu/m+OSGwwPu1yuWYHLwodvmo39aSYHnBLgs0DR0HxFUbOIjLNiCgdYY0ywAClyw9pP 3TAmW1JU/BfMeWwTxC0r70nJY3mbJFOFjSKecsYnojx+qhBx6QXrBDYele6DCjgBL0aFeEClUF5kb Ytl7Y2fzlG+tALrOZb1cDIRQKUBej9+ZnMU0a3cjSIoLMRBBuIcs8IJlA/fT4APZRL9T8CbtYkeVC ksOjQSLwI+v/gtPFNQLiTUeOEbLSUgxt/BmsCI8+0QAdsxZSrXfDFc4U5E/htGN92GjqDmtGYW17z bRXfe8C7g==; Received: from [8.25.222.2] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1cijDe-0006Rf-2R; Tue, 28 Feb 2017 14:57:38 +0000 From: Christoph Hellwig To: linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-block@vger.kernel.org Subject: [PATCH 03/12] iomap: add a IOMAP_ATOMIC flag Date: Tue, 28 Feb 2017 06:57:28 -0800 Message-Id: <20170228145737.19016-4-hch@lst.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170228145737.19016-1-hch@lst.de> References: <20170228145737.19016-1-hch@lst.de> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP To pass through O_ATOMIC to the iomap_begin methods. Signed-off-by: Christoph Hellwig --- fs/iomap.c | 13 +++++++++++-- include/linux/iomap.h | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/fs/iomap.c b/fs/iomap.c index 16a9d2b89cb6..096cbf573932 100644 --- a/fs/iomap.c +++ b/fs/iomap.c @@ -237,6 +237,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; + unsigned flags = IOMAP_WRITE; + + if (iocb->ki_filp->f_flags & O_ATOMIC) + flags |= IOMAP_ATOMIC; while (iov_iter_count(iter)) { ret = iomap_apply(inode, pos, iov_iter_count(iter), @@ -452,8 +456,12 @@ int iomap_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf, struct inode *inode = file_inode(vma->vm_file); unsigned long length; loff_t offset, size; + unsigned flags = IOMAP_WRITE | IOMAP_FAULT; ssize_t ret; + if (vma->vm_file->f_flags & O_ATOMIC) + flags |= IOMAP_ATOMIC; + lock_page(page); size = i_size_read(inode); if ((page->mapping != inode->i_mapping) || @@ -471,8 +479,7 @@ int iomap_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf, offset = page_offset(page); while (length > 0) { - ret = iomap_apply(inode, offset, length, - IOMAP_WRITE | IOMAP_FAULT, ops, page, + ret = iomap_apply(inode, offset, length, flags, ops, page, iomap_page_mkwrite_actor); if (unlikely(ret <= 0)) goto out_unlock; @@ -883,6 +890,8 @@ iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter, } else { dio->flags |= IOMAP_DIO_WRITE; flags |= IOMAP_WRITE; + if (iocb->ki_filp->f_flags & O_ATOMIC) + flags |= IOMAP_ATOMIC; } if (mapping->nrpages) { diff --git a/include/linux/iomap.h b/include/linux/iomap.h index 891459caa278..a670ff18ccd6 100644 --- a/include/linux/iomap.h +++ b/include/linux/iomap.h @@ -51,6 +51,7 @@ struct iomap { #define IOMAP_REPORT (1 << 2) /* report extent status, e.g. FIEMAP */ #define IOMAP_FAULT (1 << 3) /* mapping for page fault */ #define IOMAP_DIRECT (1 << 4) /* direct I/O */ +#define IOMAP_ATOMIC (1 << 5) /* atomic write vs power fail */ struct iomap_ops { /*