Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1099987ybh; Mon, 13 Jul 2020 09:18:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7UIMr5btxfu3vA7dxTQfeUHcnHCD517/u+5wcOqGyqoO4b7OO9lmmzeiD0Tww6tAtm9iE X-Received: by 2002:a17:906:1356:: with SMTP id x22mr473388ejb.429.1594657098025; Mon, 13 Jul 2020 09:18:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594657098; cv=none; d=google.com; s=arc-20160816; b=yyWw1Ml5h3O/FjDb5dHG3gTkaBhNPxyuZOfXfkaDnW8xwtQtneXKKZWDSenlgoX5Kz jSlesbDQD68ZyAQjhr+xzJGk1VYlZX6pAf7+2LCkBWtHOC8Jt2LUdFvn37BjF8BlzXV5 5IWF5H5mxb4NukxTZ6jNqUVh8Ca8YXxmoxoMcNHe4EAqefbsEdf2WtzSDrspguPkyJEL GGzd+auywVSjEtJNF/p1WnRHYupSuw1YK2vNmYfjnFABLI0hKcuBGdgCpENS3xnvpkEu FVAUoo05iWxZd5qvShF2/AwT3tiBgGm7IDEzeulcwtMi1tA8b2lDGfQ4ERaZYiYgBPi5 zpeg== 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=qYE0MGzN5oZiWXIC6Rq6ejY3VVjgiXoPpvYjyKeBdiI=; b=fwQsf00pFrS1isB1siMMjkSGZ/fSD7fNd1oAH1GpoubCQeXDdJ3TMnsJlJoFV04Zhk hSZWf8Yf/+37VxdAOFXiamzK/tGl3amYWAItAdZsZPpMDmXV/3NaqIOkJJo7np3nHvHr lcw2O0Hg6z1WE4KXy1qeAWChGB18miUzrdaSoxtet1eH/Xf8puZGTMi/U5URvjuHOWJ+ cd1kjwi7M8A9DDs0r44nRDoMjohVFlY6sTl0MCOqF6K/jqnC+ST6euPUby/Rfp1Y6QXQ Eg+pfgXnfgzEZz+ffin8w3HPbc+64YPSkZGoBLTFRSmGCk4JXmU7gZkeyCu4s9Ikmhlb mSsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chrisdown.name header.s=google header.b="dqAuVp/M"; 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 cq3si10121350edb.486.2020.07.13.09.17.53; Mon, 13 Jul 2020 09:18:18 -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="dqAuVp/M"; 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 S1729747AbgGMQPe (ORCPT + 99 others); Mon, 13 Jul 2020 12:15:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729027AbgGMQPe (ORCPT ); Mon, 13 Jul 2020 12:15:34 -0400 Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30445C061794 for ; Mon, 13 Jul 2020 09:15:34 -0700 (PDT) Received: by mail-ed1-x542.google.com with SMTP id h28so14213132edz.0 for ; Mon, 13 Jul 2020 09:15:34 -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=qYE0MGzN5oZiWXIC6Rq6ejY3VVjgiXoPpvYjyKeBdiI=; b=dqAuVp/Md6dltU2+wWd9YmXmJl0gjR4sK5zDAvjpTsJSVJFEJFpBOpTEFPSYpZrDap FvgwvNzH7PYXXjZj0kRjjJYnHYbr40UVkpwOFFuDRfDDDHTwKOApy25cUst736JqiSEN 1pXb/1YwmZ1btxsaqDTInRVQlHzc3Smv65CFY= 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=qYE0MGzN5oZiWXIC6Rq6ejY3VVjgiXoPpvYjyKeBdiI=; b=rbLAqeasUeJHGTHD1BmKRTqc1id2toCDDe9H9xy+ggqoDiZZEn35hKMy0gyiem+A7e Rsb2uBbxGRFqL8RXeYizZliSaMxuv88EZ0agqDRNtsoIINihrF6u6YaQPvK5vTvMFyBL pzojDmMbK3Rl4EiKYvyfP85pCqb6R+KCCmjLeoUSEDIt6nzLSne+2fjdNkTQKxBne43B vmqi8L2OtQx0XFzemo+Uqtwg1W5ghFnAY8eEyBC2y0fqrBvo7TUuizR5NCeKP65cqTlP IMo4HdEUukvd3WB+TRnI2ZrQSh201Zy38JGCEy2WtSacJnP9/KzmpNWV5yaSDb++f4TZ kfOQ== X-Gm-Message-State: AOAM533J290VbO/1EUEEC/uBgUuv9ee3yAHo9eUOD3rtn6kGVNrJ9AIC 7hudFohdZwtQ7G4S9Hnqeb3iSQ== X-Received: by 2002:a50:bf09:: with SMTP id f9mr133964edk.249.1594656932825; Mon, 13 Jul 2020 09:15:32 -0700 (PDT) Received: from localhost ([2620:10d:c093:400::5:ef88]) by smtp.gmail.com with ESMTPSA id n9sm12163985edr.46.2020.07.13.09.15.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2020 09:15:32 -0700 (PDT) Date: Mon, 13 Jul 2020 17:15:32 +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 v6 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 v5 (it's been a while, eh?): - Implement percpu batching for SB_KERNMOUNT at Hugh's suggestion. - Hugh also pointed out that user-exposed tmpfs can also now have max_inodes == 0, so we have to account for that. I just use SB_KERNMOUNT to do that in all the places we used to look at max_inodes. 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