Received: by 10.223.176.46 with SMTP id f43csp279461wra; Tue, 23 Jan 2018 20:56:46 -0800 (PST) X-Google-Smtp-Source: AH8x226MYpb9el+DfQSO77kSU+QTCKT4bDMjl/R32s+/LJ6/8WaiCjNJX58fh50XIH53yNET1T6E X-Received: by 10.98.238.2 with SMTP id e2mr11893868pfi.206.1516769806057; Tue, 23 Jan 2018 20:56:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516769806; cv=none; d=google.com; s=arc-20160816; b=RKxmjX/nnzPk4vXlh4BHJrtLL8g8YuGWxldvXpaY5/454FjPHRFOYiXHjz+NzmlhAP ua5qp45LAI+GQvJMunw/ULWelIc2w94aq8fOzxt948vnMCW0vIjPECfoe4poQtvNVBco j24rPOFFO0CJiB2d5vLhm4JkKtMJFSHOF44xG8EsacnNnP6O+EeSz3bLq8lMnV0m5Hxh 2VOoHMjV13c/pdFr41+yfxDSno43VY4sxMIlWzj+Wi3OSqgxW5d9Vv+Kx4AJwjXP6Qx4 ZjvuDke0QDIeFEx67NnW3wxpmnV6R6ts34V0Be9JBPqI5k0LOP1hiM7V33mjWXTTaAQg gdEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=Exo8oGxRx2gSWQog+GlGm73rfG+PApBakT3kQjx/rqs=; b=qmx4ZnKEGRSrySdJf2D0gmnEk7/9imIsO5+xbiU6fPtihESIcvd5xmma2zJmePWoB5 7fr8GvpQStmCHXpBGH1n6dyk7AYvY8rXhUt1MUZKVi0dlFTNRVKQ1e5t/U8uDuyWOSk2 +493N8z6pYp2vfH3ATXyeoTa3+Nbd4a06uC6eA7R/OHUf0rWjT6C0S5DdvHy3KoOx1tT vDyqM71AJvVtr2P5156c1XI0lGvVGMjV8jGoWyHNWWM+UHXVsxC8i6SBhOK/Y5u9542y 6JIoskL+s6zNpN/uOH7pTLckKVjoGsl4SSV92Ig0BpmBNbCVFN+fwhnxoEDxtQQrkFXi ScPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=ZkQu+Lzh; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a8-v6si5275250ple.375.2018.01.23.20.56.32; Tue, 23 Jan 2018 20:56:46 -0800 (PST) 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; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=ZkQu+Lzh; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932333AbeAXEzx (ORCPT + 99 others); Tue, 23 Jan 2018 23:55:53 -0500 Received: from mail-sn1nam01on0109.outbound.protection.outlook.com ([104.47.32.109]:45568 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932180AbeAXEPW (ORCPT ); Tue, 23 Jan 2018 23:15:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Exo8oGxRx2gSWQog+GlGm73rfG+PApBakT3kQjx/rqs=; b=ZkQu+LzhETx/DF0EXo3RRq0D9uhtIxuWkywqrWcaVZk08fnVSxBB1A1x4ONEWwG643aJw/lyqvecPF8nHi+G1HE3et6dfs93x+EHb2zG4bMF/EgKuXR9g/EeOSTZ10x1k/QAwJUTCa4l4qbveyW6+SfQ+lQMTJgqkZe0N0ZqXLg= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1015.namprd21.prod.outlook.com (52.132.133.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.464.0; Wed, 24 Jan 2018 04:15:18 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::6485:b98:d15e:9da7]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::6485:b98:d15e:9da7%2]) with mapi id 15.20.0464.000; Wed, 24 Jan 2018 04:15:18 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: "Darrick J. Wong" , Sasha Levin Subject: [PATCH AUTOSEL for 4.14 051/100] xfs: always free inline data before resetting inode fork during ifree Thread-Topic: [PATCH AUTOSEL for 4.14 051/100] xfs: always free inline data before resetting inode fork during ifree Thread-Index: AQHTlMngMTeTWVabNUibjwgAZbGOPA== Date: Wed, 24 Jan 2018 04:14:50 +0000 Message-ID: <20180124041414.32065-51-alexander.levin@microsoft.com> References: <20180124041414.32065-1-alexander.levin@microsoft.com> In-Reply-To: <20180124041414.32065-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;DM5PR2101MB1015;7:qxvvuPKCWvblPuOTRXFRoe6JfHYrdGJR7sOsFmMl/NbhdDsIboWkceshI+KoHMlYs15cOvtQND5Cq8U6vfjg7EyQx7xJhoOGF/jnxT1WH7Yp14QwVN2eUw8BUiLP0eDlWYQlZ7f259KiWRw3V91K+RjOHApEc8SmNvcV0p9un4vL8+GNUd8XCUWwLTZVt8jjVO9SCQgYnX1ca50aqpXgYcSXMlEWgPmMbjNL2WW5mQ9Yy5MUQ4HR9MU8oLhWSG6g x-ms-office365-filtering-correlation-id: ae61aa46-0146-4700-61e8-08d562e113c5 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(2017052603307)(7193020);SRVR:DM5PR2101MB1015; x-ms-traffictypediagnostic: DM5PR2101MB1015: 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)(3002001)(10201501046)(3231046)(2400081)(944501161)(93006095)(93001095)(6055026)(61426038)(61427038)(6041288)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:DM5PR2101MB1015;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1015; x-forefront-prvs: 056297E276 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(396003)(39380400002)(376002)(366004)(39860400002)(346002)(199004)(189003)(478600001)(6666003)(106356001)(6512007)(53936002)(2900100001)(36756003)(102836004)(2950100002)(2501003)(10290500003)(97736004)(14454004)(81166006)(72206003)(8936002)(6486002)(1076002)(10090500001)(6346003)(26005)(54906003)(4326008)(76176011)(99286004)(86362001)(3660700001)(105586002)(6116002)(8676002)(68736007)(22452003)(66066001)(25786009)(6506007)(5660300001)(305945005)(7736002)(3280700002)(5250100002)(2906002)(107886003)(86612001)(6436002)(316002)(81156014)(3846002)(110136005)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1015;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-message-info: KiPC6T4Myov5VhY2CAh8AMMRilDSbUkS63H2VpLNnN6kIeubSJzepPbxuIM5ZENdETtQ0nq7GQYH24ZLzI3Wjg== 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: ae61aa46-0146-4700-61e8-08d562e113c5 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Jan 2018 04:14:50.1821 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1015 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 63350906961a..cb4833d06467 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -2422,6 +2422,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 @@ -2458,6 +2476,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