Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp1196665pxb; Thu, 7 Oct 2021 02:53:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxIBqhV8EDpo79nvZ5S2rfEHn32dlCWDwAhIQMFO536kepxQGnCyLpxpbJi/ml0rDEqB11P X-Received: by 2002:a17:907:1b06:: with SMTP id mp6mr4263522ejc.188.1633600427645; Thu, 07 Oct 2021 02:53:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633600427; cv=none; d=google.com; s=arc-20160816; b=ypgKfInihwzeL6vlohH4Dref40mbWQqcc8KC55ZA4jWW1SUr5fzLp/7BlLdvrPRYHR jGjliKHhg6/dOhWBWerEQ7FR9Y68ftGt3+SstCsMWQsH2Hc7Oqp43sZWPxmW7Z7eJXQm VE/JMSD0vZ4Y2XxSE8ozPoyDefzd50mGei5ExgGS2gauCkcrD3O8rMW9Cv+McCQLNN4E lc7aM2zmVy6l4FcU1XCJ0iQp1ANk4VTVYHwavUQiW37E6fHsMSuk1KDXy7I/rci/N0SW Yq+BbmtsEZX6zQFlapkcIIhZ56GDJ+ZO7jSyN4+LYFBtMkPllRmINTW8BwNScPbADNvx 9VjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:dkim-signature; bh=jW40KaM1lKgxJUUU8ncvlQiPDre5IRRCh+8ZWAaODsg=; b=Lx2L7Ea81oiYrKyo4z1CQHY6QM+gazkwTwB2mqCKwKJIunOW8GrS0PGwidnOM7h3fT 2X1rhA5xNEEuzK2Av0UTgWMuic9OVwofgIQFXDLAx0jOsrUPNIFmP1Yoounft2d5DBL+ JWFFAt04kbajeVL/bqRGnEoY5HfHkDm4RFQ3BZ2szJQAAcnvgGup1tDc/ZDJ0XU/8Imf sBGo0l70Yth6BZ1nYH3QUE7nVSxoPFs7AlyPRFtDAp15ErNntrHyFZ4GCZVSdZc3HQkq /YzUViuSuoFFCZqsu95ttkHkzKeZTuITnD9ttZtbySK2xZQ0xajShghv/nF5qQED1gXu XfEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=R8PcWSL6; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=kvRNzUKV; 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 r5si12292391edv.550.2021.10.07.02.53.24; Thu, 07 Oct 2021 02:53:47 -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=@suse.cz header.s=susede2_rsa header.b=R8PcWSL6; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=kvRNzUKV; 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 S240569AbhJGJwc (ORCPT + 99 others); Thu, 7 Oct 2021 05:52:32 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:46376 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232718AbhJGJwa (ORCPT ); Thu, 7 Oct 2021 05:52:30 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 804E32008B; Thu, 7 Oct 2021 09:50:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1633600235; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=jW40KaM1lKgxJUUU8ncvlQiPDre5IRRCh+8ZWAaODsg=; b=R8PcWSL65q+iFRelGz3/+YfvxYSk4urANMubdcWqQYcmFhqgeAtTSl3MnXwg1BaGp0kcEG nhBRm1xA/i8N2Wcsdy5VVBBX1aYeqlvX9/GO7kSUnxGQCO6CmZOFFlKf6pDg/bj8Iwicfm FWkP/qfzGNSrHS4EtOytAaz2sBEwqp0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1633600235; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=jW40KaM1lKgxJUUU8ncvlQiPDre5IRRCh+8ZWAaODsg=; b=kvRNzUKVHRH32JSIfWRvq5y0CQWlGTDUo2s8M7utsXMvFd9OJSzpfIlaANjoukFZVD6VaP /leGP6ZP43nQCdBw== Received: from quack2.suse.cz (unknown [10.100.224.230]) by relay2.suse.de (Postfix) with ESMTP id 463B5A3B8C; Thu, 7 Oct 2021 09:50:35 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 422251F2C99; Thu, 7 Oct 2021 11:01:57 +0200 (CEST) Date: Thu, 7 Oct 2021 11:01:57 +0200 From: Jan Kara To: Chengguang Xu Cc: miklos@szeredi.hu, jack@suse.cz, amir73il@gmail.com, linux-fsdevel@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH v5 06/10] ovl: implement overlayfs' ->write_inode operation Message-ID: <20211007090157.GB12712@quack2.suse.cz> References: <20210923130814.140814-1-cgxu519@mykernel.net> <20210923130814.140814-7-cgxu519@mykernel.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210923130814.140814-7-cgxu519@mykernel.net> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 23-09-21 21:08:10, Chengguang Xu wrote: > Implement overlayfs' ->write_inode to sync dirty data > and redirty overlayfs' inode if necessary. > > Signed-off-by: Chengguang Xu ... > +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); > + I'm somewhat confused here. 'inode' is overlayfs inode AFAIU, so how is it correct to pass it to ->write_inode function of upper filesystem? Shouldn't you pass 'upper' there instead? > + 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; Also since you call ->write_inode directly upper->i_state won't be updated to reflect that inode has been written out (I_DIRTY flags get cleared in __writeback_single_inode()). So it seems to me overlayfs will keep writing out upper inode until flush worker on upper filesystem also writes the inode and clears the dirty flags? So you rather need to call something like write_inode_now() that will handle the flag clearing and do writeback list handling for you? Honza -- Jan Kara SUSE Labs, CR