Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/807452/?format=api
{ "id": 807452, "url": "http://patchwork.ozlabs.org/api/patches/807452/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-ext4/patch/1504079245-49002-1-git-send-email-adilger@dilger.ca/", "project": { "id": 8, "url": "http://patchwork.ozlabs.org/api/projects/8/?format=api", "name": "Linux ext4 filesystem development", "link_name": "linux-ext4", "list_id": "linux-ext4.vger.kernel.org", "list_email": "linux-ext4@vger.kernel.org", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<1504079245-49002-1-git-send-email-adilger@dilger.ca>", "list_archive_url": null, "date": "2017-08-30T07:47:24", "name": "[1/2] e2fsck: set dir_nlink feature if large dir exists", "commit_ref": null, "pull_url": null, "state": "new", "archived": true, "hash": "ea20ed378d7ead739dc2b31a5a7b78b36afc3f5c", "submitter": { "id": 4514, "url": "http://patchwork.ozlabs.org/api/people/4514/?format=api", "name": "Andreas Dilger", "email": "adilger@dilger.ca" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/linux-ext4/patch/1504079245-49002-1-git-send-email-adilger@dilger.ca/mbox/", "series": [ { "id": 539, "url": "http://patchwork.ozlabs.org/api/series/539/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-ext4/list/?series=539", "date": "2017-08-30T07:47:24", "name": "[1/2] e2fsck: set dir_nlink feature if large dir exists", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/539/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/807452/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/807452/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<linux-ext4-owner@vger.kernel.org>", "X-Original-To": "patchwork-incoming@ozlabs.org", "Delivered-To": "patchwork-incoming@ozlabs.org", "Authentication-Results": "ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=linux-ext4-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)", "Received": [ "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xhyJx4kQxz9s7F\n\tfor <patchwork-incoming@ozlabs.org>;\n\tWed, 30 Aug 2017 17:47:29 +1000 (AEST)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751318AbdH3Hr2 (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tWed, 30 Aug 2017 03:47:28 -0400", "from smtp-out-so.shaw.ca ([64.59.136.138]:60426 \"EHLO\n\tsmtp-out-so.shaw.ca\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1751186AbdH3Hr1 (ORCPT\n\t<rfc822; linux-ext4@vger.kernel.org>); Wed, 30 Aug 2017 03:47:27 -0400", "from cabot.adilger.int ([70.77.216.213]) by shaw.ca with SMTP\n\tid mxifdH92m8LPZmxigd0UKh; Wed, 30 Aug 2017 01:47:26 -0600" ], "X-Authority-Analysis": "v=2.2 cv=e552ceh/ c=1 sm=1 tr=0\n\ta=BQvS1EmAg2ttxjPVUuc1UQ==:117 a=BQvS1EmAg2ttxjPVUuc1UQ==:17\n\ta=VwQbUJbxAAAA:8\n\ta=RPJ6JBhKAAAA:8 a=IHv0yzR9u9SmF7IoSq4A:9 a=AjGcO6oz07-iQ99wixmX:22\n\ta=fa_un-3J20JGBB2Tu-mn:22", "From": "Andreas Dilger <adilger@dilger.ca>", "To": "tytso@mit.edu", "Cc": "linux-ext4@vger.kernel.org, Andreas Dilger <adilger@dilger.ca>", "Subject": "[PATCH 1/2] e2fsck: set dir_nlink feature if large dir exists", "Date": "Wed, 30 Aug 2017 01:47:24 -0600", "Message-Id": "<1504079245-49002-1-git-send-email-adilger@dilger.ca>", "X-Mailer": "git-send-email 1.8.0", "X-CMAE-Envelope": "MS4wfJR+tm9RHusbC5cbQuoIodHuLiTwKTn+exArO7qAvfwKwzq86Cqk+JsEFkt7VwB0ZbVfJXfsD6Ct8LgA+BNdI5Lch2lgvwUTn8UuoHy6N5PqR7UwACtF\n\tK85UM9IFFkU1jw3/doMNQ7mJpRrHfmymVlvpNl4BERPUDEUVbvzvdFQrM8easTjZBT3nb4M+DRWI6yyw7k4JudbQq2sEHOwguyzSEDhlyba9Sj8fV/v0Soxc", "Sender": "linux-ext4-owner@vger.kernel.org", "Precedence": "bulk", "List-ID": "<linux-ext4.vger.kernel.org>", "X-Mailing-List": "linux-ext4@vger.kernel.org" }, "content": "If there is a directory with more than EXT2_LINK_MAX (65000)\nsubdirectories, but the DIR_NLINK feature is not set in the\nsuperblock, the feature should be set before continuing on\nto change the on-disk directory link count to 1.\n\nWhile most filesystems should have DIR_NLINK set (it was set\nby default for all ext4 filesystems, and the kernel before\n4.12 automatically set it if the directory link count grew\ntoo large), it is possible that this flag is lost due to disk\ncorruption or for an upgraded filesystem. We no longer want\nthe kernel to automatically enable this feature.\n\nAddresses: https://bugzilla.kernel.org/show_bug.cgi?id=196405\nSigned-off-by: Andreas Dilger <adilger@dilger.ca>\n---\n e2fsck/pass4.c | 12 ++++++++-\n e2fsck/problem.c | 5 ++++\n e2fsck/problem.h | 3 +++\n tests/f_large_dir/expect | 7 +++--\n tests/f_large_dir/script | 67 +++++++++++++++++++++++++++++++-----------------\n 5 files changed, 68 insertions(+), 26 deletions(-)", "diff": "diff --git a/e2fsck/pass4.c b/e2fsck/pass4.c\nindex 663f87a..d0ff8e9 100644\n--- a/e2fsck/pass4.c\n+++ b/e2fsck/pass4.c\n@@ -170,6 +170,7 @@ void e2fsck_pass4(e2fsck_t ctx)\n #endif\n \tstruct problem_context\tpctx;\n \t__u16\tlink_count, link_counted;\n+\tint dir_nlink_fs;\n \tchar\t*buf = 0;\n \tdgrp_t\tgroup, maxgroup;\n \n@@ -193,6 +194,8 @@ void e2fsck_pass4(e2fsck_t ctx)\n \tif (!(ctx->options & E2F_OPT_PREEN))\n \t\tfix_problem(ctx, PR_4_PASS_HEADER, &pctx);\n \n+\tdir_nlink_fs = ext2fs_has_feature_dir_nlink(fs->super);\n+\n \tgroup = 0;\n \tmaxgroup = fs->group_desc_count;\n \tif (ctx->progress)\n@@ -249,8 +252,15 @@ void e2fsck_pass4(e2fsck_t ctx)\n \t\t\t\t\t &link_counted);\n \t\t}\n \t\tisdir = ext2fs_test_inode_bitmap2(ctx->inode_dir_map, i);\n-\t\tif (isdir && (link_counted > EXT2_LINK_MAX))\n+\t\tif (isdir && (link_counted > EXT2_LINK_MAX)) {\n+\t\t\tif (!dir_nlink_fs &&\n+\t\t\t fix_problem(ctx, PR_4_DIR_NLINK_FEATURE, &pctx)) {\n+\t\t\t\text2fs_set_feature_dir_nlink(fs->super);\n+\t\t\t\text2fs_mark_super_dirty(fs);\n+\t\t\t\tdir_nlink_fs = 1;\n+\t\t\t}\n \t\t\tlink_counted = 1;\n+\t\t}\n \t\tif (link_counted != link_count) {\n \t\t\te2fsck_read_inode_full(ctx, i, EXT2_INODE(inode),\n \t\t\t\t\t inode_size, \"pass4\");\ndiff --git a/e2fsck/problem.c b/e2fsck/problem.c\nindex 9706933..25c1de9 100644\n--- a/e2fsck/problem.c\n+++ b/e2fsck/problem.c\n@@ -1873,6 +1873,11 @@ static struct e2fsck_problem problem_table[] = {\n \t N_(\"@a @i %i ref count is %N, @s %n. \"),\n \t PROMPT_FIX, PR_PREEN_OK },\n \n+\t/* directory exceeds max links, but no DIR_NLINK feature in superblock*/\n+\t{ PR_4_DIR_NLINK_FEATURE,\n+\t N_(\"@d exceeds max links, but no DIR_NLINK feature in @S.\\n\"),\n+\t PROMPT_FIX, 0 },\n+\n \t/* Pass 5 errors */\n \n \t/* Pass 5: Checking group summary information */\ndiff --git a/e2fsck/problem.h b/e2fsck/problem.h\nindex f30f8f0..07ed0a7 100644\n--- a/e2fsck/problem.h\n+++ b/e2fsck/problem.h\n@@ -1134,6 +1134,9 @@ struct problem_context {\n /* Extended attribute inode ref count wrong */\n #define PR_4_EA_INODE_REF_COUNT\t\t0x040005\n \n+/* directory exceeds max links, but no DIR_NLINK feature in superblock */\n+#define PR_4_DIR_NLINK_FEATURE\t\t0x040006\n+\n /*\n * Pass 5 errors\n */\ndiff --git a/tests/f_large_dir/expect b/tests/f_large_dir/expect\nindex b099460..4b9ca6f 100644\n--- a/tests/f_large_dir/expect\n+++ b/tests/f_large_dir/expect\n@@ -3,10 +3,13 @@ Pass 2: Checking directory structure\n Pass 3: Checking directory connectivity\n Pass 3A: Optimizing directories\n Pass 4: Checking reference counts\n-Inode 13 ref count is 1, should be 47245. Fix? yes\n+Directory exceeds max links, but no DIR_NLINK feature in superblock.\n+Fix? yes\n+\n+Inode 12 ref count is 65012, should be 1. Fix? yes\n \n Pass 5: Checking group summary information\n \n test.img: ***** FILE SYSTEM WAS MODIFIED *****\n-test.img: 13/115368 files (0.0% non-contiguous), 32817/460800 blocks\n+test.img: 65023/65104 files (0.0% non-contiguous), 96668/100937 blocks\n Exit status is 1\ndiff --git a/tests/f_large_dir/script b/tests/f_large_dir/script\nindex 0b5fdff..b25e106 100644\n--- a/tests/f_large_dir/script\n+++ b/tests/f_large_dir/script\n@@ -5,43 +5,64 @@ E2FSCK=../e2fsck/e2fsck\n NAMELEN=255\n DIRENT_SZ=8\n BLOCKSZ=1024\n+INODESZ=128\n DIRENT_PER_LEAF=$((BLOCKSZ / (NAMELEN + DIRENT_SZ)))\n HEADER=32\n INDEX_SZ=8\n INDEX_L1=$(((BLOCKSZ - HEADER) / INDEX_SZ))\n INDEX_L2=$(((BLOCKSZ - DIRENT_SZ) / INDEX_SZ))\n-ENTRIES=$((INDEX_L1 * INDEX_L2 * DIRENT_PER_LEAF))\n+DIRBLK=$((2 + INDEX_L1 * INDEX_L2))\n+ENTRIES=$((DIRBLK * DIRENT_PER_LEAF))\n+EXT4_LINK_MAX=65000\n+if [ $ENTRIES -lt $((EXT4_LINK_MAX + 10)) ]; then\n+\tENTRIES=$((EXT4_LINK_MAX + 10))\n+\tDIRBLK=$((ENTRIES / DIRENT_PER_LEAF + 3))\n+fi\n+# directory leaf blocks plus inode count and 25% for the rest of the fs\n+FSIZE=$(((DIRBLK + EXT4_LINK_MAX * ((BLOCKSZ + INODESZ) / BLOCKSZ)) * 5 / 4))\n \n-cp /dev/null $OUT\n-$MKE2FS -b 1024 -O large_dir,uninit_bg,dir_nlink -F $TMPFILE 460800 \\\n-\t> /dev/null 2>&1\n+> $OUT\n+$MKE2FS -b 1024 -O large_dir,uninit_bg -N $((ENTRIES + 50)) \\\n+\t-I $INODESZ -F $TMPFILE $FSIZE > $OUT 2>&1\n+RC=$?\n+if [ $RC -eq 0 ]; then\n {\n-\techo \"feature large_dir\"\n+\tSTART=$SECONDS\n \techo \"mkdir /foo\"\n \techo \"cd /foo\"\n-\ttouch foofile\n-\techo \"write foofile foofile\"\n+\ttouch $TMPFILE.tmp\n+\techo \"write $TMPFILE.tmp foofile\"\n \ti=0\n-\twhile test $i -lt $ENTRIES ; do\n-\t if test $(( i % DIRENT_PER_LEAF )) -eq 0 ; then\n-\t\techo \"expand ./\"\n+\twhile test $i -lt $ENTRIES ; do\n+\t if test $((i % DIRENT_PER_LEAF)) -eq 0; then\n+\t \techo \"expand ./\"\n \t fi\n-\t if test $(( i % 5000 )) -eq 0 -a $i -gt 0 ; then\n-\t\t>&2 echo \"$test_name: $i processed\"\n+\t if test $((i % 5000)) -eq 0 -a $SECONDS -ne $START; then\n+\t\tELAPSED=$((SECONDS - START))\n+\t\tRATE=$((i / ELAPSED))\n+\t\techo \"$test_name: $i processed in ${ELAPSED}s @ $RATE/s\" >&2\n+\t\tSTART=$SECONDS\n \t fi\n-\t printf \"ln foofile %0255X\\n\" $i\n-\t i=$(($i + 1))\n+\t if test $i -lt $((EXT4_LINK_MAX + 10)); then\n+\t\tprintf \"mkdir d%0254u\\n\" $i\n+\t else\n+\t\tprintf \"ln foofile f%0254u\\n\" $i\n+\t fi\n+\t i=$((i + 1))\n \tdone\n-} | $DEBUGFS -w -f /dev/stdin $TMPFILE > /dev/null 2>&1\n-\n-$E2FSCK -yfD $TMPFILE > $OUT.new 2>&1\n-status=$?\n-echo Exit status is $status >> $OUT.new\n-sed -f $cmd_dir/filter.sed -e \"s;$TMPFILE;test.img;\" $OUT.new >> $OUT\n-rm -f $OUT.new\n+} | $DEBUGFS -w -f /dev/stdin $TMPFILE > $OUT\n+\tRC=$?\n+fi\n+if [ $RC -eq 0 ]; then\n+\t$E2FSCK -yfD $TMPFILE > $OUT.new 2>&1\n+\tstatus=$?\n+\techo \"Exit status is $status\" >> $OUT.new\n+\tsed -f $cmd_dir/filter.sed -e \"s;$TMPFILE;test.img;\" $OUT.new > $OUT\n+\trm -f $OUT.new\n \n-cmp -s $OUT $EXP\n-RC=$?\n+\tcmp -s $OUT $EXP\n+\tRC=$?\n+fi\n if [ $RC -eq 0 ]; then\n \techo \"$test_name: $test_description: ok\"\n \ttouch $test_name.ok\n", "prefixes": [ "1/2" ] }