Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp571138pxb; Thu, 23 Sep 2021 06:25:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyd9w0M8OglFzsvkLwH+6kcSpAexCV30svztUBbp/VHX62ilaLAY5jrOY0TCr/Lvz/Xafwe X-Received: by 2002:a17:906:2708:: with SMTP id z8mr2745040ejc.309.1632403557650; Thu, 23 Sep 2021 06:25:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1632403557; cv=pass; d=google.com; s=arc-20160816; b=FDWSnG5gy0zXStCsBHAF8fCc2tqbM8efRUQjIScHUa4JAgvnSVuxDV2Ircx/AzfthL kPinjrplzm3YRApwmBJ/794be1QfLlqhDMJ6Swui746EOO42G5SRuupKDR2Z3ofRMPCT nw1WqNuuwarlJovyoft3p1/wwDZeCvJcH9O3PYxEIvOwHm5y0FU6cgCxth4ebLWrW4lb jsnKCgGnwuZ2gDxnNCLWPAI8Ig0Ob+y3HDwSbPC4QKx7T8MwgYsecj6QWM2DiFjwkQKi /gi2myIraEp8blzwp5UJM3FirIWnGnjkDmjNixJjaqefnhD1oh5KIMrFn2KJZt36vrcM 2j+w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:date:subject:message-id:cc:to:from :dkim-signature; bh=XsUohhYVPknp/XYAaV7893wjUc9cOlm8DY/Vt5qPhmQ=; b=oM2W23uCkTWiIZKccGzrEv2hbhF/vQATW8XQVhDsNL3pjk+gEeUCN7WT2FjHFYbNpG Th4m8gawSwZkujrgPJSzMTXdUG6RMyReeSA5Qjo7HvGjEPGxcEWgMSdA+zSRyagMrTGH Xv5etKMABqxTEkGHmFZfXQ/y5TMS4W7NUGSpbo5VoBNIfmXemS2naZ/X5snf/21aXOxv ioExtwkCWc0UyAWApfOQqiYg589CodUMRSg8kVYC7iA6IIdjSMMSRruXiJOMIbPh1jSr zKmuwncL01Wtr26cXwIh7X6lIagZWFo213IhGq9iK74Hhoz04rxRITqaKjSRbNrFYink wWnw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@mykernel.net header.s=zohomail header.b=J1CY3iOb; arc=pass (i=1 spf=pass spfdomain=mykernel.net dkim=pass dkdomain=mykernel.net dmarc=pass fromdomain=mykernel.net>); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m3si5605611ejn.256.2021.09.23.06.25.31; Thu, 23 Sep 2021 06:25:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@mykernel.net header.s=zohomail header.b=J1CY3iOb; arc=pass (i=1 spf=pass spfdomain=mykernel.net dkim=pass dkdomain=mykernel.net dmarc=pass fromdomain=mykernel.net>); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241302AbhIWNZi (ORCPT + 99 others); Thu, 23 Sep 2021 09:25:38 -0400 Received: from sender2-op-o12.zoho.com.cn ([163.53.93.243]:17224 "EHLO sender2-op-o12.zoho.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241276AbhIWNZg (ORCPT ); Thu, 23 Sep 2021 09:25:36 -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 Content-Transfer-Encoding: quoted-printable X-ZohoCNMailClient: External Content-Type: text/plain; charset=utf8 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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) =09clear_inode(inode); } =20 +static int ovl_write_inode(struct inode *inode, +=09=09=09 struct writeback_control *wbc) +{ +=09struct ovl_fs *ofs =3D inode->i_sb->s_fs_info; +=09struct inode *upper =3D ovl_inode_upper(inode); +=09unsigned long iflag =3D 0; +=09int ret =3D 0; + +=09if (!upper) +=09=09return 0; + +=09if (!ovl_should_sync(ofs)) +=09=09return 0; + +=09if (upper->i_sb->s_op->write_inode) +=09=09ret =3D upper->i_sb->s_op->write_inode(inode, wbc); + +=09if (mapping_writably_mapped(upper->i_mapping) || +=09 mapping_tagged(upper->i_mapping, PAGECACHE_TAG_WRITEBACK)) +=09=09iflag |=3D I_DIRTY_PAGES; + +=09iflag |=3D upper->i_state & I_DIRTY_ALL; + +=09if (iflag) +=09=09ovl_mark_inode_dirty(inode); + +=09return ret; +} + static const struct super_operations ovl_super_operations =3D { =09.alloc_inode=09=3D ovl_alloc_inode, =09.free_inode=09=3D ovl_free_inode, =09.destroy_inode=09=3D ovl_destroy_inode, =09.drop_inode=09=3D generic_delete_inode, =09.evict_inode=09=3D ovl_evict_inode, +=09.write_inode=09=3D ovl_write_inode, =09.put_super=09=3D ovl_put_super, =09.sync_fs=09=3D ovl_sync_fs, =09.statfs=09=09=3D ovl_statfs, --=20 2.27.0