Received: by 10.213.65.68 with SMTP id h4csp604871imn; Fri, 23 Mar 2018 11:24:29 -0700 (PDT) X-Google-Smtp-Source: AG47ELttS+sSDGAq84Mt3gnzBty1PG3YcfmWNzYhXG0+NcKlM5nvmKJFTVvMrY8jtinkLSmnjgn1 X-Received: by 10.101.87.136 with SMTP id b8mr21445454pgr.282.1521829469438; Fri, 23 Mar 2018 11:24:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521829469; cv=none; d=google.com; s=arc-20160816; b=N4A6UQXikSRSpjoEOMnKqsjtvc/LP6mJrOqc0BfmZYgJGCdtNYKJ5OlKyyTPjUNnWR Y6FASDR4qh/hUssIRlVH/ZAD7KnOVxi/3lBQyWrcBNF2BneB3wQBuZ/CY11ZcWp7YbdI Q6cJNBgB2uwFtT61S3cpOki/EzLZzOBckpd3dfKaJ4zOrk3CeOiD77Lf6/PYEHekPZZ5 DP6qCKjw/JbnUYtwu76dtro4go8f+XavulR7p96XZUJMy29f5u9Nzzq0WQpnrVXzCgmv 4jK3hLs5DX8ioJlLxjPugcOjoRS3XunnFiW6hvmYAtPPYGDjZcJE6i5IJ1vvr+y1vZbi xq2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=zCGP/g8GP10fIvXTziB9adPoI4EAP1C/QH5qxeCUP+w=; b=X86cK8SMTJ0AO0rGoaXdf2oL+w3vZEvQoQ+pdlwSVE1tAk0KmPFY40RSNNPdhDYfsR W8+i5MzQ2wfsWi7WSnxd+MaaNnEG2cMER59/OSSFUQosGAOjvZDja0exrRodEoHz68zN sAl3IteMo32eKqoHRvq7266RGrslT8snMcBmaocmsoxzNSVB/uRwZ75tpum/IajqgEBm aqHz5x7UjaAaZsHtCk0y0BqZ0kvRzBusjrXp6oFuKv0Jlfia3A/s1qONshzvqFPj1GwB uxZIsK3zNReui+/EEFeVrdhm8yuRrr8WryhAlDVAwBnO0riDADKqulb28+YT6KzhA8AV URrA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bd3-v6si9792425plb.392.2018.03.23.11.24.15; Fri, 23 Mar 2018 11:24:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752546AbeCWSXH (ORCPT + 99 others); Fri, 23 Mar 2018 14:23:07 -0400 Received: from mx2.suse.de ([195.135.220.15]:52347 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751541AbeCWSXF (ORCPT ); Fri, 23 Mar 2018 14:23:05 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id F2EB7B035; Fri, 23 Mar 2018 18:23:02 +0000 (UTC) Date: Fri, 23 Mar 2018 18:23:02 +0000 From: "Luis R. Rodriguez" To: "Darrick J. Wong" , Christoph Hellwig Cc: "Luis R. Rodriguez" , xfs , linux-kernel@vger.kernel.org, Sasha Levin , Greg Kroah-Hartman , Julia Lawall , Josh Triplett , Takashi Iwai , Michal Hocko , Joerg Roedel Subject: Re: [PATCH] xfs: always free inline data before resetting inode fork during ifree Message-ID: <20180323182302.GB9190@wotan.suse.de> References: <20171123060137.GL2135@magnolia> <20180323013037.GA9190@wotan.suse.de> <20180323034145.GH4818@magnolia> <20180323170813.GD30543@wotan.suse.de> <20180323172620.GK4818@magnolia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180323172620.GK4818@magnolia> User-Agent: Mutt/1.6.0 (2016-04-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 23, 2018 at 10:26:20AM -0700, Darrick J. Wong wrote: > On Fri, Mar 23, 2018 at 05:08:13PM +0000, Luis R. Rodriguez wrote: > > On Thu, Mar 22, 2018 at 08:41:45PM -0700, Darrick J. Wong wrote: > > > On Fri, Mar 23, 2018 at 01:30:37AM +0000, Luis R. Rodriguez wrote: > > > > On Wed, Nov 22, 2017 at 10:01:37PM -0800, Darrick J. Wong wrote: > > > > > diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c > > > > > index 61d1cb7..8012741 100644 > > > > > --- a/fs/xfs/xfs_inode.c > > > > > +++ b/fs/xfs/xfs_inode.c > > > > > @@ -2401,6 +2401,24 @@ xfs_ifree_cluster( > > > > > } > > > > > > > > > > /* > > > > > + * Free any local-format buffers sitting around before we reset to > > > > > + * extents format. > > > > > + */ > > > > > +static inline void > > > > > +xfs_ifree_local_data( > > > > > + struct xfs_inode *ip, > > > > > + int whichfork) > > > > > +{ > > > > > + struct xfs_ifork *ifp; > > > > > + > > > > > + if (XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_LOCAL) > > > > > + return; > > > > > > > > I'm new to all this so this was a bit hard to follow. I'm confused with how > > > > commit 43518812d2 ("xfs: remove support for inlining data/extents into the > > > > inode fork") exacerbated the leak, isn't that commit about > > > > XFS_DINODE_FMT_EXTENTS? > > > > > > Not specifically _EXTENTS, merely any fork (EXTENTS or LOCAL) whose > > > incore data was small enough to fit in if_inline_ata. > > > > Got it, I thought those were XFS_DINODE_FMT_EXTENTS by definition. > > > > > > Did we have cases where the format was XFS_DINODE_FMT_LOCAL and yet > > > > ifp->if_u1.if_data == ifp->if_u2.if_inline_data ? > > > > > > An empty directory is 6 bytes, which is what you get with a fresh mkdir > > > or after deleting everything in the directory. Prior to the 43518812d2 > > > patch we could get away with not even checking if we had to free if_data > > > when deleting a directory because it fit within if_inline_data. > > > > Ah got it. So your fix *is* also applicable even prior to commit 43518812d2. > > You'd have to modify the patch so that it doesn't try to kmem_free > if_data if if_data == if_inline_data but otherwise (in theory) I think > that the concept applies to pre-4.15 kernels. > > (YMMV, please do run this through QA/kmemleak just in case I'm wrong, etc...) Well... so we need a resolution and better get testing this already given that *I believe* the new auto-selection algorithm used to cherry pick patches onto stable for linux-4.14.y (covered on a paper [0] and when used, stable patches are prefixed with AUTOSEL, a recent discussion covered this in November 2017 [1]) recommended to merge your commit 98c4f78dcdd8 ("xfs: always free inline data before resetting inode fork during ifree") as stable commit 1eccdbd4836a41 on v4.14.17 *without* merging commit 43518812d2 ("xfs: remove support for inlining data/extents into the inode fork"). Sasha, Greg, Can you confirm if the algorithm was used in this case? Since both commits are merged on v4.15, this is a non-issue on >= 4.15. I do wonder if other XFS folks are *at least* aware that the auto-selection algorithm now currently merging patches onto stable for XFS? FWIW I just finished completing review *all* the other stable commits merged on XFS on v4.14 *and* v4.13.y and this was the only one that cried out as fishy... so I would not use this as a reason to say we shouldn't use it for XFS, specially in lieu of any formal active process which we can count on always takes place for XFS stable patches. In fact, I'd say that if the auto-selection algorithm was used we should be able to fine tune it with a bit more subsystem involvement. I can at least volunteer to help try to review the candidate patches that AUTOSEL comes up with (any others?), but note I'm new to XFS... I can also think of a few modifications to the algorithm but which I can make in a separate thread. Anyway, provided this is reasonable with others, then perhaps we can keep using it for XFS? [0] https://soarsmu.github.io/papers/icse12-patch.pdf [1] https://lkml.org/lkml/2017/11/21/486 Luis