From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 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> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: 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 -- 2.17.0