From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Cyrus-Session-Id: sloti22d1t05-874563-1516767449-2-6609978798977750778 X-Sieve: CMU Sieve 3.0 X-Spam-known-sender: no X-Spam-score: 0.0 X-Spam-hits: BAYES_00 -1.9, HEADER_FROM_DIFFERENT_DOMAINS 0.25, RCVD_IN_DNSWL_HI -5, T_RP_MATCHES_RCVD -0.01, LANGUAGES en, BAYES_USED global, SA_VERSION 3.4.0 X-Spam-source: IP='209.132.180.67', Host='vger.kernel.org', Country='US', FromHeader='com', MailFrom='org', XOriginatingCountry='US' X-Spam-charsets: plain='iso-8859-1' X-Resolved-to: greg@kroah.com X-Delivered-to: greg@kroah.com X-Mail-from: stable-owner@vger.kernel.org ARC-Seal: i=1; a=rsa-sha256; cv=none; d=messagingengine.com; s=arctest; t=1516767449; b=Zmo2PbgpCm5vVxUzH1dA2cmzPvEFs0rHTFe6OOjynDsp2WP 8rt4DogdYU7C7BTW6Y4cwkG1ttQ+iOrxCOCe74wyBIvOb8Mm+2yXkROrtY2Lj8q6 xH1NkpYpILLOLAXxknIb+Sset4xGLHObRu1vefvTH9pCMj6+5zltCjPZktfIviGf zHjdAB8oCv5GuXYMjELGVW9c/xtghhGCdPPaE5HFmUSlkPWv996kpNdwkCwfcuNh 4q32ERdt+SJbzT5jBzMX3DJ6iOfWnr5PbXz0Tsof0GV88rqPipiYS6tLb3FeK1n/ P0s4vAMa0YoA3DJVXXP8b8bKRVJMl6jVSZZGr/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=from:to:cc:subject:date:message-id :references:in-reply-to:content-type:content-transfer-encoding :mime-version:sender:list-id; s=arctest; t=1516767449; bh=hwbqbI RaDEuYvGsF1M7lng6JYl4o0kfb9yLkoWox+/Y=; b=nXry+ZM7uHBcV/V1pLmFIT BujFzjWawPPqrTbiRhl32O7j4ahnESYICRGJTvsJwPFAFMIbpPVBpBlJHJE6+oYa WFwFCvYDzZXxBL1tjfkQlj0umPuJ4OVqM6Yvx28iqVM1UZYEkyD+1Kkgbf8WcqxQ xSSWUj0evfKQbWSX86SbCupfjppJLsS0eL6ATxtw2ND9+af3acWnqB2omoPx3FsB SIqO6uryg1qqyg29Fw2EIQs9aK5tCZTrM5LyD+neqLgGNBruZYT+e5a1OHxBSFPP hUDaIagQD5mD5ab65xj2KFr3gtCT4UFUIhDb2ihqvjmmPvG1oQ3w42t1k6lrMO0Q == ARC-Authentication-Results: i=1; mx4.messagingengine.com; arc=none (no signatures found); dkim=pass (1024-bit rsa key sha256) header.d=microsoft.com header.i=@microsoft.com header.b=UAR8hpl3 x-bits=1024 x-keytype=rsa x-algorithm=sha256 x-selector=selector1; dmarc=pass (p=reject,has-list-id=yes,d=none) header.from=microsoft.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=microsoft.com header.result=pass header_is_org_domain=yes Authentication-Results: mx4.messagingengine.com; arc=none (no signatures found); dkim=pass (1024-bit rsa key sha256) header.d=microsoft.com header.i=@microsoft.com header.b=UAR8hpl3 x-bits=1024 x-keytype=rsa x-algorithm=sha256 x-selector=selector1; dmarc=pass (p=reject,has-list-id=yes,d=none) header.from=microsoft.com; iprev=pass policy.iprev=209.132.180.67 (vger.kernel.org); spf=none smtp.mailfrom=stable-owner@vger.kernel.org smtp.helo=vger.kernel.org; x-aligned-from=fail; x-ptr=pass x-ptr-helo=vger.kernel.org x-ptr-lookup=vger.kernel.org; x-return-mx=pass smtp.domain=vger.kernel.org smtp.result=pass smtp_org.domain=kernel.org smtp_org.result=pass smtp_is_org_domain=no header.domain=microsoft.com header.result=pass header_is_org_domain=yes Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932419AbeAXERZ (ORCPT ); Tue, 23 Jan 2018 23:17:25 -0500 Received: from mail-sn1nam02on0108.outbound.protection.outlook.com ([104.47.36.108]:12096 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932348AbeAXERX (ORCPT ); Tue, 23 Jan 2018 23:17:23 -0500 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: "Darrick J. Wong" , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 22/55] xfs: always free inline data before resetting inode fork during ifree Thread-Topic: [PATCH AUTOSEL for 4.9 22/55] xfs: always free inline data before resetting inode fork during ifree Thread-Index: AQHTlMn+99k7AhnljUyK4IPOKCqrUw== Date: Wed, 24 Jan 2018 04:15:40 +0000 Message-ID: <20180124041521.32223-22-alexander.levin@microsoft.com> References: <20180124041521.32223-1-alexander.levin@microsoft.com> In-Reply-To: <20180124041521.32223-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB0933;7:hwdSUy9YeX1eXe5O2t5gZHpzrpzkAqBTavq5pawRWZmmbK0HLlHvuNQIFBFdKv/fWz+tnT48Xx/O/4YA8gQilmf329XrM1u/fllk6uIx8dUUQ2/yL3B0u63MbptC1kryBXMSRWscMGXvHYla+PNI/mvSmcU/soc1pMADchnZHH3p60hHCb1Rh0ZofoMGoSFniv088qQ/rM5HSJDcsrZC/WwOatArlBgxr63tN6Aj6BTCMf4nk1gvD9aYPQjOvZ0L x-ms-office365-filtering-correlation-id: f3637d4e-19dc-455f-b813-08d562e15db0 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(4604075)(3008032)(48565401081)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603307)(7193020);SRVR:DM5PR2101MB0933; x-ms-traffictypediagnostic: DM5PR2101MB0933: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(146099531331640)(17755550239193); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(61425038)(6040501)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(3002001)(3231046)(2400081)(944501161)(6055026)(61426038)(61427038)(6041288)(20161123560045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123564045)(6072148)(201708071742011);SRVR:DM5PR2101MB0933;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0933; x-forefront-prvs: 056297E276 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(39860400002)(376002)(366004)(39380400002)(396003)(189003)(199004)(105586002)(305945005)(478600001)(110136005)(10290500003)(76176011)(54906003)(106356001)(25786009)(66066001)(10090500001)(14454004)(3846002)(6116002)(1076002)(6346003)(97736004)(6506007)(5250100002)(2501003)(72206003)(4326008)(36756003)(3280700002)(3660700001)(102836004)(2906002)(5660300001)(53936002)(107886003)(2900100001)(6436002)(6512007)(99286004)(8936002)(68736007)(7736002)(86612001)(81156014)(86362001)(2950100002)(26005)(81166006)(8676002)(22452003)(6486002)(316002)(6666003)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0933;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-message-info: qHvW4NFVzpANhK+5PYeNEh07f2bVVJc2YLLMxMw4r1tiDLIOp6zhva3DfAiyPvYhT92Tj7c68+Abw1GCEKEvow== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: f3637d4e-19dc-455f-b813-08d562e15db0 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Jan 2018 04:15:40.2906 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0933 Sender: stable-owner@vger.kernel.org X-Mailing-List: stable@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-Mailing-List: linux-kernel@vger.kernel.org List-ID: From: "Darrick J. Wong" [ Upstream commit 98c4f78dcdd8cec112d1cbc5e9a792ee6e5ab7a6 ] In xfs_ifree, we reset the data/attr forks to extents format without bothering to free any inline data buffer that might still be around after all the blocks have been truncated off the file. Prior to commit 43518812d2 ("xfs: remove support for inlining data/extents into the inode fork") nobody noticed because the leftover inline data after truncation was small enough to fit inside the inline buffer inside the fork itself. However, now that we've removed the inline buffer, we /always/ have to free the inline data buffer or else we leak them like crazy. This test was found by turning on kmemleak for generic/001 or generic/388. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Sasha Levin --- fs/xfs/xfs_inode.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 98ca9f1b6a07..c5f2f1e3cc4b 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -2430,6 +2430,24 @@ retry: } =20 /* + * 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) !=3D XFS_DINODE_FMT_LOCAL) + return; + + ifp =3D XFS_IFORK_PTR(ip, whichfork); + xfs_idata_realloc(ip, -ifp->if_bytes, whichfork); +} + +/* * This is called to return an inode to the inode free list. * The inode should already be truncated to 0 length and have * no pages associated with it. This routine also assumes that @@ -2466,6 +2484,9 @@ xfs_ifree( if (error) return error; =20 + xfs_ifree_local_data(ip, XFS_DATA_FORK); + xfs_ifree_local_data(ip, XFS_ATTR_FORK); + VFS_I(ip)->i_mode =3D 0; /* mark incore inode as free */ ip->i_d.di_flags =3D 0; ip->i_d.di_dmevmask =3D 0; --=20 2.11.0