From patchwork Mon Jun 4 12:37:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Gruenbacher X-Patchwork-Id: 10446545 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 5DBBE603D7 for ; Mon, 4 Jun 2018 12:37:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4BC2C28C52 for ; Mon, 4 Jun 2018 12:37:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4076828E2E; Mon, 4 Jun 2018 12:37:47 +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 D9BC228C52 for ; Mon, 4 Jun 2018 12:37:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752981AbeFDMho (ORCPT ); Mon, 4 Jun 2018 08:37:44 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:46424 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751769AbeFDMhl (ORCPT ); Mon, 4 Jun 2018 08:37:41 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C27D64022414; Mon, 4 Jun 2018 12:37:40 +0000 (UTC) Received: from max.home.com (unknown [10.36.118.91]) by smtp.corp.redhat.com (Postfix) with ESMTP id E2F1510FFE6A; Mon, 4 Jun 2018 12:37:39 +0000 (UTC) From: Andreas Gruenbacher To: cluster-devel@redhat.com, Christoph Hellwig Cc: linux-fsdevel@vger.kernel.org, Andreas Gruenbacher Subject: [PATCH v7 05/12] fs: allow to always dirty inode in __generic_write_end Date: Mon, 4 Jun 2018 14:37:22 +0200 Message-Id: <20180604123729.23414-6-agruenba@redhat.com> In-Reply-To: <20180604123729.23414-1-agruenba@redhat.com> References: <20180604123729.23414-1-agruenba@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Mon, 04 Jun 2018 12:37:40 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Mon, 04 Jun 2018 12:37:40 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'agruenba@redhat.com' RCPT:'' 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 In __generic_write_end, we usually dirty the inode only when the file size changes. Allow to dirty the inode even when the file size stays the same; this will be used when writing to inline data stored in the inode. Signed-off-by: Andreas Gruenbacher --- fs/buffer.c | 9 ++++----- fs/internal.h | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index cb5bbf22b1ce..a59d281ca51e 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -2078,10 +2078,9 @@ int block_write_begin(struct address_space *mapping, loff_t pos, unsigned len, EXPORT_SYMBOL(block_write_begin); int __generic_write_end(struct inode *inode, loff_t pos, unsigned copied, - struct page *page) + struct page *page, bool dirty_inode) { loff_t old_size = inode->i_size; - bool i_size_changed = false; /* * No need to use i_size_read() here, the i_size cannot change under us @@ -2092,7 +2091,7 @@ int __generic_write_end(struct inode *inode, loff_t pos, unsigned copied, */ if (pos + copied > inode->i_size) { i_size_write(inode, pos + copied); - i_size_changed = true; + dirty_inode = true; } unlock_page(page); @@ -2106,7 +2105,7 @@ int __generic_write_end(struct inode *inode, loff_t pos, unsigned copied, * ordering of page lock and transaction start for journaling * filesystems. */ - if (i_size_changed) + if (dirty_inode) mark_inode_dirty(inode); return copied; } @@ -2152,7 +2151,7 @@ int generic_write_end(struct file *file, struct address_space *mapping, struct page *page, void *fsdata) { copied = block_write_end(file, mapping, pos, len, copied, page, fsdata); - return __generic_write_end(mapping->host, pos, copied, page); + return __generic_write_end(mapping->host, pos, copied, page, false); } EXPORT_SYMBOL(generic_write_end); diff --git a/fs/internal.h b/fs/internal.h index 4a18bdbd2214..8572af552285 100644 --- a/fs/internal.h +++ b/fs/internal.h @@ -44,7 +44,7 @@ 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); int __generic_write_end(struct inode *inode, loff_t pos, unsigned copied, - struct page *page); + struct page *page, bool dirty_inode); /* * char_dev.c