From bf37f936c4bcd645aebde8a476f325239e9b1f5e Mon Sep 17 00:00:00 2001 From: Omar Sandoval Date: Aug 10 2021 21:29:08 +0000 Subject: Add Facebook-only patch to deter from quotas --- diff --git a/SOURCES/1101-Require-clowntown-for-quota-enable.patch b/SOURCES/1101-Require-clowntown-for-quota-enable.patch new file mode 100644 index 0000000..09ab8fa --- /dev/null +++ b/SOURCES/1101-Require-clowntown-for-quota-enable.patch @@ -0,0 +1,86 @@ +From 72dcd3588774126e8769034847dd676a28a33dce Mon Sep 17 00:00:00 2001 +Message-Id: <72dcd3588774126e8769034847dd676a28a33dce.1628630682.git.osandov@fb.com> +From: Omar Sandoval +Date: Tue, 10 Aug 2021 23:24:38 +0200 +Subject: [PATCH] Require --clowntown for quota enable + +--- + cmds/quota.c | 35 ++++++++++++++++++++++++++++++----- + 1 file changed, 30 insertions(+), 5 deletions(-) + +diff --git a/cmds/quota.c b/cmds/quota.c +index 246dd277..07380726 100644 +--- a/cmds/quota.c ++++ b/cmds/quota.c +@@ -16,6 +16,7 @@ + * Boston, MA 021110-1307, USA. + */ + ++#include + #include + #include + +@@ -36,11 +37,11 @@ static int quota_ctl(int cmd, int argc, char **argv) + { + int ret = 0; + int fd; +- char *path = argv[1]; ++ char *path = argv[optind]; + struct btrfs_ioctl_quota_ctl_args args; + DIR *dirstream = NULL; + +- if (check_argc_exact(argc, 2)) ++ if (check_argc_exact(argc - optind, 1)) + return -1; + + memset(&args, 0, sizeof(args)); +@@ -60,8 +61,11 @@ static int quota_ctl(int cmd, int argc, char **argv) + } + + static const char * const cmd_quota_enable_usage[] = { +- "btrfs quota enable ", ++ "btrfs quota enable --clowntown ", + "Enable subvolume quota support for a filesystem.", ++ "FB-ONLY: Btrfs quotas are not supported at Facebook, so you must use", ++ "the --clowntown flag to enable quotas.", ++ "", + "Any data already present on the filesystem will not count towards", + "the space usage numbers. It is recommended to enable quota for a", + "filesystem before writing any data to it.", +@@ -71,10 +75,31 @@ static const char * const cmd_quota_enable_usage[] = { + static int cmd_quota_enable(const struct cmd_struct *cmd, int argc, char **argv) + { + int ret; ++ bool clowntown = false; + +- clean_args_no_options(cmd, argc, argv); ++ optind = 0; ++ while (1) { ++ int c; ++ static const struct option long_options[] = { ++ { "clowntown", no_argument, NULL, 'c'}, ++ { NULL, 0, NULL, 0 } ++ }; ++ c = getopt_long(argc, argv, "", long_options, NULL); ++ if (c < 0) ++ break; ++ switch (c) { ++ case 'c': ++ clowntown = true; ++ break; ++ default: ++ usage(cmd); ++ } ++ } + +- ret = quota_ctl(BTRFS_QUOTA_CTL_ENABLE, argc, argv); ++ if (clowntown) ++ ret = quota_ctl(BTRFS_QUOTA_CTL_ENABLE, argc, argv); ++ else ++ ret = -1; + + if (ret < 0) + usage(cmd); +-- +2.31.1 + diff --git a/SPECS/btrfs-progs.spec b/SPECS/btrfs-progs.spec index 023843c..d249dba 100644 --- a/SPECS/btrfs-progs.spec +++ b/SPECS/btrfs-progs.spec @@ -15,6 +15,9 @@ Source2: gpgkey-F2B41200C54EFB30380C1756C565D5F9D76D583B.gpg # Patches not for upstream (1000-1400) Patch1001: 1001-balance-mkfs-Disable-raid56-modes.patch +%if 0%{?facebook} +Patch1101: 1101-Require-clowntown-for-quota-enable.patch +%endif BuildRequires: gnupg2 BuildRequires: gcc, autoconf, automake, make @@ -147,6 +150,7 @@ popd %changelog * Tue Aug 10 2021 Omar Sandoval - 5.13.1-1 - Update to 5.13.1 for CentOS Hyperscale +- Add Facebook-only patch to require extra flag for quota enable * Fri Jul 30 2021 Neal Gompa - 5.13.1-1 - Update to 5.13.1