diff --git a/debugfs-Fix-headers-for-quota-commands.patch b/debugfs-Fix-headers-for-quota-commands.patch new file mode 100644 index 0000000..433c183 --- /dev/null +++ b/debugfs-Fix-headers-for-quota-commands.patch @@ -0,0 +1,81 @@ +From bdcd8e7bbc374e28fa699031ad2dd83ed4bc70b4 Mon Sep 17 00:00:00 2001 +From: Jan Kara +Date: Mon, 23 Aug 2021 16:44:25 +0200 +Subject: [PATCH 7/8] debugfs: Fix headers for quota commands +X-Developer-Signature: v=1; a=openpgp-sha256; l=4088; h=from:subject; + bh=DMtVDsyxwY63aIschGhsYoFtaRzgKdcoj+H6ag3wBwA=; + b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBhI8GmjMKrGf+RnVrgOxdjhO+t478ULkN2q+GNTt0j + Guy1xK+JATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCYSPBpgAKCRCcnaoHP2RA2QAlB/ + 9TcSu83oYIMfsnjdrDQJRJLdaWiCSP5A5IET00b2JGlqWkSjTLUhcJUHPWq5ZB9q2hLp8z4V4DoTBT + dsDPDPqSS6PmG5jdbjU29Gz/iOmUSnNl1IDCHhO/HJwg5DA+fbwpIC1tbNfw6XpvvqpTi6yYJ6B1LP + byj3D2PLrvqQDtoxc+V90n59U/irl9HqVh6BJOBlhyYvOdbAkvunt6LIsQZvuVmjcpL+TYhcI+S6Ey + fkyC3hebYfeKTg/ZQunW3bJkhso+XRQqUPGDTU393G3SFn5lywV2pMhhupdW7Rek0BjymcqDEqyhDS + VRa3oN+/KSiVWg1qy2JAM+ErlZu5fU +X-Developer-Key: i=jack@suse.cz; a=openpgp; + fpr=93C6099A142276A28BBE35D815BC833443038D8C + +list_quota and get_quota commands have 'blocks' header while what they +actually show is a used space in bytes. Fix the header to state 'space' +instead. + +Signed-off-by: Jan Kara +--- + debugfs/quota.c | 4 ++-- + tests/f_orphquot/expect | 4 ++-- + tests/f_quota/expect.0 | 12 ++++++------ + 3 files changed, 10 insertions(+), 10 deletions(-) + +Index: e2fsprogs-1.46.4/debugfs/quota.c +=================================================================== +--- e2fsprogs-1.46.4.orig/debugfs/quota.c ++++ e2fsprogs-1.46.4/debugfs/quota.c +@@ -123,7 +123,7 @@ void do_list_quota(int argc, char *argv[ + + printf("%7s %2s %8s %8s %8s %8s %8s %8s\n", + quota_type[type], "id", +- "blocks", "quota", "limit", "inodes", "quota", "limit"); ++ "space", "quota", "limit", "inodes", "quota", "limit"); + qh = current_qctx->quota_file[type]; + retval = qh->qh_ops->scan_dquots(qh, list_quota_callback, NULL); + if (retval) { +@@ -158,7 +158,7 @@ void do_get_quota(int argc, char *argv[] + + printf("%7s %2s %8s %8s %8s %8s %8s %8s\n", + quota_type[type], "id", +- "blocks", "quota", "limit", "inodes", "quota", "limit"); ++ "space", "quota", "limit", "inodes", "quota", "limit"); + + qh = current_qctx->quota_file[type]; + +Index: e2fsprogs-1.46.4/tests/f_quota/expect.0 +=================================================================== +--- e2fsprogs-1.46.4.orig/tests/f_quota/expect.0 ++++ e2fsprogs-1.46.4/tests/f_quota/expect.0 +@@ -1,21 +1,21 @@ + debugfs: list_quota user +- user id blocks quota limit inodes quota limit ++ user id space quota limit inodes quota limit + 0 13312 0 0 2 0 0 + 34 1024 0 0 1 0 0 + 100 2048 32 50 2 20 30 + debugfs: list_quota group +- group id blocks quota limit inodes quota limit ++ group id space quota limit inodes quota limit + 0 16384 0 0 5 0 0 + debugfs: get_quota user 0 +- user id blocks quota limit inodes quota limit ++ user id space quota limit inodes quota limit + 0 13312 0 0 2 0 0 + debugfs: get_quota user 100 +- user id blocks quota limit inodes quota limit ++ user id space quota limit inodes quota limit + 100 2048 32 50 2 20 30 + debugfs: get_quota user 34 +- user id blocks quota limit inodes quota limit ++ user id space quota limit inodes quota limit + 34 1024 0 0 1 0 0 + debugfs: get_quota group 0 +- group id blocks quota limit inodes quota limit ++ group id space quota limit inodes quota limit + 0 16384 0 0 5 0 0 + debugfs: diff --git a/e2fsck-Do-not-trash-user-limits-when-processing-orph.patch b/e2fsck-Do-not-trash-user-limits-when-processing-orph.patch new file mode 100644 index 0000000..b8b0b70 --- /dev/null +++ b/e2fsck-Do-not-trash-user-limits-when-processing-orph.patch @@ -0,0 +1,43 @@ +From 1f3a91cf868ededb19b3b37caa3352f67e66a10a Mon Sep 17 00:00:00 2001 +From: Jan Kara +Date: Mon, 23 Aug 2021 17:04:52 +0200 +Subject: [PATCH 5/8] e2fsck: Do not trash user limits when processing orphan + list +X-Developer-Signature: v=1; a=openpgp-sha256; l=770; h=from:subject; + bh=qzGpt7+UOJv3hwzSLcLGr0hCRSh47K/myPGChyylU8U=; + b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBhI8GlX5hq3rRf6HziKT8bgW4lwXuVz7w+FuGOUcPK + Xw3NgfGJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCYSPBpQAKCRCcnaoHP2RA2R2qCA + DhX7BXpS8G05CmyapN9NiAu63JaSVW4o084uvfnud8EdFUMXbOkwGndcOty1Uk09HXfvVkeaZVTmkv + pVfz8s4Vi/vjqCPOkxo7HiElNKlm/s/yCGP05ByfwhCqCXKKoaODsbMZJHz4bpUbfxo+qcBD1C0XuE + tYgIzL35Jo0rJA65NyBao65L1jTDw4EZGykaYszfZjPayimYg3z2wl0Kv6qT+niYmOw+6w43O6b+6L + vgIv8E0XTR0Pc0/JGhfydCSqYM+zoJXpcuURhap0hIo+j3x8FvRGu5ws5tM5Nw0dLmm/MqiDxfBSdA + VYBJ83ewrnLu//5q0Kljfxo6T3qN4W +X-Developer-Key: i=jack@suse.cz; a=openpgp; + fpr=93C6099A142276A28BBE35D815BC833443038D8C + +When e2fsck was loading quotas to process orphan list, it was loading +only quota usage. However subsequent quota writeout has effectively +overwritten quota limits, loosing them forever. Make sure quota limits +are preserved over orphan replay. + +Signed-off-by: Jan Kara +--- + e2fsck/super.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/e2fsck/super.c b/e2fsck/super.c +index 75b7b8ffa9b6..4ffafb211e50 100644 +--- a/e2fsck/super.c ++++ b/e2fsck/super.c +@@ -282,7 +282,7 @@ static errcode_t e2fsck_read_all_quotas(e2fsck_t ctx) + continue; + + retval = quota_read_all_dquots(ctx->qctx, qf_ino, qtype, +- QREAD_USAGE); ++ QREAD_USAGE | QREAD_LIMITS); + if (retval) + break; + } +-- +2.26.2 + diff --git a/e2fsprogs.changes b/e2fsprogs.changes index 8e73f19..5568cd2 100644 --- a/e2fsprogs.changes +++ b/e2fsprogs.changes @@ -1,3 +1,22 @@ +------------------------------------------------------------------- +Thu Sep 30 14:13:06 UTC 2021 - Jan Kara + +- quota-Add-support-to-version-0-quota-format.patch: quota: Add support to + version 0 quota format (jsc#SLE-17360) + quota-Fold-quota_read_all_dquots-into-quota_update_l.patch: quota: Fold + quota_read_all_dquots() into quota_update_limits() (jsc#SLE-17360) + quota-Rename-quota_update_limits-to-quota_read_all_d.patch: quota: Rename + quota_update_limits() to quota_read_all_dquots() (jsc#SLE-17360) + tune2fs-Fix-conversion-of-quota-files.patch: tune2fs: Fix conversion of quota + files (jsc#SLE-17360) + e2fsck-Do-not-trash-user-limits-when-processing-orph.patch: e2fsck: Do not + trash user limits when processing orphan list (jsc#SLE-17360) + debugfs-Fix-headers-for-quota-commands.patch: debugfs: Fix headers for quota + commands (jsc#SLE-17360) + quota-Drop-dead-code.patch: quota: Drop dead code (jsc#SLE-17360) +- add these not yet released fixes to e2fsprogs package so that SLE15-SP4 ships + with them + ------------------------------------------------------------------- Wed Sep 15 09:16:54 UTC 2021 - Jan Kara diff --git a/e2fsprogs.spec b/e2fsprogs.spec index 386ac32..9e921ce 100644 --- a/e2fsprogs.spec +++ b/e2fsprogs.spec @@ -94,6 +94,13 @@ Patch7: harden_e2scrub_all.service.patch Patch8: harden_e2scrub_fail@.service.patch Patch9: harden_e2scrub_reap.service.patch Patch10: libss-add-newer-libreadline.so.8-to-dlopen-path.patch +Patch11: quota-Add-support-to-version-0-quota-format.patch +Patch12: quota-Fold-quota_read_all_dquots-into-quota_update_l.patch +Patch13: quota-Rename-quota_update_limits-to-quota_read_all_d.patch +Patch14: tune2fs-Fix-conversion-of-quota-files.patch +Patch15: e2fsck-Do-not-trash-user-limits-when-processing-orph.patch +Patch16: debugfs-Fix-headers-for-quota-commands.patch +Patch17: quota-Drop-dead-code.patch # Do not suppress make commands BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -263,6 +270,13 @@ cp %{SOURCE2} . %patch8 -p1 %patch9 -p1 %patch10 -p1 +%patch11 -p1 +%patch12 -p1 +%patch13 -p1 +%patch14 -p1 +%patch15 -p1 +%patch16 -p1 +%patch17 -p1 %build %global _lto_cflags %{_lto_cflags} -ffat-lto-objects diff --git a/quota-Add-support-to-version-0-quota-format.patch b/quota-Add-support-to-version-0-quota-format.patch new file mode 100644 index 0000000..70977fb --- /dev/null +++ b/quota-Add-support-to-version-0-quota-format.patch @@ -0,0 +1,188 @@ +From cb060896aac2207ea77479db2e2212ebe7955de9 Mon Sep 17 00:00:00 2001 +From: Jan Kara +Date: Fri, 20 Aug 2021 21:18:32 +0200 +Subject: [PATCH 1/8] quota: Add support to version 0 quota format +X-Developer-Signature: v=1; a=openpgp-sha256; l=6268; h=from:subject; + bh=UhE03jWwtF7/2Unh5tfHgBCzzdLaSNZ7G9C22vuq4H4=; + b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBhI8GhrizE8ehds+qrTxuX1OCIKL+zMflZgbZ3qOb5 + 4X5jnt+JATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCYSPBoQAKCRCcnaoHP2RA2dHMCA + CzR/VySs+XXZrCsUYOO3oUzFueRoSJnOAuAUONScP8h7x8fH7wclET0eU/ZGDTMFPrhSIAWjqqwfI8 + zeFGmbi4GR5BRbsxWNCJnmjwtbxHfOiXsH8KLqT8DyLFl/Svw4yHi9URyIKk4rij2q9AqmA1DTc5M6 + iMHejidF5w4SbKSmvVYpJi1Ny/TyWXUU9ATzZv01cwjBnMsTw+xq3MD55K9VVZJ9tIF3YZd0PahiT0 + h/zKA7uQX6W3PKWVuTHkSzjUnsOhKMCX9MxMX6uGXzHBiUsqdCSijVQ6qwBmbwbbz5OZRBRdTfm+0X + 6fJidGzi6Zcpp/jOs8RIOSu55qCTAb +X-Developer-Key: i=jack@suse.cz; a=openpgp; + fpr=93C6099A142276A28BBE35D815BC833443038D8C + +Version 0 quota format differs from version 1 by having only 32-bit +counters for inodes and block limits. For many installations this is not +limiting and thus the format is widely used. Also quota tools still +create quota files with this format by default. Add support for this +quota format to e2fsprogs so that we can seamlessly convert quota files +in this format into our internal quota files. + +Signed-off-by: Jan Kara +--- + lib/support/quotaio_v2.c | 85 +++++++++++++++++++++++++++++++++++++--- + lib/support/quotaio_v2.h | 17 +++++++- + 2 files changed, 96 insertions(+), 6 deletions(-) + +diff --git a/lib/support/quotaio_v2.c b/lib/support/quotaio_v2.c +index 23717f03f428..a49aa6ac8c2f 100644 +--- a/lib/support/quotaio_v2.c ++++ b/lib/support/quotaio_v2.c +@@ -41,6 +41,68 @@ struct quotafile_ops quotafile_ops_2 = { + .report = v2_report, + }; + ++/* ++ * Copy dquot from disk to memory ++ */ ++static void v2r0_disk2memdqblk(struct dquot *dquot, void *dp) ++{ ++ struct util_dqblk *m = &dquot->dq_dqb; ++ struct v2r0_disk_dqblk *d = dp, empty; ++ ++ dquot->dq_id = ext2fs_le32_to_cpu(d->dqb_id); ++ m->dqb_ihardlimit = ext2fs_le32_to_cpu(d->dqb_ihardlimit); ++ m->dqb_isoftlimit = ext2fs_le32_to_cpu(d->dqb_isoftlimit); ++ m->dqb_bhardlimit = ext2fs_le32_to_cpu(d->dqb_bhardlimit); ++ m->dqb_bsoftlimit = ext2fs_le32_to_cpu(d->dqb_bsoftlimit); ++ m->dqb_curinodes = ext2fs_le32_to_cpu(d->dqb_curinodes); ++ m->dqb_curspace = ext2fs_le64_to_cpu(d->dqb_curspace); ++ m->dqb_itime = ext2fs_le64_to_cpu(d->dqb_itime); ++ m->dqb_btime = ext2fs_le64_to_cpu(d->dqb_btime); ++ ++ memset(&empty, 0, sizeof(struct v2r0_disk_dqblk)); ++ empty.dqb_itime = ext2fs_cpu_to_le64(1); ++ if (!memcmp(&empty, dp, sizeof(struct v2r0_disk_dqblk))) ++ m->dqb_itime = 0; ++} ++ ++/* ++ * Copy dquot from memory to disk ++ */ ++static void v2r0_mem2diskdqblk(void *dp, struct dquot *dquot) ++{ ++ struct util_dqblk *m = &dquot->dq_dqb; ++ struct v2r0_disk_dqblk *d = dp; ++ ++ d->dqb_ihardlimit = ext2fs_cpu_to_le32(m->dqb_ihardlimit); ++ d->dqb_isoftlimit = ext2fs_cpu_to_le32(m->dqb_isoftlimit); ++ d->dqb_bhardlimit = ext2fs_cpu_to_le32(m->dqb_bhardlimit); ++ d->dqb_bsoftlimit = ext2fs_cpu_to_le32(m->dqb_bsoftlimit); ++ d->dqb_curinodes = ext2fs_cpu_to_le32(m->dqb_curinodes); ++ d->dqb_curspace = ext2fs_cpu_to_le64(m->dqb_curspace); ++ d->dqb_itime = ext2fs_cpu_to_le64(m->dqb_itime); ++ d->dqb_btime = ext2fs_cpu_to_le64(m->dqb_btime); ++ d->dqb_id = ext2fs_cpu_to_le32(dquot->dq_id); ++ if (qtree_entry_unused(&dquot->dq_h->qh_info.u.v2_mdqi.dqi_qtree, dp)) ++ d->dqb_itime = ext2fs_cpu_to_le64(1); ++} ++ ++static int v2r0_is_id(void *dp, struct dquot *dquot) ++{ ++ struct v2r0_disk_dqblk *d = dp; ++ struct qtree_mem_dqinfo *info = ++ &dquot->dq_h->qh_info.u.v2_mdqi.dqi_qtree; ++ ++ if (qtree_entry_unused(info, dp)) ++ return 0; ++ return ext2fs_le32_to_cpu(d->dqb_id) == dquot->dq_id; ++} ++ ++static struct qtree_fmt_operations v2r0_fmt_ops = { ++ .mem2disk_dqblk = v2r0_mem2diskdqblk, ++ .disk2mem_dqblk = v2r0_disk2memdqblk, ++ .is_id = v2r0_is_id, ++}; ++ + /* + * Copy dquot from disk to memory + */ +@@ -164,7 +226,8 @@ static int v2_check_file(struct quota_handle *h, int type, int fmt) + log_err("Your quota file is stored in wrong endianity"); + return 0; + } +- if (V2_VERSION != ext2fs_le32_to_cpu(dqh.dqh_version)) ++ if (V2_VERSION_R0 != ext2fs_le32_to_cpu(dqh.dqh_version) && ++ V2_VERSION_R1 != ext2fs_le32_to_cpu(dqh.dqh_version)) + return 0; + return 1; + } +@@ -174,13 +237,25 @@ static int v2_check_file(struct quota_handle *h, int type, int fmt) + */ + static int v2_init_io(struct quota_handle *h) + { ++ struct v2_disk_dqheader dqh; + struct v2_disk_dqinfo ddqinfo; + struct v2_mem_dqinfo *info; + __u64 filesize; ++ int version; + +- h->qh_info.u.v2_mdqi.dqi_qtree.dqi_entry_size = +- sizeof(struct v2r1_disk_dqblk); +- h->qh_info.u.v2_mdqi.dqi_qtree.dqi_ops = &v2r1_fmt_ops; ++ if (!v2_read_header(h, &dqh)) ++ return -1; ++ version = ext2fs_le32_to_cpu(dqh.dqh_version); ++ ++ if (version == V2_VERSION_R0) { ++ h->qh_info.u.v2_mdqi.dqi_qtree.dqi_entry_size = ++ sizeof(struct v2r0_disk_dqblk); ++ h->qh_info.u.v2_mdqi.dqi_qtree.dqi_ops = &v2r0_fmt_ops; ++ } else { ++ h->qh_info.u.v2_mdqi.dqi_qtree.dqi_entry_size = ++ sizeof(struct v2r1_disk_dqblk); ++ h->qh_info.u.v2_mdqi.dqi_qtree.dqi_ops = &v2r1_fmt_ops; ++ } + + /* Read information about quotafile */ + if (h->e2fs_read(&h->qh_qf, V2_DQINFOOFF, &ddqinfo, +@@ -231,7 +306,7 @@ static int v2_new_io(struct quota_handle *h) + + /* Write basic quota header */ + ddqheader.dqh_magic = ext2fs_cpu_to_le32(file_magics[h->qh_type]); +- ddqheader.dqh_version = ext2fs_cpu_to_le32(V2_VERSION); ++ ddqheader.dqh_version = ext2fs_cpu_to_le32(V2_VERSION_R1); + if (h->e2fs_write(&h->qh_qf, 0, &ddqheader, sizeof(ddqheader)) != + sizeof(ddqheader)) + return -1; +diff --git a/lib/support/quotaio_v2.h b/lib/support/quotaio_v2.h +index de2db2785cb0..35054cafaa23 100644 +--- a/lib/support/quotaio_v2.h ++++ b/lib/support/quotaio_v2.h +@@ -13,7 +13,8 @@ + /* Offset of info header in file */ + #define V2_DQINFOOFF sizeof(struct v2_disk_dqheader) + /* Supported version of quota-tree format */ +-#define V2_VERSION 1 ++#define V2_VERSION_R1 1 ++#define V2_VERSION_R0 0 + + struct v2_disk_dqheader { + __le32 dqh_magic; /* Magic number identifying file */ +@@ -36,6 +37,20 @@ struct v2_disk_dqinfo { + * free entry */ + } __attribute__ ((packed)); + ++struct v2r0_disk_dqblk { ++ __le32 dqb_id; /* id this quota applies to */ ++ __le32 dqb_ihardlimit; /* absolute limit on allocated inodes */ ++ __le32 dqb_isoftlimit; /* preferred inode limit */ ++ __le32 dqb_curinodes; /* current # allocated inodes */ ++ __le32 dqb_bhardlimit; /* absolute limit on disk space ++ * (in QUOTABLOCK_SIZE) */ ++ __le32 dqb_bsoftlimit; /* preferred limit on disk space ++ * (in QUOTABLOCK_SIZE) */ ++ __le64 dqb_curspace; /* current space occupied (in bytes) */ ++ __le64 dqb_btime; /* time limit for excessive disk use */ ++ __le64 dqb_itime; /* time limit for excessive inode use */ ++} __attribute__ ((packed)); ++ + struct v2r1_disk_dqblk { + __le32 dqb_id; /* id this quota applies to */ + __le32 dqb_pad; +-- +2.26.2 + diff --git a/quota-Drop-dead-code.patch b/quota-Drop-dead-code.patch new file mode 100644 index 0000000..583338f --- /dev/null +++ b/quota-Drop-dead-code.patch @@ -0,0 +1,57 @@ +From 32d9f7b1e48f203315890b4d7374f4afd68ce7bb Mon Sep 17 00:00:00 2001 +From: Jan Kara +Date: Mon, 23 Aug 2021 17:09:41 +0200 +Subject: [PATCH 8/8] quota: Drop dead code +X-Developer-Signature: v=1; a=openpgp-sha256; l=1119; h=from:subject; + bh=61dKtjVKi3diCfHpa1/d4uDj1elmJCEY1fKv83UzzKA=; + b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBhI8GnVlsRAgEc7AzGwJddaA7LDt33ZX+Yj9rady7y + 42St04GJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCYSPBpwAKCRCcnaoHP2RA2aBMCA + COK2Z3O7gobEnW9GHL1bd1MlJOqsYxPxnOp3rFCkB4Kb6V770XUoCCnyeD7NwNxooWZSNOB7JCuyGQ + Yl945dec75Yv8zw49bulfVe496hHFX4O4UzAgZKG0vZYAjHpwaEk9Txf3MLpSHxSFlvbH8LE4sT7yD + M4wEEznUZokwwRoj+ds12+Rm+P1Sj/AhghUTaPFpuA5RjplBAg728b9f6Ia2JMsNzxoBRksVdOONjU + 2gtjwbR7Ne2GlN722u71YHItAL0sBAVPIHZQznZEKAZFwEnOHSRWlvwLItLdMfpoMcYXjDJIWz+mXx + QbpFU9jSQfiJBn+wba2yVZKohLP403 +X-Developer-Key: i=jack@suse.cz; a=openpgp; + fpr=93C6099A142276A28BBE35D815BC833443038D8C + +Drop unused function from quota support code. + +Signed-off-by: Jan Kara +--- + lib/support/mkquota.c | 20 -------------------- + 1 file changed, 20 deletions(-) + +diff --git a/lib/support/mkquota.c b/lib/support/mkquota.c +index 0fefca90c843..a4401b7f77af 100644 +--- a/lib/support/mkquota.c ++++ b/lib/support/mkquota.c +@@ -564,26 +564,6 @@ static int scan_dquots_callback(struct dquot *dquot, void *cb_data) + return 0; + } + +-/* +- * Write all memory dquots into quota file +- */ +-#if 0 /* currently unused, but may be useful in the future? */ +-static errcode_t quota_write_all_dquots(struct quota_handle *qh, +- quota_ctx_t qctx) +-{ +- errcode_t err; +- +- err = ext2fs_read_bitmaps(qctx->fs); +- if (err) +- return err; +- write_dquots(qctx->quota_dict[qh->qh_type], qh); +- ext2fs_mark_bb_dirty(qctx->fs); +- qctx->fs->flags &= ~EXT2_FLAG_SUPER_ONLY; +- ext2fs_write_bitmaps(qctx->fs); +- return 0; +-} +-#endif +- + /* + * Read quotas from disk and updates the in-memory information determined by + * 'flags' from the on-disk data. +-- +2.26.2 + diff --git a/quota-Fold-quota_read_all_dquots-into-quota_update_l.patch b/quota-Fold-quota_read_all_dquots-into-quota_update_l.patch new file mode 100644 index 0000000..98f1224 --- /dev/null +++ b/quota-Fold-quota_read_all_dquots-into-quota_update_l.patch @@ -0,0 +1,77 @@ +From cbc02e7ef11d5129d090ff49aa1aa57c6ac67fd5 Mon Sep 17 00:00:00 2001 +From: Jan Kara +Date: Mon, 23 Aug 2021 16:20:52 +0200 +Subject: [PATCH 2/8] quota: Fold quota_read_all_dquots() into + quota_update_limits() +X-Developer-Signature: v=1; a=openpgp-sha256; l=1845; h=from:subject; + bh=P7jQb3ZXNuPWs0M0khNUm88nO2ChkOKzT3PGfFt2YNE=; + b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBhI8GihdgOLrTUGvgyKLo/9lHgsSXNpuX+TjVHdW+m + 661Y0fGJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCYSPBogAKCRCcnaoHP2RA2aEPB/ + 9zdPkcMlJKxGzpEO0BmaBNu0c3VbFZR72otTj64Pm1AWxyU9PL288d+VnPov7WSeduPBKtXxmevxAw + tR0TYFt4ui8Gr7HLMoTvP7EJ3YX/KZ2mnXnz9JJ5DB2fG07VBbKmcfPKzsxYTUd0Xe5RJU0PYPI62W + j8W17jQelcHCNhAJk6oJFP7hPE+dsGUzGthbeQhWrb5zmboB/Ui55mfM1mLaloebpJkg1eqEZzX1jE + 6T9iEfBSgv5WowKIfJInnXkI+l4UED+Ri1pjuFgBtpWjJEP8ixpFhlo0ULZxfK/OX9sFWQU+Z+opoM + Qi0W7Fbb7hR7YZP84xnIbF1FUgHa+l +X-Developer-Key: i=jack@suse.cz; a=openpgp; + fpr=93C6099A142276A28BBE35D815BC833443038D8C + +There's just one caller of quota_read_all_dquots(), fold it into its +caller quota_update_limits(). No functional changes. + +Signed-off-by: Jan Kara +--- + lib/support/mkquota.c | 24 ++++++------------------ + 1 file changed, 6 insertions(+), 18 deletions(-) + +diff --git a/lib/support/mkquota.c b/lib/support/mkquota.c +index fbc3833aee98..8e5c61a601cc 100644 +--- a/lib/support/mkquota.c ++++ b/lib/support/mkquota.c +@@ -564,23 +564,6 @@ static int scan_dquots_callback(struct dquot *dquot, void *cb_data) + return 0; + } + +-/* +- * Read all dquots from quota file into memory +- */ +-static errcode_t quota_read_all_dquots(struct quota_handle *qh, +- quota_ctx_t qctx, +- int update_limits EXT2FS_ATTR((unused))) +-{ +- struct scan_dquots_data scan_data; +- +- scan_data.quota_dict = qctx->quota_dict[qh->qh_type]; +- scan_data.check_consistency = 0; +- scan_data.update_limits = 0; +- scan_data.update_usage = 1; +- +- return qh->qh_ops->scan_dquots(qh, scan_dquots_callback, &scan_data); +-} +- + /* + * Write all memory dquots into quota file + */ +@@ -607,6 +590,7 @@ static errcode_t quota_write_all_dquots(struct quota_handle *qh, + errcode_t quota_update_limits(quota_ctx_t qctx, ext2_ino_t qf_ino, + enum quota_type qtype) + { ++ struct scan_dquots_data scan_data; + struct quota_handle *qh; + errcode_t err; + +@@ -625,7 +609,11 @@ errcode_t quota_update_limits(quota_ctx_t qctx, ext2_ino_t qf_ino, + goto out; + } + +- quota_read_all_dquots(qh, qctx, 1); ++ scan_data.quota_dict = qctx->quota_dict[qh->qh_type]; ++ scan_data.check_consistency = 0; ++ scan_data.update_limits = 0; ++ scan_data.update_usage = 1; ++ qh->qh_ops->scan_dquots(qh, scan_dquots_callback, &scan_data); + + err = quota_file_close(qctx, qh); + if (err) { +-- +2.26.2 + diff --git a/quota-Rename-quota_update_limits-to-quota_read_all_d.patch b/quota-Rename-quota_update_limits-to-quota_read_all_d.patch new file mode 100644 index 0000000..2611108 --- /dev/null +++ b/quota-Rename-quota_update_limits-to-quota_read_all_d.patch @@ -0,0 +1,112 @@ +From f2a7403c6e232aa8dba92d56178d81ba8285fa65 Mon Sep 17 00:00:00 2001 +From: Jan Kara +Date: Mon, 23 Aug 2021 16:32:13 +0200 +Subject: [PATCH 3/8] quota: Rename quota_update_limits() to + quota_read_all_dquots() +X-Developer-Signature: v=1; a=openpgp-sha256; l=3796; h=from:subject; + bh=EWzfurjfbAs2HTtmIoM8glu+EY0nvkRwYkafyLH0vAw=; + b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBhI8GjQ7OLyPGH5e21pa5vzRbAJrBUX2fqN9Cishyr + zRhheaOJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCYSPBowAKCRCcnaoHP2RA2fqAB/ + 99OFSOi1posHQs9IivQagLwUAxytNoe9VWRoUqypcx5DFtbSItNlcyRCRxmouxUdpTyWR3BoYfDz97 + /R2KsPNu9XU6oA2NiC7WcmNdSJ0ay+sRuXy2EF5FxCvXjB4xN7pUu7QEEjcQXOYOwIsdEDQru+eajq + NK05uq6j0Zb/zelJ9VkTA0iKkiCkKGNYZlCUkn3x+E8wTb4RCbywnAynC6RXFlmt+EnaxxHoGCsJGv + TLIe+yhPDECdjW39RZWYV87fRRGDRiVnuDFR0uj0QRFY1unELcy+Z72lySrH9X3SZl9VB72WKvofFb + Ar8ofkj4dd4g8RTr9WRC+h9b1kwnNk +X-Developer-Key: i=jack@suse.cz; a=openpgp; + fpr=93C6099A142276A28BBE35D815BC833443038D8C + +quota_update_limits() is a misnomer because what it actually does is +that it updates 'usage' counters and leaves 'limit' counters intact. +Rename quota_update_limits() to quota_read_all_dquots() and while +changing prototype also add a flags argument so that callers can control +which quota information is actually updated from the disk. + +Signed-off-by: Jan Kara +--- + e2fsck/super.c | 3 ++- + lib/support/mkquota.c | 11 ++++++----- + lib/support/quotaio.h | 7 +++++-- + misc/tune2fs.c | 5 +++-- + 4 files changed, 16 insertions(+), 10 deletions(-) + +diff --git a/e2fsck/super.c b/e2fsck/super.c +index e1c3f93572f4..75b7b8ffa9b6 100644 +--- a/e2fsck/super.c ++++ b/e2fsck/super.c +@@ -281,7 +281,8 @@ static errcode_t e2fsck_read_all_quotas(e2fsck_t ctx) + if (qf_ino == 0) + continue; + +- retval = quota_update_limits(ctx->qctx, qf_ino, qtype); ++ retval = quota_read_all_dquots(ctx->qctx, qf_ino, qtype, ++ QREAD_USAGE); + if (retval) + break; + } +diff --git a/lib/support/mkquota.c b/lib/support/mkquota.c +index 8e5c61a601cc..0fefca90c843 100644 +--- a/lib/support/mkquota.c ++++ b/lib/support/mkquota.c +@@ -585,10 +585,11 @@ static errcode_t quota_write_all_dquots(struct quota_handle *qh, + #endif + + /* +- * Updates the in-memory quota limits from the given quota inode. ++ * Read quotas from disk and updates the in-memory information determined by ++ * 'flags' from the on-disk data. + */ +-errcode_t quota_update_limits(quota_ctx_t qctx, ext2_ino_t qf_ino, +- enum quota_type qtype) ++errcode_t quota_read_all_dquots(quota_ctx_t qctx, ext2_ino_t qf_ino, ++ enum quota_type qtype, unsigned int flags) + { + struct scan_dquots_data scan_data; + struct quota_handle *qh; +@@ -611,8 +612,8 @@ errcode_t quota_update_limits(quota_ctx_t qctx, ext2_ino_t qf_ino, + + scan_data.quota_dict = qctx->quota_dict[qh->qh_type]; + scan_data.check_consistency = 0; +- scan_data.update_limits = 0; +- scan_data.update_usage = 1; ++ scan_data.update_limits = !!(flags & QREAD_LIMITS); ++ scan_data.update_usage = !!(flags & QREAD_USAGE); + qh->qh_ops->scan_dquots(qh, scan_dquots_callback, &scan_data); + + err = quota_file_close(qctx, qh); +diff --git a/lib/support/quotaio.h b/lib/support/quotaio.h +index 6068970009f5..84fac35dda20 100644 +--- a/lib/support/quotaio.h ++++ b/lib/support/quotaio.h +@@ -224,8 +224,11 @@ void quota_data_add(quota_ctx_t qctx, struct ext2_inode_large *inode, + void quota_data_sub(quota_ctx_t qctx, struct ext2_inode_large *inode, + ext2_ino_t ino, qsize_t space); + errcode_t quota_write_inode(quota_ctx_t qctx, enum quota_type qtype); +-errcode_t quota_update_limits(quota_ctx_t qctx, ext2_ino_t qf_ino, +- enum quota_type type); ++/* Flags for quota_read_all_dquots() */ ++#define QREAD_USAGE 0x01 ++#define QREAD_LIMITS 0x02 ++errcode_t quota_read_all_dquots(quota_ctx_t qctx, ext2_ino_t qf_ino, ++ enum quota_type type, unsigned int flags); + errcode_t quota_compute_usage(quota_ctx_t qctx); + void quota_release_context(quota_ctx_t *qctx); + errcode_t quota_remove_inode(ext2_filsys fs, enum quota_type qtype); +diff --git a/misc/tune2fs.c b/misc/tune2fs.c +index f739f16cd62b..bb08f8026918 100644 +--- a/misc/tune2fs.c ++++ b/misc/tune2fs.c +@@ -1671,8 +1671,9 @@ static int handle_quota_options(ext2_filsys fs) + if (quota_enable[qtype] == QOPT_ENABLE && + *quota_sb_inump(fs->super, qtype) == 0) { + if ((qf_ino = quota_file_exists(fs, qtype)) > 0) { +- retval = quota_update_limits(qctx, qf_ino, +- qtype); ++ retval = quota_read_all_dquots(qctx, qf_ino, ++ qtype, ++ QREAD_USAGE); + if (retval) { + com_err(program_name, retval, + _("while updating quota limits (%d)"), +-- +2.26.2 + diff --git a/tune2fs-Fix-conversion-of-quota-files.patch b/tune2fs-Fix-conversion-of-quota-files.patch new file mode 100644 index 0000000..058546c --- /dev/null +++ b/tune2fs-Fix-conversion-of-quota-files.patch @@ -0,0 +1,47 @@ +From 5d446b4969ee6cb4025f576158be562c87d57142 Mon Sep 17 00:00:00 2001 +From: Jan Kara +Date: Fri, 20 Aug 2021 21:35:34 +0200 +Subject: [PATCH 4/8] tune2fs: Fix conversion of quota files +X-Developer-Signature: v=1; a=openpgp-sha256; l=1210; h=from:subject; + bh=Lx1UJPZNLgsKBmmbN+0GUP40hOyhJD5D9kEVqqVigg4=; + b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBhI8GkUaN9eZsgn0XvL7BSjbTu57jpbJHkTGpEei61 + KG+q9pGJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCYSPBpAAKCRCcnaoHP2RA2Z7NB/ + 4osbGPQGrmAwHVUJEqkXAxOBazQE/W3qiykm9uUmzeBGC++5nQzo1J05nb479mQY84Lu8j1Mhbloh8 + vtdLdJ0HVHxHQrY058HIXBQfAYlLV0pN6/qRNCVelyjdqQVTjri8oD+TVCjsu4aaTu9ZLZCYM41w5s + gweKqj260PJ93IL025nGha6ZL2BsenQy/tKRG7/I9O/c6YUAFKSvXDJ0M/L4XtgMTKxzROSiKDmy8h + gEw2Gc9oCZLISL2ulhLJ6ppxQ7jcbvoTuZmdFxhbQIfs8gQnmxlGcQLWs5fDMIKfux5qBwQGnYIC1u + jZOGndUvcOaDO3Zexb1ik8pxnpIi+F +X-Developer-Key: i=jack@suse.cz; a=openpgp; + fpr=93C6099A142276A28BBE35D815BC833443038D8C + +When tune2fs is enabling quota feature, it looks for old-style quota +files and tries to transfer limits stored in these files into newly +created hidded quota files. However the code doing the transfer setups +the quota scan wrongly and instead of transferring limits we transfer +usage. So not only quota limits are lost (at least they can still be +recovered from the old quota files) but also usage information may be +wrong if the accounting in e2fsprogs does not exactly match the +accounting in quota-tools (which is actually the case). Fix the setup of +the quota scan. + +Signed-off-by: Jan Kara +--- + misc/tune2fs.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/misc/tune2fs.c b/misc/tune2fs.c +index bb08f8026918..0f6ef3d6df6b 100644 +--- a/misc/tune2fs.c ++++ b/misc/tune2fs.c +@@ -1673,7 +1673,7 @@ static int handle_quota_options(ext2_filsys fs) + if ((qf_ino = quota_file_exists(fs, qtype)) > 0) { + retval = quota_read_all_dquots(qctx, qf_ino, + qtype, +- QREAD_USAGE); ++ QREAD_LIMITS); + if (retval) { + com_err(program_name, retval, + _("while updating quota limits (%d)"), +-- +2.26.2 +