Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1146778ybh; Mon, 13 Jul 2020 10:28:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzs8H27WaGy81KUKingzSq0aQmdqTVlWmdp5ovMMHoxrp0wNE9hWF/tlkEJIIGhDtEFl2OO X-Received: by 2002:a17:906:a058:: with SMTP id bg24mr804751ejb.370.1594661323249; Mon, 13 Jul 2020 10:28:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594661323; cv=none; d=google.com; s=arc-20160816; b=cDKqf3S9lHc3BLNIZ5+D1OMhpJH7gL3XLv+ozxjYUxLQHuYMUicdwU7Nz1Gmjqrej3 V4S57HbaAgDk09rt+65wNb51PCHwMHPZvhmN1U4pQ8jLnStFvN6/7Pq9D4igZi3w7W/U j2WU0M9SPUN8K16wV8J0IcJMcMJzpivkjrcNdn+QRQ8q0ysGHxpieCxZtPRVl8DZJCSb 3nuLnEprHTioBmgYtep2mCVUbA6d+k9VpFI7IwHmk/usudVwFofUUsXPROAbf3+B4HcP FFEnUAyqKQ69P0wK5dBBsWiU4WCgdHjiOj49EgQWjdzR1MdpKzZYzOG46nUUv6tU9eCY 93hA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=pH1K2vUzPfJhwEBVdOMPKdK/A94n7hLqQfvszT16hv4=; b=lmzI6tczdOcrJr7xAu/kl6skCM1xctLH2p+PB+BgiRcT1y77e9kFDW/2cvRJwrhCdr cczBPcjBlAXWJ0rrlyrduezRZhK262JbmKe7tK1BOOA4cSz8+rFUTYbMLZjjpbxSldgt u1PARpi8v53GX3sDFHEscDV6NAKxs2wOR34GDqoF/dLn47BIE3E/JTR4W+i8QbD2fFCp DB7f5waYCqRfVQnXmV2i34ez9oUK50Nd9blgha1uag/0XxfA5af5G17moEAcSnEkABMC D1SYYz/s/TKlaU+c1DEDgRlZJurpoTLtDWSAT7g6gAD2CuqglSq4HV4PUC4yhbxL+exM HR4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chrisdown.name header.s=google header.b=NRegjh3L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chrisdown.name Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n7si5491677ejg.734.2020.07.13.10.28.20; Mon, 13 Jul 2020 10:28:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chrisdown.name header.s=google header.b=NRegjh3L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chrisdown.name Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730257AbgGMR2L (ORCPT + 99 others); Mon, 13 Jul 2020 13:28:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730192AbgGMR2K (ORCPT ); Mon, 13 Jul 2020 13:28:10 -0400 Received: from mail-ej1-x642.google.com (mail-ej1-x642.google.com [IPv6:2a00:1450:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65857C061794 for ; Mon, 13 Jul 2020 10:28:10 -0700 (PDT) Received: by mail-ej1-x642.google.com with SMTP id o18so18149559eje.7 for ; Mon, 13 Jul 2020 10:28:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chrisdown.name; s=google; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=pH1K2vUzPfJhwEBVdOMPKdK/A94n7hLqQfvszT16hv4=; b=NRegjh3LBWDlrzUeOyPaQJxImhcWMjvignzs5E6UY4PzLSDkmPbyXeWAHNwJECOTmS cwenOTW+EsLhulDrayiQ/2zwo5NgqG4xyARuMoN+FCHCM4FS8fduE6c0yLQ92Dik+fN9 qPQsCSXMlAdYzgiDDf30IbAHXQyAltxf+sHHA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=pH1K2vUzPfJhwEBVdOMPKdK/A94n7hLqQfvszT16hv4=; b=cxXQnkxCEyJ2DoEggxMZKkzb2gPdwIQTTz32s0Y6m7G5LKzXgMyXI6FjXojXX/qXMe hdiQ5KQss0OexPM4xe7I3nLsQZv3rsQ8tDFFu5NVO1le604xa8bNvo1wbEhNIVLoW4Yc JbG2ebL85OiPO+RLXjU/hBiV5OapqBSDsEUgIjPDjCFC7f2HXYUjnSklOfaP62WM6oaV myPX1y8sslrRxKkpEGANwo6gCfEc4qTLhcH9lJKUnAJg6behUhNObxnJyP5QNjwQNcEA ooISkUGaCSAD959OYbCuno4I37BA6xyxGLaUCpp0/hqlnLLTE94QJdN8qQ1aZFIbL9cs s2ng== X-Gm-Message-State: AOAM531v8N7rlS51jhNJyj3x9qmIRi2G65Jo/O64ltMxk8moHl1aHmUx szpd4dG23Oe5yiCJmNKTZjXc1g== X-Received: by 2002:a17:906:9244:: with SMTP id c4mr796991ejx.60.1594661288807; Mon, 13 Jul 2020 10:28:08 -0700 (PDT) Received: from localhost ([2620:10d:c093:400::5:ef88]) by smtp.gmail.com with ESMTPSA id b14sm10150344ejg.18.2020.07.13.10.28.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 10:28:08 -0700 (PDT) Date: Mon, 13 Jul 2020 18:28:08 +0100 From: Chris Down To: Andrew Morton Cc: Hugh Dickins , Al Viro , Matthew Wilcox , Amir Goldstein , Jeff Layton , Johannes Weiner , Tejun Heo , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: [PATCH v7 0/2] tmpfs: inode: Reduce risk of inum overflow Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.14.5 (2020-06-23) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In Facebook production we are seeing heavy i_ino wraparounds on tmpfs. On affected tiers, in excess of 10% of hosts show multiple files with different content and the same inode number, with some servers even having as many as 150 duplicated inode numbers with differing file content. This causes actual, tangible problems in production. For example, we have complaints from those working on remote caches that their application is reporting cache corruptions because it uses (device, inodenum) to establish the identity of a particular cache object, but because it's not unique any more, the application refuses to continue and reports cache corruption. Even worse, sometimes applications may not even detect the corruption but may continue anyway, causing phantom and hard to debug behaviour. In general, userspace applications expect that (device, inodenum) should be enough to be uniquely point to one inode, which seems fair enough. One might also need to check the generation, but in this case: 1. That's not currently exposed to userspace (ioctl(...FS_IOC_GETVERSION...) returns ENOTTY on tmpfs); 2. Even with generation, there shouldn't be two live inodes with the same inode number on one device. In order to mitigate this, we take a two-pronged approach: 1. Moving inum generation from being global to per-sb for tmpfs. This itself allows some reduction in i_ino churn. This works on both 64- and 32- bit machines. 2. Adding inode{64,32} for tmpfs. This fix is supported on machines with 64-bit ino_t only: we allow users to mount tmpfs with a new inode64 option that uses the full width of ino_t, or CONFIG_TMPFS_INODE64. You can see how this compares to previous related patches which didn't implement this per-superblock: - https://patchwork.kernel.org/patch/11254001/ - https://patchwork.kernel.org/patch/11023915/ Changes since v6: - Fix misalignment in percpu batching, thanks Matthew. Chris Down (2): tmpfs: Per-superblock i_ino support tmpfs: Support 64-bit inums per-sb Documentation/filesystems/tmpfs.rst | 11 +++ fs/Kconfig | 15 ++++ include/linux/fs.h | 15 ++++ include/linux/shmem_fs.h | 3 + mm/shmem.c | 127 ++++++++++++++++++++++++++-- 5 files changed, 166 insertions(+), 5 deletions(-) -- 2.27.0