Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp193794imj; Thu, 14 Feb 2019 18:23:46 -0800 (PST) X-Google-Smtp-Source: AHgI3IaIy4giFo2MvWxBxEET63Mash2YkSQ45QhvHRg4ukiyNb5AbchLJ0iSYEY2ZVio0DHyQ2B2 X-Received: by 2002:a62:55c4:: with SMTP id j187mr7317540pfb.129.1550197426247; Thu, 14 Feb 2019 18:23:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550197426; cv=none; d=google.com; s=arc-20160816; b=inqUUE60kYX0tPrL7Na1EU+slaslh3mXcXOpMz3R9sGUGhqOArsw2TVFNW56rr+q6x Mpah//r/MCyE9QGTz3IXF1AEYjq18SEDG4BCiZce3ju8xHio4IarDSDPHJxe8OSsYXrT wEFHliq8KMxxG4o0SCn8+kP6ZbDyOav/56rxvi6NxAaYG+PVIczyy0MZNXGqRkUoTlGa bY6sUzzzoEYyO2sk+Rs9w8uLB1slQgl0UJ1potdg/oGyV/JTIEfrUP+wIJhYl8Srgg+F uHQAzYn9RxozItLMXn3v0KwbpwFBa/KgzoHrg4r1Qtdco6O/EJTccHXbvi+6xW1aPuBh SG5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=Q4MpzrcqhsOXOojlMWUsqfBkRic2LhHEZxnWFgd/TWU=; b=nBRP5meq6gWwcsTpFimqJm0NJ7tTUB5GQwvx6bzPY/I5gXOT7dS3g82e1k+RK2kLhL VFT5L6EtSIRt2Uje0+DXYG7IQxQ1YaCeTpZM5u4htdHSAnc7coljpFipOAbvqfrI+Iv4 cP5LFP6fBZVuw+TuD6T8Z+GlHU5RYDEpft8oZWeUcyULsMcWQaLxd3cWDldDZD8SFUbq /gk+/i9Yph97j0M3CtcA/fFDndYuj7TgaoG7DKjr8AMci3UATeoZJ5ZC8HA5IPidVJ7S 7zBAG75MEknI8cqNNjFd6/MDQea4HB/IEzPR5QY1mw6eV7/aB0nZPjWYIZlGHoF4rwAo ftsg== 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 l7si3993687pgm.129.2019.02.14.18.23.30; Thu, 14 Feb 2019 18:23: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; 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 S1729301AbfBNXoF (ORCPT + 99 others); Thu, 14 Feb 2019 18:44:05 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:50740 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726178AbfBNXoF (ORCPT ); Thu, 14 Feb 2019 18:44:05 -0500 Received: from akpm3.svl.corp.google.com (unknown [104.133.8.65]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id E90182C; Thu, 14 Feb 2019 23:44:03 +0000 (UTC) Date: Thu, 14 Feb 2019 15:44:02 -0800 From: Andrew Morton To: Matej Kupljen Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: tmpfs inode leakage when opening file with O_TMP_FILE Message-Id: <20190214154402.5d204ef2aa109502761ab7a0@linux-foundation.org> In-Reply-To: References: X-Mailer: Sylpheed 3.6.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org (cc linux-fsdevel) On Mon, 11 Feb 2019 15:18:11 +0100 Matej Kupljen wrote: > Hi, > > it seems that when opening file on file system that is mounted on > tmpfs with the O_TMPFILE flag and using linkat call after that, it > uses 2 inodes instead of 1. > > This is simple test case: > > #include > #include > #include > #include > #include > #include > #include > #include > #include > > #define TEST_STRING "Testing\n" > > #define TMP_PATH "/tmp/ping/" > #define TMP_FILE "file.txt" > > > int main(int argc, char* argv[]) > { > char path[PATH_MAX]; > int fd; > int rc; > > fd = open(TMP_PATH, __O_TMPFILE | O_RDWR, > S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | > S_IROTH | S_IWOTH); > > rc = write(fd, TEST_STRING, strlen(TEST_STRING)); > > snprintf(path, PATH_MAX, "/proc/self/fd/%d", fd); > linkat(AT_FDCWD, path, AT_FDCWD, TMP_PATH TMP_FILE, AT_SYMLINK_FOLLOW); > close(fd); > > return 0; > } > > I have checked indoes with "df -i" tool. The first inode is used when > the call to open is executed and the second one when the call to > linkat is executed. > It is not decreased when close is executed. > > I have also tested this on an ext4 mounted fs and there only one inode is used. > > I tested this on: > $ cat /etc/lsb-release > DISTRIB_ID=Ubuntu > DISTRIB_RELEASE=18.04 > DISTRIB_CODENAME=bionic > DISTRIB_DESCRIPTION="Ubuntu 18.04.1 LTS" > > $ uname -a > Linux Orion 4.15.0-43-generic #46-Ubuntu SMP Thu Dec 6 14:45:28 UTC > 2018 x86_64 x86_64 x86_64 GNU/Linux > > If you need any more information, please let me know. > > And please CC me when replying, I am not subscribed to the list. > > Thanks and BR, > Matej