From patchwork Tue Feb 28 14:57:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 9595875 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 F1F3260574 for ; Tue, 28 Feb 2017 14:58:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E690F28497 for ; Tue, 28 Feb 2017 14:58:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DB62828534; Tue, 28 Feb 2017 14:58:12 +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=unavailable 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 8070B284EF for ; Tue, 28 Feb 2017 14:58:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752349AbdB1O6J (ORCPT ); Tue, 28 Feb 2017 09:58:09 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:37183 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752000AbdB1O6E (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=xibYZ+YZx2pxDT9WqHrX+P+Mjo/thBjzJsAF4fVZknE=; b=gWyGrczuyJoPSt+HuevftmCIG qlBqx6vYJn/1Rps2F20QoPAEfE2P7mEX8Bh+3q65/yEFkmJ+1uSvqnTUXWRaCEYEcFOY7dvwQ8ZCx t4GShUseqJqDxgBIvYVgle/3d4D0baGdxifsHPFLf2M9C05upEqJyg7wkrGPjOwYbPpV4pTp2cz6Z 0q8eYJ+TjP5JL1VtYJdc/rEFG4AoUzBhxxD9kakomdEX5FFi2Uv844dOnBgqU/8uC3j6yCIMto0Cq Q9LGNt5lfdZGRnzqDGnbtdgKmrj8hU/2Psd9ypqayTL7taGVAtKhD9mIj3exI5gdBHjGHnhao8e1x pPx2TbrAA==; Received: from [8.25.222.2] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1cijDe-0006Rj-6R; 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 04/12] fs: add a BH_Atomic flag Date: Tue, 28 Feb 2017 06:57:29 -0800 Message-Id: <20170228145737.19016-5-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-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This allows us propagate the O_ATOMIC flag through the writeback code. Signed-off-by: Christoph Hellwig --- fs/buffer.c | 13 +++++++++---- fs/internal.h | 2 +- fs/iomap.c | 4 ++-- include/linux/buffer_head.h | 2 ++ 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index 0e87401cf335..85b0dce31b34 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -1937,7 +1937,7 @@ EXPORT_SYMBOL(page_zero_new_buffers); static void iomap_to_bh(struct inode *inode, sector_t block, struct buffer_head *bh, - struct iomap *iomap) + struct iomap *iomap, unsigned flags) { loff_t offset = block << inode->i_blkbits; @@ -1987,10 +1987,15 @@ iomap_to_bh(struct inode *inode, sector_t block, struct buffer_head *bh, set_buffer_mapped(bh); break; } + + if (flags & IOMAP_ATOMIC) + set_buffer_atomic(bh); + else + clear_buffer_atomic(bh); } int __block_write_begin_int(struct page *page, loff_t pos, unsigned len, - get_block_t *get_block, struct iomap *iomap) + get_block_t *get_block, struct iomap *iomap, unsigned flags) { unsigned from = pos & (PAGE_SIZE - 1); unsigned to = from + len; @@ -2031,7 +2036,7 @@ int __block_write_begin_int(struct page *page, loff_t pos, unsigned len, if (err) break; } else { - iomap_to_bh(inode, block, bh, iomap); + iomap_to_bh(inode, block, bh, iomap, flags); } if (buffer_new(bh)) { @@ -2077,7 +2082,7 @@ int __block_write_begin_int(struct page *page, loff_t pos, unsigned len, int __block_write_begin(struct page *page, loff_t pos, unsigned len, get_block_t *get_block) { - return __block_write_begin_int(page, pos, len, get_block, NULL); + return __block_write_begin_int(page, pos, len, get_block, NULL, 0); } EXPORT_SYMBOL(__block_write_begin); diff --git a/fs/internal.h b/fs/internal.h index 1934fdb2bb27..5f4cbdedafdb 100644 --- a/fs/internal.h +++ b/fs/internal.h @@ -42,7 +42,7 @@ static inline int __sync_blockdev(struct block_device *bdev, int wait) */ extern void guard_bio_eod(int rw, struct bio *bio); extern int __block_write_begin_int(struct page *page, loff_t pos, unsigned len, - get_block_t *get_block, struct iomap *iomap); + get_block_t *get_block, struct iomap *iomap, unsigned flags); /* * char_dev.c diff --git a/fs/iomap.c b/fs/iomap.c index 096cbf573932..3c3c09104dcd 100644 --- a/fs/iomap.c +++ b/fs/iomap.c @@ -119,7 +119,7 @@ iomap_write_begin(struct inode *inode, loff_t pos, unsigned len, if (!page) return -ENOMEM; - status = __block_write_begin_int(page, pos, len, NULL, iomap); + status = __block_write_begin_int(page, pos, len, NULL, iomap, flags); if (unlikely(status)) { unlock_page(page); put_page(page); @@ -441,7 +441,7 @@ iomap_page_mkwrite_actor(struct inode *inode, loff_t pos, loff_t length, struct page *page = data; int ret; - ret = __block_write_begin_int(page, pos, length, NULL, iomap); + ret = __block_write_begin_int(page, pos, length, NULL, iomap, flags); if (ret) return ret; diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h index d67ab83823ad..baff49fdfbe8 100644 --- a/include/linux/buffer_head.h +++ b/include/linux/buffer_head.h @@ -37,6 +37,7 @@ enum bh_state_bits { BH_Meta, /* Buffer contains metadata */ BH_Prio, /* Buffer should be submitted with REQ_PRIO */ BH_Defer_Completion, /* Defer AIO completion to workqueue */ + BH_Atomic, /* part of an O_ATOMIC write */ BH_PrivateStart,/* not a state bit, but the first bit available * for private allocation by other entities @@ -130,6 +131,7 @@ BUFFER_FNS(Unwritten, unwritten) BUFFER_FNS(Meta, meta) BUFFER_FNS(Prio, prio) BUFFER_FNS(Defer_Completion, defer_completion) +BUFFER_FNS(Atomic, atomic); #define bh_offset(bh) ((unsigned long)(bh)->b_data & ~PAGE_MASK)