From patchwork Thu Sep 23 13:08:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengguang Xu X-Patchwork-Id: 12512927 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A498C433EF for ; Thu, 23 Sep 2021 13:24:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E5ACC61164 for ; Thu, 23 Sep 2021 13:24:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241374AbhIWNZt (ORCPT ); Thu, 23 Sep 2021 09:25:49 -0400 Received: from sender2-op-o12.zoho.com.cn ([163.53.93.243]:17277 "EHLO sender2-op-o12.zoho.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241304AbhIWNZn (ORCPT ); Thu, 23 Sep 2021 09:25:43 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1632402518; cv=none; d=zoho.com.cn; s=zohoarc; b=HVj590TZaxGsnVA2O5lZ0pLpPyNFSLFe2gysnBVdtFfGHI9kp3LJ/nmln+JcUCJDtc8s59pFHXaKSSzz6eHNeAwaFEkGu8yV0ai5b+MTeka4L6cuDvfIynsGfzaSxtx4cadVb6fTqAQBFWmob2hUk63lzt41XeEnQXMukiRvvEM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com.cn; s=zohoarc; t=1632402518; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=BUzq9Nw85NI4rCLzem4WvUl+lsGH5mOKA8UJLkEtvlg=; b=eEC7aRdbfXV3Uz6aRCVzJddTHBP11c5+/em2WRByqMH11zB/vt440HxZgRs3cXO8yyBujqh1niZXbDs6/N1uURKKVyYolp41AZJQefYOP6VPlL+0ZvykJejiUzHfz8u/U32sXgFyP/qWRQdJJnsgEc+lPpHfA4b5QNLWN40an4c= ARC-Authentication-Results: i=1; mx.zoho.com.cn; dkim=pass header.i=mykernel.net; spf=pass smtp.mailfrom=cgxu519@mykernel.net; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1632402518; s=zohomail; d=mykernel.net; i=cgxu519@mykernel.net; h=From:To:Cc:Message-ID:Subject:Date:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Content-Type; bh=BUzq9Nw85NI4rCLzem4WvUl+lsGH5mOKA8UJLkEtvlg=; b=X8i5R5ocA5qRsRqIrz9vHXfXgQh/gPbjN8JhON/5BC+psOnIt5wPJGatZTTMHUuM zRIWWshiKGewEaaFzZLJ7InZcQ9cq8Lz3FZzrXyl4iUO1+4uB9KEPL2rQneRVPggJ7Q zW98XxfuWivzXA7HFhB5YmSRLF38QmA1Jx9EC3mE= Received: from localhost.localdomain (81.71.33.115 [81.71.33.115]) by mx.zoho.com.cn with SMTPS id 1632402516780153.9678330778986; Thu, 23 Sep 2021 21:08:36 +0800 (CST) From: Chengguang Xu To: miklos@szeredi.hu, jack@suse.cz, amir73il@gmail.com Cc: linux-fsdevel@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-kernel@vger.kernel.org, Chengguang Xu Message-ID: <20210923130814.140814-2-cgxu519@mykernel.net> Subject: [RFC PATCH v5 01/10] ovl: setup overlayfs' private bdi Date: Thu, 23 Sep 2021 21:08:05 +0800 X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210923130814.140814-1-cgxu519@mykernel.net> References: <20210923130814.140814-1-cgxu519@mykernel.net> MIME-Version: 1.0 X-ZohoCNMailClient: External Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Setup overlayfs' private bdi so that we can collect overlayfs' own dirty inodes. Signed-off-by: Chengguang Xu --- fs/overlayfs/super.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c index 178daa5e82c9..51886ba6130a 100644 --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c @@ -1980,6 +1980,10 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent) if (!ofs) goto out; + err = super_setup_bdi(sb); + if (err) + goto out_err; + err = -ENOMEM; ofs->creator_cred = cred = prepare_creds(); if (!cred) From patchwork Thu Sep 23 13:08:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengguang Xu X-Patchwork-Id: 12512923 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BC6CFC4332F for ; Thu, 23 Sep 2021 13:24:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A5CB761241 for ; Thu, 23 Sep 2021 13:24:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241297AbhIWNZp (ORCPT ); Thu, 23 Sep 2021 09:25:45 -0400 Received: from sender2-op-o12.zoho.com.cn ([163.53.93.243]:17276 "EHLO sender2-op-o12.zoho.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241303AbhIWNZk (ORCPT ); Thu, 23 Sep 2021 09:25:40 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1632402519; cv=none; d=zoho.com.cn; s=zohoarc; b=hcflms2yGXPj40zXwh79bs9B+rZlwAiNHoAiDqeB4kA5p8f5VY28Pp2nyg/53vRHwWM7SfZsc87Nm5OEwvWTqeX7ibL/bYV3V6FsT0LgGNsmLQrPiq6yWye5y5MBU2s+iHPIDT7rypigGbqTkczAIS89q9YoNUiZjxpeE22oRQk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com.cn; s=zohoarc; t=1632402519; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=oiT5pr0K1SzNaD+tk1eXPsdcldxnjdYU+xq7vNjbxmY=; b=QYvnxb8rUmPDsebgB8N/Dp0/H2Ln1nV+HF4EVJ5sKBBnAn+rSaHxEGCjm3WoPzsESQ/cYEqiSYR4TO4z7uoCF6s1Mul3kg7AUS7+ezr1kDhk3yvxq1w8rJ1AeBh/rOC9eEa94k/NlhsOlsfhGUIbHmdmEWMsqiAaUIZAbxQE5Ms= ARC-Authentication-Results: i=1; mx.zoho.com.cn; dkim=pass header.i=mykernel.net; spf=pass smtp.mailfrom=cgxu519@mykernel.net; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1632402519; s=zohomail; d=mykernel.net; i=cgxu519@mykernel.net; h=From:To:Cc:Message-ID:Subject:Date:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Content-Type; bh=oiT5pr0K1SzNaD+tk1eXPsdcldxnjdYU+xq7vNjbxmY=; b=HHkVZft3KaPjFQxhfMb9MimXpR/ixs/USm+dwjyN9o90gVKkZQIi9yN3CHGKROpQ xWKvsGFH027LE3F55nu02bb+Xaj+mR+HWpTj/BUCoAYBtLAJ6ymn/EumJ3uk8u3lAxB MWj7zmmv4iPT9gdstaLn8nem+Mx9GjqgkfWFxa2w= Received: from localhost.localdomain (81.71.33.115 [81.71.33.115]) by mx.zoho.com.cn with SMTPS id 1632402517441659.6191501603354; Thu, 23 Sep 2021 21:08:37 +0800 (CST) From: Chengguang Xu To: miklos@szeredi.hu, jack@suse.cz, amir73il@gmail.com Cc: linux-fsdevel@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-kernel@vger.kernel.org, Chengguang Xu Message-ID: <20210923130814.140814-3-cgxu519@mykernel.net> Subject: [RFC PATCH v5 02/10] ovl: implement ->writepages operation Date: Thu, 23 Sep 2021 21:08:06 +0800 X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210923130814.140814-1-cgxu519@mykernel.net> References: <20210923130814.140814-1-cgxu519@mykernel.net> MIME-Version: 1.0 X-ZohoCNMailClient: External Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Implement overlayfs' ->writepages operation so that we can sync dirty data/metadata to upper filesystem. Signed-off-by: Chengguang Xu --- fs/overlayfs/inode.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c index 832b17589733..d854e59a3710 100644 --- a/fs/overlayfs/inode.c +++ b/fs/overlayfs/inode.c @@ -659,9 +659,22 @@ static const struct inode_operations ovl_special_inode_operations = { .update_time = ovl_update_time, }; +static int ovl_writepages(struct address_space *mapping, + struct writeback_control *wbc) +{ + struct inode *inode = mapping->host; + struct ovl_fs *ofs = inode->i_sb->s_fs_info; + struct inode *upper = ovl_inode_upper(inode); + + if (!ovl_should_sync(ofs)) + return 0; + return filemap_fdatawrite_wbc(upper->i_mapping, wbc); +} + static const struct address_space_operations ovl_aops = { /* For O_DIRECT dentry_open() checks f_mapping->a_ops->direct_IO */ .direct_IO = noop_direct_IO, + .writepages = ovl_writepages, }; /* From patchwork Thu Sep 23 13:08:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengguang Xu X-Patchwork-Id: 12512915 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 089CDC433FE for ; Thu, 23 Sep 2021 13:24:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E77D661164 for ; Thu, 23 Sep 2021 13:24:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241257AbhIWNZd (ORCPT ); Thu, 23 Sep 2021 09:25:33 -0400 Received: from sender2-op-o12.zoho.com.cn ([163.53.93.243]:17267 "EHLO sender2-op-o12.zoho.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241246AbhIWNZc (ORCPT ); Thu, 23 Sep 2021 09:25:32 -0400 X-Greylist: delayed 907 seconds by postgrey-1.27 at vger.kernel.org; Thu, 23 Sep 2021 09:25:32 EDT ARC-Seal: i=1; a=rsa-sha256; t=1632402519; cv=none; d=zoho.com.cn; s=zohoarc; b=USt4P00lNZZPNFMSumV/GycrF2tO2fKY8/ClpqdludyrNoFvkUovVomhVmsX6bWSky95dzqEl/+q51Pp7wQjN98Kee5UnyA1eq5IOpQvyi8bmQP1fb9rOh0nsBjJcsMibjXgWgOoH8lRprGv4y/0+XzBvjBz6lqHIdEhla0L6sI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com.cn; s=zohoarc; t=1632402519; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=YcxkPiJx6Ikxp0ynHw1Dz+L3wBzcP9EXpk2Zzl1PCl4=; b=eIgoR/BVZrZMhGaM2ewLhBaQsrwvTn7bThx3r/0azeLUM3tHIqwEDxYLWoYKQE2aKsP75NhsAG46RgGKnkSn0U4YeNzKUhnfRX6VamXWtV8lYLr8fWWEu59WHe4x2vu1620w7Nl4f4N5G55uoK/wJYzAzYbCn/S91QNvcFWb8P4= ARC-Authentication-Results: i=1; mx.zoho.com.cn; dkim=pass header.i=mykernel.net; spf=pass smtp.mailfrom=cgxu519@mykernel.net; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1632402519; s=zohomail; d=mykernel.net; i=cgxu519@mykernel.net; h=From:To:Cc:Message-ID:Subject:Date:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Content-Type; bh=YcxkPiJx6Ikxp0ynHw1Dz+L3wBzcP9EXpk2Zzl1PCl4=; b=OAeo3R/bEBj3E+lbzVDff2g72aNLcqL3jxZRwYe4TiR9NCtnj55RAKPCJgb/cEQ1 eShD7V7ouJPRFkSmStmbkZSFTq8dsE914Zk9hHVNsVRYIE4ijYEnQGc5qF7bCmsnwLG LsO4yHkMEskGjCW2LJjm/Nt1kBEWO77fJmP0lPzU= Received: from localhost.localdomain (81.71.33.115 [81.71.33.115]) by mx.zoho.com.cn with SMTPS id 1632402518088813.5030221103862; Thu, 23 Sep 2021 21:08:38 +0800 (CST) From: Chengguang Xu To: miklos@szeredi.hu, jack@suse.cz, amir73il@gmail.com Cc: linux-fsdevel@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-kernel@vger.kernel.org, Chengguang Xu Message-ID: <20210923130814.140814-4-cgxu519@mykernel.net> Subject: [RFC PATCH v5 03/10] ovl: implement overlayfs' ->evict_inode operation Date: Thu, 23 Sep 2021 21:08:07 +0800 X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210923130814.140814-1-cgxu519@mykernel.net> References: <20210923130814.140814-1-cgxu519@mykernel.net> MIME-Version: 1.0 X-ZohoCNMailClient: External Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Implement overlayfs' ->evict_inode operation, so that we can clear dirty flags of overlayfs inode. Signed-off-by: Chengguang Xu --- fs/overlayfs/super.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c index 51886ba6130a..2ab77adf7256 100644 --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c @@ -406,11 +406,18 @@ static int ovl_remount(struct super_block *sb, int *flags, char *data) return ret; } +static void ovl_evict_inode(struct inode *inode) +{ + inode->i_state &= ~I_DIRTY_ALL; + clear_inode(inode); +} + static const struct super_operations ovl_super_operations = { .alloc_inode = ovl_alloc_inode, .free_inode = ovl_free_inode, .destroy_inode = ovl_destroy_inode, .drop_inode = generic_delete_inode, + .evict_inode = ovl_evict_inode, .put_super = ovl_put_super, .sync_fs = ovl_sync_fs, .statfs = ovl_statfs, From patchwork Thu Sep 23 13:08:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengguang Xu X-Patchwork-Id: 12512925 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 584A7C433EF for ; Thu, 23 Sep 2021 13:24:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4682F61241 for ; Thu, 23 Sep 2021 13:24:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241366AbhIWNZo (ORCPT ); Thu, 23 Sep 2021 09:25:44 -0400 Received: from sender2-op-o12.zoho.com.cn ([163.53.93.243]:17225 "EHLO sender2-op-o12.zoho.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241297AbhIWNZj (ORCPT ); Thu, 23 Sep 2021 09:25:39 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1632402519; cv=none; d=zoho.com.cn; s=zohoarc; b=VWzAN0jCnhLrGy3jC0Mm6+b57VyrtubCVelrCQzI/wQYYxLtp2F5NU7qy7lI0lwEB/vG4P6sFbZjETH8pxEpavBORH+jhjb4BM9YIFkU5wIpGAsRxM+IVSy10nbRz9bH4Jj87dBvps6K/QsNZxR1GwsUL49aQcbXDMVfB39ecq8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com.cn; s=zohoarc; t=1632402519; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=w/gDJAniEk07y4xvkybDn7HV+NGUOUDW0TeqbBoxuiE=; b=V2yeYqrC4dXlA9juc5hRIxPCQsUJxAgGsTLEAC6bglrrN+I2Czgc9E5Fu5RL5k2m4kBKjabUONufQ5difqwiL2ttlJzmrjWak8WrqXc50I7dh13rNtN9r37h9+xE1gEIzV80oTQbJZh6EgvnQ3Y1XeYf+YO3auxuWHRMjk67RJ4= ARC-Authentication-Results: i=1; mx.zoho.com.cn; dkim=pass header.i=mykernel.net; spf=pass smtp.mailfrom=cgxu519@mykernel.net; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1632402519; s=zohomail; d=mykernel.net; i=cgxu519@mykernel.net; h=From:To:Cc:Message-ID:Subject:Date:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Content-Type; bh=w/gDJAniEk07y4xvkybDn7HV+NGUOUDW0TeqbBoxuiE=; b=QZMMaqGR5LywkBwNIGIgNW2QNHMHcxmweQfOG5wgRqe1XwZpwsJ9F3RbNy+oNB1R ZsbBg6hQFf795E4yGcVKudkL4z182w6dZOIuJb9zBPSPvjp0rybADzD7HkiC3sm6JeN Ql7TZ5CqCbpiSoLzbDYh+kcc4+hMxPea3JJVc4cA= Received: from localhost.localdomain (81.71.33.115 [81.71.33.115]) by mx.zoho.com.cn with SMTPS id 163240251872378.04107038429561; Thu, 23 Sep 2021 21:08:38 +0800 (CST) From: Chengguang Xu To: miklos@szeredi.hu, jack@suse.cz, amir73il@gmail.com Cc: linux-fsdevel@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-kernel@vger.kernel.org, Chengguang Xu Message-ID: <20210923130814.140814-5-cgxu519@mykernel.net> Subject: [RFC PATCH v5 04/10] ovl: mark overlayfs' inode dirty on modification Date: Thu, 23 Sep 2021 21:08:08 +0800 X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210923130814.140814-1-cgxu519@mykernel.net> References: <20210923130814.140814-1-cgxu519@mykernel.net> MIME-Version: 1.0 X-ZohoCNMailClient: External Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Mark overlayfs' inode dirty on modification so that we can recognize and collect target inodes for syncfs. Signed-off-by: Chengguang Xu --- fs/overlayfs/inode.c | 1 + fs/overlayfs/overlayfs.h | 4 ++++ fs/overlayfs/util.c | 21 +++++++++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c index d854e59a3710..4a03aceaeedc 100644 --- a/fs/overlayfs/inode.c +++ b/fs/overlayfs/inode.c @@ -478,6 +478,7 @@ int ovl_update_time(struct inode *inode, struct timespec64 *ts, int flags) if (upperpath.dentry) { touch_atime(&upperpath); inode->i_atime = d_inode(upperpath.dentry)->i_atime; + ovl_mark_inode_dirty(inode); } } return 0; diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h index 3894f3347955..5a016baa06dd 100644 --- a/fs/overlayfs/overlayfs.h +++ b/fs/overlayfs/overlayfs.h @@ -276,6 +276,7 @@ static inline bool ovl_allow_offline_changes(struct ovl_fs *ofs) /* util.c */ +void ovl_mark_inode_dirty(struct inode *inode); int ovl_want_write(struct dentry *dentry); void ovl_drop_write(struct dentry *dentry); struct dentry *ovl_workdir(struct dentry *dentry); @@ -529,6 +530,9 @@ static inline void ovl_copyattr(struct inode *from, struct inode *to) to->i_mtime = from->i_mtime; to->i_ctime = from->i_ctime; i_size_write(to, i_size_read(from)); + + if (ovl_inode_upper(to) && from->i_state & I_DIRTY_ALL) + ovl_mark_inode_dirty(to); } /* vfs inode flags copied from real to ovl inode */ diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c index f48284a2a896..5441eae2e345 100644 --- a/fs/overlayfs/util.c +++ b/fs/overlayfs/util.c @@ -25,7 +25,14 @@ int ovl_want_write(struct dentry *dentry) void ovl_drop_write(struct dentry *dentry) { struct ovl_fs *ofs = dentry->d_sb->s_fs_info; + struct dentry *upper; + mnt_drop_write(ovl_upper_mnt(ofs)); + if (d_inode(dentry)) { + upper = ovl_dentry_upper(dentry); + if (upper && d_inode(upper) && d_inode(upper)->i_state & I_DIRTY_ALL) + ovl_mark_inode_dirty(d_inode(dentry)); + } } struct dentry *ovl_workdir(struct dentry *dentry) @@ -1060,3 +1067,17 @@ int ovl_sync_status(struct ovl_fs *ofs) return errseq_check(&mnt->mnt_sb->s_wb_err, ofs->errseq); } + +/* + * We intentionally add I_DIRTY_SYNC flag regardless dirty flag + * of upper inode so that we have chance to invoke ->write_inode + * to re-dirty overlayfs' inode during writeback process. + */ +void ovl_mark_inode_dirty(struct inode *inode) +{ + struct inode *upper = ovl_inode_upper(inode); + unsigned long iflag = I_DIRTY_SYNC; + + iflag |= upper->i_state & I_DIRTY_ALL; + __mark_inode_dirty(inode, iflag); +} From patchwork Thu Sep 23 13:08:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengguang Xu X-Patchwork-Id: 12512919 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D16A5C433FE for ; Thu, 23 Sep 2021 13:24:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BCA8D61164 for ; Thu, 23 Sep 2021 13:24:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241266AbhIWNZg (ORCPT ); Thu, 23 Sep 2021 09:25:36 -0400 Received: from sender2-op-o12.zoho.com.cn ([163.53.93.243]:17274 "EHLO sender2-op-o12.zoho.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241252AbhIWNZf (ORCPT ); Thu, 23 Sep 2021 09:25:35 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1632402521; cv=none; d=zoho.com.cn; s=zohoarc; b=L1v9aJ10+Cg+LJ2ZbCif6XWkIptsXu5lucWEt9Drkp7JdZm2GH2N3moGZSN4HNHglwtPFxKR0ZC924CsoeSGbDxEERGuzuzacIw8/K9Ud97EzMc8EaNHOskbFrWQ6hir/zsNhFaVeXx6a7ijPyA4Z95OWYIOZtMuKNzoI3Tn2rI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com.cn; s=zohoarc; t=1632402521; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=q/ZniZvEQNR9QMjyUGnqhtU4K3+28Lsctqx6fnG5LiE=; b=PMxgor99S9g4BKqAeG9F1Y6buycIqPC3U2jAPE2XStUZ6CtxFnQ7j1FDqxOcBrR06A0h//j9KFoAuctOxcnz1RYuwHaVJN7W8YWryu34Yqvxa6rOqhZtolUhU0EZvnhXFbTv2gD6gSuVVyXTIp1FEO19WPU1W/xfyz50sejlSl4= ARC-Authentication-Results: i=1; mx.zoho.com.cn; dkim=pass header.i=mykernel.net; spf=pass smtp.mailfrom=cgxu519@mykernel.net; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1632402521; s=zohomail; d=mykernel.net; i=cgxu519@mykernel.net; h=From:To:Cc:Message-ID:Subject:Date:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Content-Type; bh=q/ZniZvEQNR9QMjyUGnqhtU4K3+28Lsctqx6fnG5LiE=; b=NjilX8d3wa3bTRR0ftONhPLUW3ClZ4ZT4AjNY4/G9Oy5qIE+SArx5y0AzSdNTT6x ATqxD5vlusfbfeb4Z4pfMUgsyDMTC9KcCSm80guqKs8g/o2cESFeqSAJfEdH60RjOmr /pPXXKKbPBWvsE5apRv+4jbUzUg0mJFAQrfE8rO0= Received: from localhost.localdomain (81.71.33.115 [81.71.33.115]) by mx.zoho.com.cn with SMTPS id 163240251969041.52353362646056; Thu, 23 Sep 2021 21:08:39 +0800 (CST) From: Chengguang Xu To: miklos@szeredi.hu, jack@suse.cz, amir73il@gmail.com Cc: linux-fsdevel@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-kernel@vger.kernel.org, Chengguang Xu Message-ID: <20210923130814.140814-6-cgxu519@mykernel.net> Subject: [RFC PATCH v5 05/10] ovl: mark overlayfs' inode dirty on shared mmap Date: Thu, 23 Sep 2021 21:08:09 +0800 X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210923130814.140814-1-cgxu519@mykernel.net> References: <20210923130814.140814-1-cgxu519@mykernel.net> MIME-Version: 1.0 X-ZohoCNMailClient: External Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Overlayfs cannot be notified when mmapped area gets dirty, so we need to proactively mark inode dirty in ->mmap operation. Signed-off-by: Chengguang Xu --- fs/overlayfs/file.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c index d081faa55e83..f9dc5249c183 100644 --- a/fs/overlayfs/file.c +++ b/fs/overlayfs/file.c @@ -482,6 +482,12 @@ static int ovl_mmap(struct file *file, struct vm_area_struct *vma) revert_creds(old_cred); ovl_file_accessed(file); + if (!ret) { + if (ovl_inode_upper(file_inode(file)) && + vma->vm_flags & VM_SHARED) + ovl_mark_inode_dirty(file_inode(file)); + } + return ret; } From patchwork Thu Sep 23 13:08:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengguang Xu X-Patchwork-Id: 12512917 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73166C433EF for ; Thu, 23 Sep 2021 13:24:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 57F9F61216 for ; Thu, 23 Sep 2021 13:24:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241260AbhIWNZd (ORCPT ); Thu, 23 Sep 2021 09:25:33 -0400 Received: from sender2-op-o12.zoho.com.cn ([163.53.93.243]:17222 "EHLO sender2-op-o12.zoho.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241252AbhIWNZd (ORCPT ); Thu, 23 Sep 2021 09:25:33 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1632402521; cv=none; d=zoho.com.cn; s=zohoarc; b=LtT4AHvjKfjxM7qfFR64EaDXeRwB+/cGDrDpPbwsQpxOy9zU9S/34b9tcckTWtPRC99AFBxe4FcaVqr1Uj/UN3hKhKg1h8vL6QxnRLBoNpV0P2g63VPQspXv2qjNvZW21/WRc0M3YzJIgEErJ2ElGnTzX/Mpa3IsiMjtrSGEC7Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com.cn; s=zohoarc; t=1632402521; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=XsUohhYVPknp/XYAaV7893wjUc9cOlm8DY/Vt5qPhmQ=; b=FZdUAfgRvEjoF5w4JyAviHQETBr1ci/Y8SnblybEi/0LWK5d3aFFN9xTY586aGoFtbmw6OyHq3a5zpS5nMzls52AY6lw9HEHZTbZHiIZw+pT8q69FGam1LPJ+XkUkb4CMOMKsi/5IQZftPqGOkd6WDwfCsVisLm9Wt8I6VOeRAU= ARC-Authentication-Results: i=1; mx.zoho.com.cn; dkim=pass header.i=mykernel.net; spf=pass smtp.mailfrom=cgxu519@mykernel.net; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1632402521; s=zohomail; d=mykernel.net; i=cgxu519@mykernel.net; h=From:To:Cc:Message-ID:Subject:Date:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Content-Type; bh=XsUohhYVPknp/XYAaV7893wjUc9cOlm8DY/Vt5qPhmQ=; b=J1CY3iOba+GXjdL6LsJYfjWo0tJEIuJUg9Pz9U+pHROXjA9a2Rsu2AQ+m9g4SrqV WizDKlrtcKcL5qhJovXGJI74s5Nh41Fl0UU8EKQS5yeuiqnrgwgmhTAZv8FN+HdRh/P UDcIVxHoK3jjQtUiQfOr7zd9ChTCWPJCdjjSz7NE= Received: from localhost.localdomain (81.71.33.115 [81.71.33.115]) by mx.zoho.com.cn with SMTPS id 1632402520332669.3406501896101; Thu, 23 Sep 2021 21:08:40 +0800 (CST) From: Chengguang Xu To: miklos@szeredi.hu, jack@suse.cz, amir73il@gmail.com Cc: linux-fsdevel@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-kernel@vger.kernel.org, Chengguang Xu Message-ID: <20210923130814.140814-7-cgxu519@mykernel.net> Subject: [RFC PATCH v5 06/10] ovl: implement overlayfs' ->write_inode operation Date: Thu, 23 Sep 2021 21:08:10 +0800 X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210923130814.140814-1-cgxu519@mykernel.net> References: <20210923130814.140814-1-cgxu519@mykernel.net> MIME-Version: 1.0 X-ZohoCNMailClient: External Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Implement overlayfs' ->write_inode to sync dirty data and redirty overlayfs' inode if necessary. Signed-off-by: Chengguang Xu --- fs/overlayfs/super.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c index 2ab77adf7256..cddae3ca2fa5 100644 --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c @@ -412,12 +412,42 @@ static void ovl_evict_inode(struct inode *inode) clear_inode(inode); } +static int ovl_write_inode(struct inode *inode, + struct writeback_control *wbc) +{ + struct ovl_fs *ofs = inode->i_sb->s_fs_info; + struct inode *upper = ovl_inode_upper(inode); + unsigned long iflag = 0; + int ret = 0; + + if (!upper) + return 0; + + if (!ovl_should_sync(ofs)) + return 0; + + if (upper->i_sb->s_op->write_inode) + ret = upper->i_sb->s_op->write_inode(inode, wbc); + + if (mapping_writably_mapped(upper->i_mapping) || + mapping_tagged(upper->i_mapping, PAGECACHE_TAG_WRITEBACK)) + iflag |= I_DIRTY_PAGES; + + iflag |= upper->i_state & I_DIRTY_ALL; + + if (iflag) + ovl_mark_inode_dirty(inode); + + return ret; +} + static const struct super_operations ovl_super_operations = { .alloc_inode = ovl_alloc_inode, .free_inode = ovl_free_inode, .destroy_inode = ovl_destroy_inode, .drop_inode = generic_delete_inode, .evict_inode = ovl_evict_inode, + .write_inode = ovl_write_inode, .put_super = ovl_put_super, .sync_fs = ovl_sync_fs, .statfs = ovl_statfs, From patchwork Thu Sep 23 13:08:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengguang Xu X-Patchwork-Id: 12512933 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 197C8C433EF for ; Thu, 23 Sep 2021 13:24:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 031906121F for ; Thu, 23 Sep 2021 13:24:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241316AbhIWNZv (ORCPT ); Thu, 23 Sep 2021 09:25:51 -0400 Received: from sender2-op-o12.zoho.com.cn ([163.53.93.243]:17227 "EHLO sender2-op-o12.zoho.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241340AbhIWNZo (ORCPT ); Thu, 23 Sep 2021 09:25:44 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1632402523; cv=none; d=zoho.com.cn; s=zohoarc; b=lblKkx98PmU32v/JOaN89LnX9lFru/3VCKt8x9LWCCbSK4aV8OPgF2WZ3CspPGqlsj76ko/pgKsMA6B4BSKt1llvthSSp+GF9qGr3IdoarAytpmE4jAR5naUTR8QdMbIiOt3E5VBpS/kCXn5628uF/YzZQ93GegiE4O/I6rwYHI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com.cn; s=zohoarc; t=1632402523; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=aPd3vzQLUXRuk4ebbbXy1hr64pu+TM/TzIndQasNLMs=; b=R8HPodvCEP1R0iYr4bUBUPRRSJItfmUq5o3QxyTDEhQNqx+y7MoqgWDRYveCLFGbwU+kDnrXoOB6i72X75l+LYYsuQDYGvn2qSKZ4dINE9PfHFE6aVHoy0YSAeU33zipSV5jvMGX0P5b6eDYFbZSE3DXcf7NHVSIOuUQYii4nhA= ARC-Authentication-Results: i=1; mx.zoho.com.cn; dkim=pass header.i=mykernel.net; spf=pass smtp.mailfrom=cgxu519@mykernel.net; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1632402523; s=zohomail; d=mykernel.net; i=cgxu519@mykernel.net; h=From:To:Cc:Message-ID:Subject:Date:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Content-Type; bh=aPd3vzQLUXRuk4ebbbXy1hr64pu+TM/TzIndQasNLMs=; b=PR5fCIU7NcfBHTykhNCmCkejwWHT5IVa8Ihxaybsa4vMopw2NGEYGfg96dtmcAbz d/EDrRWml/ola8aJTAiBCS6wARIjusRxjPq6sPZc2uQkYwFokQyV0GC2Zcf1YGxkq+2 UfTFF2XRvGuU5uiDq0POLzhXrc8H04gA75BfsyUU= Received: from localhost.localdomain (81.71.33.115 [81.71.33.115]) by mx.zoho.com.cn with SMTPS id 1632402520970573.0190553351058; Thu, 23 Sep 2021 21:08:40 +0800 (CST) From: Chengguang Xu To: miklos@szeredi.hu, jack@suse.cz, amir73il@gmail.com Cc: linux-fsdevel@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-kernel@vger.kernel.org, Chengguang Xu Message-ID: <20210923130814.140814-8-cgxu519@mykernel.net> Subject: [RFC PATCH v5 07/10] ovl: cache dirty overlayfs' inode Date: Thu, 23 Sep 2021 21:08:11 +0800 X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210923130814.140814-1-cgxu519@mykernel.net> References: <20210923130814.140814-1-cgxu519@mykernel.net> MIME-Version: 1.0 X-ZohoCNMailClient: External Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Now drop overlayfs' inode will sync dirty data, so we change to only drop clean inode. The purpose of doing this is to keep compatible behavior with before because without this change dropping overlayfs inode will not trigger syncing of underlying dirty inode. Signed-off-by: Chengguang Xu --- fs/overlayfs/super.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c index cddae3ca2fa5..bf4000eb9be8 100644 --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c @@ -441,11 +441,25 @@ static int ovl_write_inode(struct inode *inode, return ret; } +/* + * In iput_final(), clean inode will drop directly and dirty inode will + * keep in the cache until write back to sync dirty data then add to lru + * list to wait reclaim. + */ +static int ovl_drop_inode(struct inode *inode) +{ + struct inode *upper = ovl_inode_upper(inode); + + if (!upper || !(inode->i_state & I_DIRTY_ALL)) + return 1; + return generic_drop_inode(inode); +} + static const struct super_operations ovl_super_operations = { .alloc_inode = ovl_alloc_inode, .free_inode = ovl_free_inode, .destroy_inode = ovl_destroy_inode, - .drop_inode = generic_delete_inode, + .drop_inode = ovl_drop_inode, .evict_inode = ovl_evict_inode, .write_inode = ovl_write_inode, .put_super = ovl_put_super, From patchwork Thu Sep 23 13:08:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengguang Xu X-Patchwork-Id: 12512931 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16C10C4321E for ; Thu, 23 Sep 2021 13:24:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 027526115A for ; Thu, 23 Sep 2021 13:24:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241394AbhIWNZv (ORCPT ); Thu, 23 Sep 2021 09:25:51 -0400 Received: from sender2-op-o12.zoho.com.cn ([163.53.93.243]:17272 "EHLO sender2-op-o12.zoho.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241357AbhIWNZo (ORCPT ); Thu, 23 Sep 2021 09:25:44 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1632402523; cv=none; d=zoho.com.cn; s=zohoarc; b=qH3ngKsxfDBir5NbpElwAqfEGQ6iHB041TE9vOS2w3gnqi1XONO2MMlLMRdbKRgbRfWsfFNtxgxtGDqp1YrzCkkx/VWeEV07mKNhKk70pFWgq+2gXh/Lrzkm5sshuksLpUeEDxuZGJMk6BcTA8DMN6od7bPBmOKnq2+6KZXIhxA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com.cn; s=zohoarc; t=1632402523; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=SJerK8hn3kKJX7a0C29xFImquFtm+fSY+XjyQ7ULrjs=; b=VcF6xUTRV2Z0fmfyEphbwYgIYz52AXlEBzlBP2RZnHlA80o+1qaQGwFnBRFfhzhWhNTJlgqzFxmyxOQdzghh2n6q/r4ey5kfzb5ojsuCQcY1DOi7klQrQ9RS5ythmJOSV0FoyZ0T7A4hgRzWHsbOSDUwFXFZtlaXyzkv1gaVwjs= ARC-Authentication-Results: i=1; mx.zoho.com.cn; dkim=pass header.i=mykernel.net; spf=pass smtp.mailfrom=cgxu519@mykernel.net; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1632402523; s=zohomail; d=mykernel.net; i=cgxu519@mykernel.net; h=From:To:Cc:Message-ID:Subject:Date:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Content-Type; bh=SJerK8hn3kKJX7a0C29xFImquFtm+fSY+XjyQ7ULrjs=; b=MwQ5U9dtYqlgPS1baurzUMI0iLzWurkQBJwILxnogau7MtDCArgzgsLxI7yYtGZ8 +3z1v/Hgd3Y/Amfd7+2O70S07JhSlnNvafHGF8sIx1+5XCE+x51+1xPs0BhDPhCxFyL v3FFzjVsYlDCHSXvNKqKc6uElBrpB8MG+PVj29QU= Received: from localhost.localdomain (81.71.33.115 [81.71.33.115]) by mx.zoho.com.cn with SMTPS id 1632402521611230.03974667116563; Thu, 23 Sep 2021 21:08:41 +0800 (CST) From: Chengguang Xu To: miklos@szeredi.hu, jack@suse.cz, amir73il@gmail.com Cc: linux-fsdevel@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-kernel@vger.kernel.org, Chengguang Xu Message-ID: <20210923130814.140814-9-cgxu519@mykernel.net> Subject: [RFC PATCH v5 08/10] fs: export wait_sb_inodes() Date: Thu, 23 Sep 2021 21:08:12 +0800 X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210923130814.140814-1-cgxu519@mykernel.net> References: <20210923130814.140814-1-cgxu519@mykernel.net> MIME-Version: 1.0 X-ZohoCNMailClient: External Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org In order to wait syncing upper inodes we need to call wait_sb_inodes() in overlayfs' ->sync_fs. Signed-off-by: Chengguang Xu --- fs/fs-writeback.c | 3 ++- include/linux/writeback.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index 81ec192ce067..0438c911241e 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -2505,7 +2505,7 @@ EXPORT_SYMBOL(__mark_inode_dirty); * completed by the time we have gained the lock and waited for all IO that is * in progress regardless of the order callers are granted the lock. */ -static void wait_sb_inodes(struct super_block *sb) +void wait_sb_inodes(struct super_block *sb) { LIST_HEAD(sync_list); @@ -2589,6 +2589,7 @@ static void wait_sb_inodes(struct super_block *sb) rcu_read_unlock(); mutex_unlock(&sb->s_sync_lock); } +EXPORT_SYMBOL(wait_sb_inodes); static void __writeback_inodes_sb_nr(struct super_block *sb, unsigned long nr, enum wb_reason reason, bool skip_if_busy) diff --git a/include/linux/writeback.h b/include/linux/writeback.h index d1f65adf6a26..d7aacd0434cf 100644 --- a/include/linux/writeback.h +++ b/include/linux/writeback.h @@ -198,6 +198,7 @@ void wakeup_flusher_threads_bdi(struct backing_dev_info *bdi, enum wb_reason reason); void inode_wait_for_writeback(struct inode *inode); void inode_io_list_del(struct inode *inode); +void wait_sb_inodes(struct super_block *sb); /* writeback.h requires fs.h; it, too, is not included from here. */ static inline void wait_on_inode(struct inode *inode) From patchwork Thu Sep 23 13:08:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengguang Xu X-Patchwork-Id: 12512929 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68D6CC4332F for ; Thu, 23 Sep 2021 13:24:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4F58F6124E for ; Thu, 23 Sep 2021 13:24:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241375AbhIWNZu (ORCPT ); Thu, 23 Sep 2021 09:25:50 -0400 Received: from sender2-op-o12.zoho.com.cn ([163.53.93.243]:17279 "EHLO sender2-op-o12.zoho.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241320AbhIWNZo (ORCPT ); Thu, 23 Sep 2021 09:25:44 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1632402523; cv=none; d=zoho.com.cn; s=zohoarc; b=DRn4vGd96dGD8cKVzzWUjNJKFPgjfCYBK0l1Frw9AqTe7+7FinjJ8MrKMKiydWBaeUP3MpTuKud+dPmMcHEzShsMq7FpAfoaCP7Udy2l2iyVCsWKAe3s4vPu4LCYrDMXkWrPfyVyL4eZBRICJUhXFHoGbSsEpguwMzTvmNaHVuI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com.cn; s=zohoarc; t=1632402523; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=THw0YvMlxjX1i71lpc4CHFA+3w1dXqVfXs694rHAFw0=; b=MIAWSmelOd6p6i+AbbwfXjUZH1yPjBxaL/6JELlFuwbzO6KAylw3IljmmdRK7oIrRglfaEv5KUU41xDDHf9+oRBjq/IUbk3LSNdJY1WF6pSucd8apH1Cwniy3l62wAxjcwee2Oir1jRfsgoCe+cP5d6C9M3c/XnhpSXSmWLt8+I= ARC-Authentication-Results: i=1; mx.zoho.com.cn; dkim=pass header.i=mykernel.net; spf=pass smtp.mailfrom=cgxu519@mykernel.net; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1632402523; s=zohomail; d=mykernel.net; i=cgxu519@mykernel.net; h=From:To:Cc:Message-ID:Subject:Date:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Content-Type; bh=THw0YvMlxjX1i71lpc4CHFA+3w1dXqVfXs694rHAFw0=; b=XWkTWpTIMjshz23RcCmTbnXDGGJxrJC4OAeiH5+AHTLm2qjREUfJsWJ3AGcWkBQn FRJyHnNlgBqolSkPsFGEoIh/7icBqaemuIu4uRm+Bub0i5FCFqlfnJfwa/0eYE0frot Q8E9qR0ldZNehaayd1aQSNTWqqn+HRu9BEeWvFuA= Received: from localhost.localdomain (81.71.33.115 [81.71.33.115]) by mx.zoho.com.cn with SMTPS id 1632402522263998.249844109196; Thu, 23 Sep 2021 21:08:42 +0800 (CST) From: Chengguang Xu To: miklos@szeredi.hu, jack@suse.cz, amir73il@gmail.com Cc: linux-fsdevel@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-kernel@vger.kernel.org, Chengguang Xu Message-ID: <20210923130814.140814-10-cgxu519@mykernel.net> Subject: [RFC PATCH v5 09/10] fs: introduce new helper sync_fs_and_blockdev() Date: Thu, 23 Sep 2021 21:08:13 +0800 X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210923130814.140814-1-cgxu519@mykernel.net> References: <20210923130814.140814-1-cgxu519@mykernel.net> MIME-Version: 1.0 X-ZohoCNMailClient: External Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Overlayfs needs to call upper layer's ->sync_fs and __sync_blockdev() to sync metadata during syncfs(2). Currently, __sync_blockdev() does not export to module so introduce new helper sync_fs_and_blockdev() to wrap those operations. Signed-off-by: Chengguang Xu --- fs/sync.c | 14 ++++++++++---- include/linux/fs.h | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/fs/sync.c b/fs/sync.c index 1373a610dc78..36c755e6568a 100644 --- a/fs/sync.c +++ b/fs/sync.c @@ -21,6 +21,15 @@ #define VALID_FLAGS (SYNC_FILE_RANGE_WAIT_BEFORE|SYNC_FILE_RANGE_WRITE| \ SYNC_FILE_RANGE_WAIT_AFTER) + +int sync_fs_and_blockdev(struct super_block *sb, int wait) +{ + if (sb->s_op->sync_fs) + sb->s_op->sync_fs(sb, wait); + return __sync_blockdev(sb->s_bdev, wait); +} +EXPORT_SYMBOL(sync_fs_and_blockdev); + /* * Do the filesystem syncing work. For simple filesystems * writeback_inodes_sb(sb) just dirties buffers with inodes so we have to @@ -34,10 +43,7 @@ static int __sync_filesystem(struct super_block *sb, int wait) sync_inodes_sb(sb); else writeback_inodes_sb(sb, WB_REASON_SYNC); - - if (sb->s_op->sync_fs) - sb->s_op->sync_fs(sb, wait); - return __sync_blockdev(sb->s_bdev, wait); + return sync_fs_and_blockdev(sb, wait); } /* diff --git a/include/linux/fs.h b/include/linux/fs.h index e7a633353fd2..e5ebf126281c 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2777,6 +2777,7 @@ static inline bool sb_is_blkdev_sb(struct super_block *sb) void emergency_thaw_all(void); extern int sync_filesystem(struct super_block *); +extern int sync_fs_and_blockdev(struct super_block *sb, int wait); extern const struct file_operations def_blk_fops; extern const struct file_operations def_chr_fops; From patchwork Thu Sep 23 13:08:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengguang Xu X-Patchwork-Id: 12512935 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1263FC433FE for ; Thu, 23 Sep 2021 13:24:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E1B7F61164 for ; Thu, 23 Sep 2021 13:24:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241404AbhIWNZw (ORCPT ); Thu, 23 Sep 2021 09:25:52 -0400 Received: from sender2-op-o12.zoho.com.cn ([163.53.93.243]:17226 "EHLO sender2-op-o12.zoho.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241338AbhIWNZo (ORCPT ); Thu, 23 Sep 2021 09:25:44 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1632402523; cv=none; d=zoho.com.cn; s=zohoarc; b=f2h811w2svJQ4VmTGeEPdH8ik/s9xSbE+Y2NhLHm4skAElJ4FYA4xm5dEZGFMAi1TGnQJewLXfnkxfoHMNJGI3jNPYuLd4vA0vip+HcqcY+zwSgNfsMa1ORU7ggfUWGi3pDN72aPTjEogAu7+kShz6Zh98ewPabDJhBOXBqL4xc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com.cn; s=zohoarc; t=1632402523; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=oG9u6AuZGZnG2KRRqhJabX8iiojey6H8VgFRc9r8zZI=; b=VkcPKRSjcPvbDFAsHX4SaX3tRDA349fSUPEhiU7yZblCVudkVNhNPAh8EjSEhhquivpvlX/Y2+ep4mRONhMq5NdadZqjKW0IrEbQ9WE1ncQejOM9iLp0VN/EcTaYok3dknMfKuY1V952v6eneT6XYeQERXol7ZFqmkrrvyDNUhQ= ARC-Authentication-Results: i=1; mx.zoho.com.cn; dkim=pass header.i=mykernel.net; spf=pass smtp.mailfrom=cgxu519@mykernel.net; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1632402523; s=zohomail; d=mykernel.net; i=cgxu519@mykernel.net; h=From:To:Cc:Message-ID:Subject:Date:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Content-Type; bh=oG9u6AuZGZnG2KRRqhJabX8iiojey6H8VgFRc9r8zZI=; b=XJQM+4b0CJp8iL2K71cfogKzVBIQgvz8ktaI3l4hTq+Fyn3vaxMs2Vo46b6Ap2Di 78la47q64qXuBX4hgyzGubgPeER3oS7CfGs3fPVN3BhSN+j/VOtQeUBJaqdqXFZLaJS Tft2OQcHcIoZ55Cvjh/9z2MNFtN00A1UW+hZ7vXA= Received: from localhost.localdomain (81.71.33.115 [81.71.33.115]) by mx.zoho.com.cn with SMTPS id 1632402522914922.0766031758626; Thu, 23 Sep 2021 21:08:42 +0800 (CST) From: Chengguang Xu To: miklos@szeredi.hu, jack@suse.cz, amir73il@gmail.com Cc: linux-fsdevel@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-kernel@vger.kernel.org, Chengguang Xu Message-ID: <20210923130814.140814-11-cgxu519@mykernel.net> Subject: [RFC PATCH v5 10/10] ovl: implement containerized syncfs for overlayfs Date: Thu, 23 Sep 2021 21:08:14 +0800 X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210923130814.140814-1-cgxu519@mykernel.net> References: <20210923130814.140814-1-cgxu519@mykernel.net> MIME-Version: 1.0 X-ZohoCNMailClient: External Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Now overlayfs can sync proper dirty inodes during syncfs, so remove unnecessary sync_filesystem() on upper file system. Signed-off-by: Chengguang Xu --- fs/overlayfs/super.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c index bf4000eb9be8..ef998ada6cb9 100644 --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c @@ -15,6 +15,7 @@ #include #include #include +#include #include "overlayfs.h" MODULE_AUTHOR("Miklos Szeredi "); @@ -281,18 +282,15 @@ static int ovl_sync_fs(struct super_block *sb, int wait) /* * Not called for sync(2) call or an emergency sync (SB_I_SKIP_SYNC). * All the super blocks will be iterated, including upper_sb. - * - * If this is a syncfs(2) call, then we do need to call - * sync_filesystem() on upper_sb, but enough if we do it when being - * called with wait == 1. */ - if (!wait) - return 0; upper_sb = ovl_upper_mnt(ofs)->mnt_sb; down_read(&upper_sb->s_umount); - ret = sync_filesystem(upper_sb); + if (wait) + wait_sb_inodes(upper_sb); + + ret = sync_fs_and_blockdev(upper_sb, wait); up_read(&upper_sb->s_umount); return ret;