From owner-freebsd-hackers@freebsd.org Fri Mar 15 16:25:27 2019 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 651F115259CE for ; Fri, 15 Mar 2019 16:25:27 +0000 (UTC) (envelope-from asomers@gmail.com) Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E5B4B6F4C9 for ; Fri, 15 Mar 2019 16:25:26 +0000 (UTC) (envelope-from asomers@gmail.com) Received: by mail-lj1-f172.google.com with SMTP id v10so8476289lji.3 for ; Fri, 15 Mar 2019 09:25:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=tfYrLkqSIy5oDf0QgiNcICMtC+mHZsxJWKvf999p+Qk=; b=BO1ui//VaOMVCaej4ky/13Lfv9Qh0KrR3iZzs9mC1UFyP1u/gyw/zyPHie5iyEm/t9 mSq7kDyIS55BJFcNDXOWC7Z7gLqCPNkdq7fboWzBajypg7xnFdhku7mIEsFMqrZWWWiD iATCPmxMPU51LZz47VBVEVFnrGUMEVz7przGH89YMqNuwmBh2Qf9SApdig7azIP5xoDQ 0F7Dlg22ywGnwzyT2kdbZphvA/ZQ+hYWr/E7L1j+2nNUykkzXBkVJ095tL6VGXmNbiuo Gsc4pANXgysq0L5J+zEcVt3FnKncp99MVjE+kXsDPYOU245FyrBVc5Az9PTDUKfLNBvD nrTA== X-Gm-Message-State: APjAAAU3Llq/8/Q7HiupG6bPY/DRRnzXxvPce7kSko9NNAS+D2vUaOyN pfjZK2y7llZrz6dCKyHOA9sImclHD7HqFQm698M= X-Google-Smtp-Source: APXvYqxRsH5x7O9L1oivRg1fdOhoo2ur/0LJSOB/MRnfaQ5Ht7hIZNn4fwMyZVOZgP/7bHx7wrd6vJhcCxk8lJ91L5s= X-Received: by 2002:a2e:9889:: with SMTP id b9mr2450283ljj.29.1552667125051; Fri, 15 Mar 2019 09:25:25 -0700 (PDT) MIME-Version: 1.0 References: <20190315151920.GC96870@kib.kiev.ua> In-Reply-To: <20190315151920.GC96870@kib.kiev.ua> From: Alan Somers Date: Fri, 15 Mar 2019 10:25:13 -0600 Message-ID: Subject: Re: VOP_INACTIVE(9): reclaiming space for open but deleted files? To: Konstantin Belousov Cc: FreeBSD Hackers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: E5B4B6F4C9 X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.95 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; REPLY(-4.00)[]; NEURAL_HAM_SHORT(-0.95)[-0.951,0] X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Mar 2019 16:25:27 -0000 On Fri, Mar 15, 2019 at 9:19 AM Konstantin Belousov w= rote: > > On Fri, Mar 15, 2019 at 08:44:57AM -0600, Alan Somers wrote: > > VOP_INACTIVE(9) says that the vop can "be used to reclaim space for > > =E2=80=98open but deleted=E2=80=99 files". What does that mean? How c= an you reclaim > > space for open files? I assume it's just a mistake, but I want to > > check before I fix the man page. SVN archaeology shows that the line > > has been present since a mass import of man pages in 1997. > > VOP_INACTIVE() call means that the last use count for the vnode is > dereferenced. This can only happen when there is no more open files > using the vnode. > > Now consider what happens when you open file, then unlink it while > keeping the file opened. Filesystems usually mark such files with > VV_NOSYNC v_vflag, but there are typically other means to determine that > there is no name for the inode, like UFS i_nlink. On the last close > VOP_INACTIVE() is called (this is not guaranteed but you need to race to > not get the call). Then, if the vnode is not reclaimed, it is put on the > free list and the allocated blocks and other resources linger until the > vnode is reclaim (reclaim absolutely must free space for inodes which > cannot be reached). If inactive() frees the resources, the temporal > leak is avoided. > > As example look at UFS_INACTIVE(). If it detects file with effective lin= k > count of zero, it resets i_mode and calls ffs_vfree() to free inode. The= n > the vnode is reclaimed. Ok, so the man page is talking files which were formerly open but deleted, but are no longer open. I find the wording confusing. It seems to refer to files that are still open but deleted. -Alan