Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp3173523imj; Mon, 18 Feb 2019 21:50:28 -0800 (PST) X-Google-Smtp-Source: AHgI3IYSDTXc2I2uyO0jS/0S8KSIyGASbSDrZ5ivsiCZRhrdh4Qfdzo+z6tanaQFIntVDz/W5un3 X-Received: by 2002:a63:2bc4:: with SMTP id r187mr22104077pgr.306.1550555428463; Mon, 18 Feb 2019 21:50:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550555428; cv=none; d=google.com; s=arc-20160816; b=OU02bZ7/9ZDAXckCNbP/lnnmuw/cC+EunWKlyPkNXYB7wbHm/KLiDdaMD1hlD5SIxn TiIDqwYQbiBjERFVWQ00WT0JLYz/6QnCUqX9HEq5Hq9SEHBZv/8HYzhd/II0GlX5UASn dMOKYYw8YeTmTbzOq3rXtsumZOgD6mPYo+weVWzny2CoKMuPxfKBPhLCM5CzyuESVNGW qf+GxveET1URfYQUYKhHuGo43q0gx5XXsAw8vQQ9V2nfb/27KFQJ2I2+rxcba5J6NtOU bpWVTiHlK0fDeuVNt/cwaK2h23MlU5znIVq1/icnPpst7lxZ62qTIEPT0OHH5j1D9Gcz 0z8g== 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; bh=2s2UoIshcg+Lry9kl5cpTRzFGHWhySz8aruPidqxSaw=; b=bSWWEV4NjQ0fdZTiI3hjKawnyhi4WGjfSB17icd3HcVNmzRRlT7n7rIz1KTP5VkGMd vtsnEOrAbD8nUD8dC7Vy4jokiYFX3B8STIzM7D9c+YltlEtajvAP8/XEFgEZasEcG5GL Z5oQPCO4WwkNzowX37HGimxW9HlOhvFoZ/pX7OVOTpKet7Pr36CDqDZjkQHufhjqQtyE YMEnXndpzn5bzKqgKHee+v67iZW/pG0v8zncQI5wlX9a6TLe2VksxkFz+fc0LAKdes/t J0pr4CCP/eNKNGy9x3P26YLsXidu0MQZOz0SCipE2pqQ8Ts6t0zKw0LplMIdA3lhTMwu BbXA== 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 j66si13470243pfb.182.2019.02.18.21.50.13; Mon, 18 Feb 2019 21:50:28 -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; 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 S1726469AbfBSFsN (ORCPT + 99 others); Tue, 19 Feb 2019 00:48:13 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:58718 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725763AbfBSFsN (ORCPT ); Tue, 19 Feb 2019 00:48:13 -0500 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.91 #2 (Red Hat Linux)) id 1gvyGG-00086D-0y; Tue, 19 Feb 2019 05:48:08 +0000 Date: Tue, 19 Feb 2019 05:48:07 +0000 From: Al Viro To: Hugh Dickins Cc: Andrew Morton , "Darrick J. Wong" , Matej Kupljen , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH] tmpfs: fix link accounting when a tmpfile is linked in Message-ID: <20190219054807.GX2217@ZenIV.linux.org.uk> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 18, 2019 at 09:37:52PM -0800, Hugh Dickins wrote: > From: "Darrick J. Wong" > > tmpfs has a peculiarity of accounting hard links as if they were separate > inodes: so that when the number of inodes is limited, as it is by default, > a user cannot soak up an unlimited amount of unreclaimable dcache memory > just by repeatedly linking a file. > > But when v3.11 added O_TMPFILE, and the ability to use linkat() on the fd, > we missed accommodating this new case in tmpfs: "df -i" shows that an > extra "inode" remains accounted after the file is unlinked and the fd > closed and the actual inode evicted. If a user repeatedly links tmpfiles > into a tmpfs, the limit will be hit (ENOSPC) even after they are deleted. > > Just skip the extra reservation from shmem_link() in this case: there's > a sense in which this first link of a tmpfile is then cheaper than a > hard link of another file, but the accounting works out, and there's > still good limiting, so no need to do anything more complicated. > > Fixes: f4e0c30c191 ("allow the temp files created by open() to be linked to") > Reported-by: Matej Kupljen > Signed-off-by: Darrick J. Wong > Signed-off-by: Hugh Dickins FWIW, Acked-by: Al Viro Or I can drop it into vfs.git - up to you.