From fc87b01f96e8485a3713d0e446551e985e0e4aa0 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Thu, 5 Mar 2020 20:40:47 -0500 Subject: [PATCH] LU-12477 ldiskfs: remove obsolete ext4 patches Drop support for ldiskfs kernels earlier than RHEL7.6. Test-Parameters: trivial Change-Id: I30450904c508ec8aa5388cbfd9bd967028f88b28 Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/37352 Reviewed-by: Andreas Dilger Reviewed-by: Alex Zhuravlev Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- config/lustre-build-ldiskfs.m4 | 29 +- .../rhel6.3/ext4-export-64bit-name-hash.patch | 189 -- .../ext4-hash-indexed-dir-dotdot-update.patch | 87 - .../patches/rhel6.3/ext4-inode-version.patch | 63 - .../patches/rhel6.3/ext4-journal-path-opt.patch | 67 - .../patches/rhel6.3/ext4-max-dir-size.patch | 70 - .../patches/rhel6.3/ext4-nlink-2.6.patch | 36 - .../patches/rhel6.3/ext4-nocmtime-2.6.patch | 14 - .../ext4-not-discard-preallocation-umount.patch | 14 - .../patches/rhel6.3/ext4-osd-iam-exports.patch | 64 - .../patches/rhel6.3/ext4-pdir-fix.patch | 52 - .../patches/rhel6.3/ext4-pdirop.patch | 1872 ------------------- .../rhel6.3/ext4-remove-cond_resched-calls.patch | 29 - .../patches/rhel6.5/ext4-fix-journal-quota.patch | 15 - .../ext4-give-warning-with-dir-htree-growing.patch | 168 -- .../rhel7.2/ext4-dont-check-before-replay.patch | 33 - .../patches/rhel7.2/ext4-dont-check-in-ro.patch | 29 - .../patches/rhel7.2/ext4-large-eas.patch | 1093 ----------- .../patches/rhel7.2/ext4-pdirop.patch | 1932 -------------------- .../rhel7.2/ext4-release-bh-in-makeinxdir.patch | 10 - .../ext4-remove-i_data_sem-from-xattr.patch | 475 ----- ...pted-inode-block-bitmaps-handling-patches.patch | 464 ----- .../rhel7.4/ext4-dont-check-before-replay.patch | 33 - .../ext4-remove-i_data_sem-from-xattr.patch | 363 ---- .../ext4-attach-jinode-in-writepages.patch | 0 .../ext4-cleanup-goto-next-group.patch | 0 .../{rhel7.3 => rhel7.6}/ext4-data-in-dirent.patch | 0 .../ext4-disable-mb-cache.patch | 0 .../ext4-dont-check-in-ro.patch | 0 ...ext4-export-mb-stream-allocator-variables.patch | 0 .../ext4-export-orphan-add.patch | 0 ...-fix-xattr-shifting-when-expanding-inodes.patch | 0 .../ext4-give-warning-with-dir-htree-growing.patch | 0 .../ext4-hash-indexed-dir-dotdot-update.patch | 0 ...ze-of-xattr-entries-when-expanding-inodes.patch | 0 .../{rhel7 => rhel7.6}/ext4-inode-version.patch | 0 .../{rhel7 => rhel7.6}/ext4-jcb-optimization.patch | 0 .../{rhel7 => rhel7.6}/ext4-kill-dx-root.patch | 0 .../{rhel7.4 => rhel7.6}/ext4-large-dir.patch | 0 .../{rhel7 => rhel7.6}/ext4-lookup-dotdot.patch | 0 .../{rhel7 => rhel7.6}/ext4-max-dir-size.patch | 0 .../ext4-mballoc-extra-checks.patch | 0 .../ext4-mballoc-pa-free-mismatch.patch | 0 .../patches/rhel7.6/ext4-mballoc-prefetch.patch | 235 +++ .../ext4-mballoc-skip-uninit-groups-cr0.patch | 0 .../patches/{rhel7 => rhel7.6}/ext4-misc.patch | 0 .../{rhel7 => rhel7.6}/ext4-mmp-brelse.patch | 0 .../ext4-mmp-dont-mark-bh-dirty.patch | 0 .../patches/{rhel7 => rhel7.6}/ext4-nocmtime.patch | 0 ...ze-ext4_find_delalloc_range-in-nodelalloc.patch | 0 .../patches/{rhel7.4 => rhel7.6}/ext4-pdirop.patch | 0 .../{rhel7.4 => rhel7.6}/ext4-prealloc.patch | 0 .../{rhel7.2 => rhel7.6}/ext4-preread-gd.patch | 0 .../ext4-print-inum-in-htree-warning.patch | 0 .../ext4-projid-feature-support.patch | 0 .../ext4-projid-ignore-maxquotas.patch | 0 .../{rhel7 => rhel7.6}/ext4-projid-quotas.patch | 0 .../ext4-projid-xfs-ioctls.patch | 0 ...educe-lock-contention-in-__ext4_new_inode.patch | 0 .../ext4-simple-blockalloc.patch | 0 ...-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch | 0 .../ext4_s_max_ext_tree_depth.patch | 0 ...pted-inode-block-bitmaps-handling-patches.patch | 465 ----- .../patches/rhel7/ext4-data-in-dirent.patch | 793 -------- .../patches/rhel7/ext4-disable-mb-cache.patch | 157 -- ...-fix-xattr-shifting-when-expanding-inodes.patch | 444 ----- .../patches/rhel7/ext4-large-dir.patch | 351 ---- .../patches/rhel7/ext4-large-eas.patch | 1097 ----------- .../kernel_patches/patches/rhel7/ext4-pdirop.patch | 1932 -------------------- .../patches/rhel7/ext4-prealloc.patch | 400 ---- .../patches/rhel7/ext4-projid-xfs-ioctls.patch | 485 ----- .../rhel7/ext4-remove-i_data_sem-from-xattr.patch | 475 ----- .../sles11sp1/ext4-notalloc_under_idatasem.patch | 14 - .../patches/sles11sp2/export-ext4-3.0.patch | 224 --- ...pted-inode-block-bitmaps-handling-patches.patch | 438 ----- .../patches/sles11sp2/ext4-data-in-dirent.patch | 555 ------ .../patches/sles11sp2/ext4-disable-mb-cache.patch | 154 -- .../patches/sles11sp2/ext4-ext_generation.patch | 48 - .../ext4-handle-cleanup-after-quota-failure.patch | 34 - ...xt4_kvmalloc-ext4_kzalloc-and-ext4_kvfree.patch | 120 -- .../patches/sles11sp2/ext4-journal-callback.patch | 455 ----- .../patches/sles11sp2/ext4-kill-dx_root.patch | 229 --- .../patches/sles11sp2/ext4-large-dir.patch | 364 ---- .../patches/sles11sp2/ext4-large-eas.patch | 1040 ----------- .../patches/sles11sp2/ext4-lookup-dotdot.patch | 62 - ...ke-quota-as-first-class-supported-feature.patch | 322 ---- .../sles11sp2/ext4-map_inode_page-3.0.patch | 85 - .../sles11sp2/ext4-max-dir-size-options.patch | 33 - .../sles11sp2/ext4-mballoc-extra-checks.patch | 321 ---- .../sles11sp2/ext4-mballoc-pa_free-mismatch.patch | 109 -- .../patches/sles11sp2/ext4-misc.patch | 122 -- .../sles11sp2/ext4-mmp-dont-mark-bh-dirty.patch | 35 - .../patches/sles11sp2/ext4-osd-iop-common.patch | 216 --- .../patches/sles11sp2/ext4-prealloc.patch | 391 ---- ...rim-by-recording-flags-in-ext4_group_info.patch | 159 -- .../ext4-store-tree-generation-at-find.patch | 64 - ...vmalloc-for-s_group_desc-and-s_group_info.patch | 121 -- ...use-ext4_msg-instead-of-printk-in-mballoc.patch | 196 -- .../restore-path-in-walk_extent_callback.patch | 58 - ...emory-references-in-ext3_htree_next_block.patch | 107 -- .../sles11sp3/ext4-dont-check-before-replay.patch | 31 - .../patches/sles11sp3/ext4-mmp-brelse.patch | 23 - .../sles11sp3/ext4_s_max_ext_tree_depth.patch | 158 -- .../patches/sles11sp4/ext4-large-dir.patch | 364 ---- .../{rhel7 => sles12}/ext4-osd-iop-common.patch | 0 .../series/ldiskfs-3.0-sles11.series | 44 - .../series/ldiskfs-3.0-sles11sp3.series | 48 - .../series/ldiskfs-3.0-sles11sp4.series | 48 - .../series/ldiskfs-3.10-rhel7.2.series | 40 - .../series/ldiskfs-3.10-rhel7.3.series | 40 - .../series/ldiskfs-3.10-rhel7.4.series | 40 - .../series/ldiskfs-3.10-rhel7.5.series | 40 - .../series/ldiskfs-3.10-rhel7.6.series | 74 +- .../series/ldiskfs-3.10-rhel7.7.series | 62 +- .../series/ldiskfs-3.10-rhel7.series | 35 - .../series/ldiskfs-3.12-sles12.series | 36 +- .../series/ldiskfs-3.12-sles12sp1.series | 32 +- .../series/ldiskfs-4.15.0-20-ubuntu18.series | 8 +- .../series/ldiskfs-4.15.0-24-ubuntu18.series | 8 +- .../series/ldiskfs-4.18-rhel8.1.series | 6 +- .../series/ldiskfs-4.18-rhel8.series | 6 +- .../series/ldiskfs-4.4-sles12sp2.series | 18 +- .../series/ldiskfs-4.4-sles12sp3.series | 16 +- .../series/ldiskfs-4.4.0-45-ubuntu14+16.series | 16 +- .../series/ldiskfs-4.4.0-49-ubuntu14+16.series | 16 +- .../series/ldiskfs-4.4.0-62-ubuntu14+16.series | 16 +- .../series/ldiskfs-4.4.0-73-ubuntu14+16.series | 16 +- .../series/ldiskfs-5.0.0-13-ubuntu19.series | 6 +- .../kernel_patches/series/ldiskfs-5.4.0-ml.series | 6 +- 129 files changed, 408 insertions(+), 20956 deletions(-) delete mode 100644 ldiskfs/kernel_patches/patches/rhel6.3/ext4-export-64bit-name-hash.patch delete mode 100644 ldiskfs/kernel_patches/patches/rhel6.3/ext4-hash-indexed-dir-dotdot-update.patch delete mode 100644 ldiskfs/kernel_patches/patches/rhel6.3/ext4-inode-version.patch delete mode 100644 ldiskfs/kernel_patches/patches/rhel6.3/ext4-journal-path-opt.patch delete mode 100644 ldiskfs/kernel_patches/patches/rhel6.3/ext4-max-dir-size.patch delete mode 100644 ldiskfs/kernel_patches/patches/rhel6.3/ext4-nlink-2.6.patch delete mode 100644 ldiskfs/kernel_patches/patches/rhel6.3/ext4-nocmtime-2.6.patch delete mode 100644 ldiskfs/kernel_patches/patches/rhel6.3/ext4-not-discard-preallocation-umount.patch delete mode 100644 ldiskfs/kernel_patches/patches/rhel6.3/ext4-osd-iam-exports.patch delete mode 100644 ldiskfs/kernel_patches/patches/rhel6.3/ext4-pdir-fix.patch delete mode 100644 ldiskfs/kernel_patches/patches/rhel6.3/ext4-pdirop.patch delete mode 100644 ldiskfs/kernel_patches/patches/rhel6.3/ext4-remove-cond_resched-calls.patch delete mode 100644 ldiskfs/kernel_patches/patches/rhel6.5/ext4-fix-journal-quota.patch delete mode 100644 ldiskfs/kernel_patches/patches/rhel6.5/ext4-give-warning-with-dir-htree-growing.patch delete mode 100644 ldiskfs/kernel_patches/patches/rhel7.2/ext4-dont-check-before-replay.patch delete mode 100644 ldiskfs/kernel_patches/patches/rhel7.2/ext4-dont-check-in-ro.patch delete mode 100644 ldiskfs/kernel_patches/patches/rhel7.2/ext4-large-eas.patch delete mode 100644 ldiskfs/kernel_patches/patches/rhel7.2/ext4-pdirop.patch delete mode 100644 ldiskfs/kernel_patches/patches/rhel7.2/ext4-release-bh-in-makeinxdir.patch delete mode 100644 ldiskfs/kernel_patches/patches/rhel7.2/ext4-remove-i_data_sem-from-xattr.patch delete mode 100644 ldiskfs/kernel_patches/patches/rhel7.3/ext4-corrupted-inode-block-bitmaps-handling-patches.patch delete mode 100644 ldiskfs/kernel_patches/patches/rhel7.4/ext4-dont-check-before-replay.patch delete mode 100644 ldiskfs/kernel_patches/patches/rhel7.4/ext4-remove-i_data_sem-from-xattr.patch rename ldiskfs/kernel_patches/patches/{rhel7.4 => rhel7.6}/ext4-attach-jinode-in-writepages.patch (100%) rename ldiskfs/kernel_patches/patches/{rhel7 => rhel7.6}/ext4-cleanup-goto-next-group.patch (100%) rename ldiskfs/kernel_patches/patches/{rhel7.3 => rhel7.6}/ext4-data-in-dirent.patch (100%) rename ldiskfs/kernel_patches/patches/{rhel7.3 => rhel7.6}/ext4-disable-mb-cache.patch (100%) rename ldiskfs/kernel_patches/patches/{rhel6.3 => rhel7.6}/ext4-dont-check-in-ro.patch (100%) rename ldiskfs/kernel_patches/patches/{rhel7.2 => rhel7.6}/ext4-export-mb-stream-allocator-variables.patch (100%) rename ldiskfs/kernel_patches/patches/{rhel7 => rhel7.6}/ext4-export-orphan-add.patch (100%) rename ldiskfs/kernel_patches/patches/{rhel7.4 => rhel7.6}/ext4-fix-xattr-shifting-when-expanding-inodes.patch (100%) rename ldiskfs/kernel_patches/patches/{rhel7 => rhel7.6}/ext4-give-warning-with-dir-htree-growing.patch (100%) rename ldiskfs/kernel_patches/patches/{rhel7 => rhel7.6}/ext4-hash-indexed-dir-dotdot-update.patch (100%) rename ldiskfs/kernel_patches/patches/{rhel7 => rhel7.6}/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch (100%) rename ldiskfs/kernel_patches/patches/{rhel7 => rhel7.6}/ext4-inode-version.patch (100%) rename ldiskfs/kernel_patches/patches/{rhel7 => rhel7.6}/ext4-jcb-optimization.patch (100%) rename ldiskfs/kernel_patches/patches/{rhel7 => rhel7.6}/ext4-kill-dx-root.patch (100%) rename ldiskfs/kernel_patches/patches/{rhel7.4 => rhel7.6}/ext4-large-dir.patch (100%) rename ldiskfs/kernel_patches/patches/{rhel7 => rhel7.6}/ext4-lookup-dotdot.patch (100%) rename ldiskfs/kernel_patches/patches/{rhel7 => rhel7.6}/ext4-max-dir-size.patch (100%) rename ldiskfs/kernel_patches/patches/{rhel7 => rhel7.6}/ext4-mballoc-extra-checks.patch (100%) rename ldiskfs/kernel_patches/patches/{rhel7 => rhel7.6}/ext4-mballoc-pa-free-mismatch.patch (100%) create mode 100644 ldiskfs/kernel_patches/patches/rhel7.6/ext4-mballoc-prefetch.patch rename ldiskfs/kernel_patches/patches/{rhel7 => rhel7.6}/ext4-mballoc-skip-uninit-groups-cr0.patch (100%) rename ldiskfs/kernel_patches/patches/{rhel7 => rhel7.6}/ext4-misc.patch (100%) rename ldiskfs/kernel_patches/patches/{rhel7 => rhel7.6}/ext4-mmp-brelse.patch (100%) rename ldiskfs/kernel_patches/patches/{rhel7 => rhel7.6}/ext4-mmp-dont-mark-bh-dirty.patch (100%) rename ldiskfs/kernel_patches/patches/{rhel7 => rhel7.6}/ext4-nocmtime.patch (100%) rename ldiskfs/kernel_patches/patches/{rhel7 => rhel7.6}/ext4-optimize-ext4_find_delalloc_range-in-nodelalloc.patch (100%) rename ldiskfs/kernel_patches/patches/{rhel7.4 => rhel7.6}/ext4-pdirop.patch (100%) rename ldiskfs/kernel_patches/patches/{rhel7.4 => rhel7.6}/ext4-prealloc.patch (100%) rename ldiskfs/kernel_patches/patches/{rhel7.2 => rhel7.6}/ext4-preread-gd.patch (100%) rename ldiskfs/kernel_patches/patches/{rhel6.3 => rhel7.6}/ext4-print-inum-in-htree-warning.patch (100%) rename ldiskfs/kernel_patches/patches/{rhel7 => rhel7.6}/ext4-projid-feature-support.patch (100%) rename ldiskfs/kernel_patches/patches/{rhel7 => rhel7.6}/ext4-projid-ignore-maxquotas.patch (100%) rename ldiskfs/kernel_patches/patches/{rhel7 => rhel7.6}/ext4-projid-quotas.patch (100%) rename ldiskfs/kernel_patches/patches/{rhel7.5 => rhel7.6}/ext4-projid-xfs-ioctls.patch (100%) rename ldiskfs/kernel_patches/patches/{rhel7 => rhel7.6}/ext4-reduce-lock-contention-in-__ext4_new_inode.patch (100%) rename ldiskfs/kernel_patches/patches/{rhel7.2 => rhel7.6}/ext4-simple-blockalloc.patch (100%) rename ldiskfs/kernel_patches/patches/{rhel7 => rhel7.6}/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch (100%) rename ldiskfs/kernel_patches/patches/{rhel7 => rhel7.6}/ext4_s_max_ext_tree_depth.patch (100%) delete mode 100644 ldiskfs/kernel_patches/patches/rhel7/ext4-corrupted-inode-block-bitmaps-handling-patches.patch delete mode 100644 ldiskfs/kernel_patches/patches/rhel7/ext4-data-in-dirent.patch delete mode 100644 ldiskfs/kernel_patches/patches/rhel7/ext4-disable-mb-cache.patch delete mode 100644 ldiskfs/kernel_patches/patches/rhel7/ext4-fix-xattr-shifting-when-expanding-inodes.patch delete mode 100644 ldiskfs/kernel_patches/patches/rhel7/ext4-large-dir.patch delete mode 100644 ldiskfs/kernel_patches/patches/rhel7/ext4-large-eas.patch delete mode 100644 ldiskfs/kernel_patches/patches/rhel7/ext4-pdirop.patch delete mode 100644 ldiskfs/kernel_patches/patches/rhel7/ext4-prealloc.patch delete mode 100644 ldiskfs/kernel_patches/patches/rhel7/ext4-projid-xfs-ioctls.patch delete mode 100644 ldiskfs/kernel_patches/patches/rhel7/ext4-remove-i_data_sem-from-xattr.patch delete mode 100644 ldiskfs/kernel_patches/patches/sles11sp1/ext4-notalloc_under_idatasem.patch delete mode 100644 ldiskfs/kernel_patches/patches/sles11sp2/export-ext4-3.0.patch delete mode 100644 ldiskfs/kernel_patches/patches/sles11sp2/ext4-corrupted-inode-block-bitmaps-handling-patches.patch delete mode 100644 ldiskfs/kernel_patches/patches/sles11sp2/ext4-data-in-dirent.patch delete mode 100644 ldiskfs/kernel_patches/patches/sles11sp2/ext4-disable-mb-cache.patch delete mode 100644 ldiskfs/kernel_patches/patches/sles11sp2/ext4-ext_generation.patch delete mode 100644 ldiskfs/kernel_patches/patches/sles11sp2/ext4-handle-cleanup-after-quota-failure.patch delete mode 100644 ldiskfs/kernel_patches/patches/sles11sp2/ext4-introduce-ext4_kvmalloc-ext4_kzalloc-and-ext4_kvfree.patch delete mode 100644 ldiskfs/kernel_patches/patches/sles11sp2/ext4-journal-callback.patch delete mode 100644 ldiskfs/kernel_patches/patches/sles11sp2/ext4-kill-dx_root.patch delete mode 100644 ldiskfs/kernel_patches/patches/sles11sp2/ext4-large-dir.patch delete mode 100644 ldiskfs/kernel_patches/patches/sles11sp2/ext4-large-eas.patch delete mode 100644 ldiskfs/kernel_patches/patches/sles11sp2/ext4-lookup-dotdot.patch delete mode 100644 ldiskfs/kernel_patches/patches/sles11sp2/ext4-make-quota-as-first-class-supported-feature.patch delete mode 100644 ldiskfs/kernel_patches/patches/sles11sp2/ext4-map_inode_page-3.0.patch delete mode 100644 ldiskfs/kernel_patches/patches/sles11sp2/ext4-max-dir-size-options.patch delete mode 100644 ldiskfs/kernel_patches/patches/sles11sp2/ext4-mballoc-extra-checks.patch delete mode 100644 ldiskfs/kernel_patches/patches/sles11sp2/ext4-mballoc-pa_free-mismatch.patch delete mode 100644 ldiskfs/kernel_patches/patches/sles11sp2/ext4-misc.patch delete mode 100644 ldiskfs/kernel_patches/patches/sles11sp2/ext4-mmp-dont-mark-bh-dirty.patch delete mode 100644 ldiskfs/kernel_patches/patches/sles11sp2/ext4-osd-iop-common.patch delete mode 100644 ldiskfs/kernel_patches/patches/sles11sp2/ext4-prealloc.patch delete mode 100644 ldiskfs/kernel_patches/patches/sles11sp2/ext4-speed-up-fitrim-by-recording-flags-in-ext4_group_info.patch delete mode 100644 ldiskfs/kernel_patches/patches/sles11sp2/ext4-store-tree-generation-at-find.patch delete mode 100644 ldiskfs/kernel_patches/patches/sles11sp2/ext4-use-ext4_kvzalloc-ext4_kvmalloc-for-s_group_desc-and-s_group_info.patch delete mode 100644 ldiskfs/kernel_patches/patches/sles11sp2/ext4-use-ext4_msg-instead-of-printk-in-mballoc.patch delete mode 100644 ldiskfs/kernel_patches/patches/sles11sp2/restore-path-in-walk_extent_callback.patch delete mode 100644 ldiskfs/kernel_patches/patches/sles11sp2/revert-ext4-avoid-uninitialized-memory-references-in-ext3_htree_next_block.patch delete mode 100644 ldiskfs/kernel_patches/patches/sles11sp3/ext4-dont-check-before-replay.patch delete mode 100644 ldiskfs/kernel_patches/patches/sles11sp3/ext4-mmp-brelse.patch delete mode 100644 ldiskfs/kernel_patches/patches/sles11sp3/ext4_s_max_ext_tree_depth.patch delete mode 100644 ldiskfs/kernel_patches/patches/sles11sp4/ext4-large-dir.patch rename ldiskfs/kernel_patches/patches/{rhel7 => sles12}/ext4-osd-iop-common.patch (100%) delete mode 100644 ldiskfs/kernel_patches/series/ldiskfs-3.0-sles11.series delete mode 100644 ldiskfs/kernel_patches/series/ldiskfs-3.0-sles11sp3.series delete mode 100644 ldiskfs/kernel_patches/series/ldiskfs-3.0-sles11sp4.series diff --git a/config/lustre-build-ldiskfs.m4 b/config/lustre-build-ldiskfs.m4 index 1f4a1e7..f205890 100644 --- a/config/lustre-build-ldiskfs.m4 +++ b/config/lustre-build-ldiskfs.m4 @@ -17,38 +17,13 @@ AS_IF([test x$RHEL_KERNEL = xyes], [ 80) LDISKFS_SERIES="4.18-rhel8.series" ;; 77) LDISKFS_SERIES="3.10-rhel7.7.series" ;; 76) LDISKFS_SERIES="3.10-rhel7.6.series" ;; - 75) LDISKFS_SERIES="3.10-rhel7.5.series" ;; - 74) LDISKFS_SERIES="3.10-rhel7.4.series" ;; - 73) LDISKFS_SERIES="3.10-rhel7.3.series" ;; - 72) LDISKFS_SERIES="3.10-rhel7.2.series" ;; - 71) LDISKFS_SERIES="3.10-rhel7.series" ;; - 69) LDISKFS_SERIES="2.6-rhel6.9.series" ;; - 68) LDISKFS_SERIES="2.6-rhel6.8.series" ;; - 67) LDISKFS_SERIES="2.6-rhel6.7.series" ;; - 66) LDISKFS_SERIES="2.6-rhel6.6.series" ;; - 65) LDISKFS_SERIES="2.6-rhel6.5.series" ;; - 64) LDISKFS_SERIES="2.6-rhel6.4.series" ;; - 6[0-3]) LDISKFS_SERIES="2.6-rhel6.series" ;; esac ], [test x$SUSE_KERNEL = xyes], [ AS_VERSION_COMPARE([$LINUXRELEASE],[4.12.14],[ AS_VERSION_COMPARE([$LINUXRELEASE],[4.4.82],[ AS_VERSION_COMPARE([$LINUXRELEASE],[4.4.0],[ - AS_VERSION_COMPARE([$LINUXRELEASE],[3.12.0],[ - AS_VERSION_COMPARE([$LINUXRELEASE],[3.0.0],[ - AS_VERSION_COMPARE([$LINUXRELEASE],[2.6.32], [], - [LDISKFS_SERIES="2.6-sles11.series"],[LDISKFS_SERIES="2.6-sles11.series"])], - [LDISKFS_SERIES="3.0-sles11.series"],[ - PLEV=$(grep PATCHLEVEL /etc/SuSE-release | sed -e 's/.*= *//') - case $PLEV in - 2) LDISKFS_SERIES="3.0-sles11.series" - ;; - 3) LDISKFS_SERIES="3.0-sles11sp3.series" - ;; - 4) LDISKFS_SERIES="3.0-sles11sp4.series" - ;; - esac - ])],[LDISKFS_SERIES="3.12-sles12.series"],[ + AS_VERSION_COMPARE([$LINUXRELEASE],[3.12.0],[], + [LDISKFS_SERIES="3.12-sles12.series"],[ PLEV=$(grep PATCHLEVEL /etc/SuSE-release | sed -e 's/.*= *//') case $PLEV in 1) LDISKFS_SERIES="3.12-sles12sp1.series" diff --git a/ldiskfs/kernel_patches/patches/rhel6.3/ext4-export-64bit-name-hash.patch b/ldiskfs/kernel_patches/patches/rhel6.3/ext4-export-64bit-name-hash.patch deleted file mode 100644 index f3982bdd..0000000 --- a/ldiskfs/kernel_patches/patches/rhel6.3/ext4-export-64bit-name-hash.patch +++ /dev/null @@ -1,189 +0,0 @@ -diff -urp linux-stage.orig/fs/ext4/dir.c linux-stage/fs/ext4/dir.c ---- linux-stage.orig/fs/ext4/dir.c 2012-06-21 10:26:23.000000000 -0400 -+++ linux-stage/fs/ext4/dir.c 2012-06-21 10:37:39.000000000 -0400 -@@ -247,20 +247,52 @@ out: - - /* - * These functions convert from the major/minor hash to an f_pos -- * value. -+ * value for dx directories. - * -- * Currently we only use major hash numer. This is unfortunate, but -- * on 32-bit machines, the same VFS interface is used for lseek and -- * llseek, so if we use the 64 bit offset, then the 32-bit versions of -- * lseek/telldir/seekdir will blow out spectacularly, and from within -- * the ext2 low-level routine, we don't know if we're being called by -- * a 64-bit version of the system call or the 32-bit version of the -- * system call. Worse yet, NFSv2 only allows for a 32-bit readdir -- * cookie. Sigh. -+ * Upper layer (for example NFS) should specify FMODE_32BITHASH or -+ * FMODE_64BITHASH explicitly. On the other hand, we allow ext4 to be mounted -+ * directly on both 32-bit and 64-bit nodes, under such case, neither -+ * FMODE_32BITHASH nor FMODE_64BITHASH is specified. -+ */ -+static inline loff_t hash2pos(struct file *filp, __u32 major, __u32 minor) -+{ -+ if ((filp->f_mode & FMODE_32BITHASH) || -+ (!(filp->f_mode & FMODE_64BITHASH) && is_compat_task())) -+ return major >> 1; -+ else -+ return ((__u64)(major >> 1) << 32) | (__u64)minor; -+} -+ -+static inline __u32 pos2maj_hash(struct file *filp, loff_t pos) -+{ -+ if ((filp->f_mode & FMODE_32BITHASH) || -+ (!(filp->f_mode & FMODE_64BITHASH) && is_compat_task())) -+ return (pos << 1) & 0xffffffff; -+ else -+ return ((pos >> 32) << 1) & 0xffffffff; -+} -+ -+static inline __u32 pos2min_hash(struct file *filp, loff_t pos) -+{ -+ if ((filp->f_mode & FMODE_32BITHASH) || -+ (!(filp->f_mode & FMODE_64BITHASH) && is_compat_task())) -+ return 0; -+ else -+ return pos & 0xffffffff; -+} -+ -+/* -+ * Return 32- or 64-bit end-of-file for dx directories - */ --#define hash2pos(major, minor) (major >> 1) --#define pos2maj_hash(pos) ((pos << 1) & 0xffffffff) --#define pos2min_hash(pos) (0) -+static inline loff_t ext4_get_htree_eof(struct file *filp) -+{ -+ if ((filp->f_mode & FMODE_32BITHASH) || -+ (!(filp->f_mode & FMODE_64BITHASH) && is_compat_task())) -+ return EXT4_HTREE_EOF_32BIT; -+ else -+ return EXT4_HTREE_EOF_64BIT; -+} -+ - - /* - * This structure holds the nodes of the red-black tree used to store -@@ -323,15 +364,16 @@ static void free_rb_tree_fname(struct rb - } - - --static struct dir_private_info *ext4_htree_create_dir_info(loff_t pos) -+static struct dir_private_info * -+ext4_htree_create_dir_info(struct file *filp, loff_t pos) - { - struct dir_private_info *p; - - p = kzalloc(sizeof(struct dir_private_info), GFP_KERNEL); - if (!p) - return NULL; -- p->curr_hash = pos2maj_hash(pos); -- p->curr_minor_hash = pos2min_hash(pos); -+ p->curr_hash = pos2maj_hash(filp, pos); -+ p->curr_minor_hash = pos2min_hash(filp, pos); - return p; - } - -@@ -427,7 +469,7 @@ static int call_filldir(struct file *fil - "null fname?!?\n"); - return 0; - } -- curr_pos = hash2pos(fname->hash, fname->minor_hash); -+ curr_pos = hash2pos(filp, fname->hash, fname->minor_hash); - while (fname) { - error = filldir(dirent, fname->name, - fname->name_len, curr_pos, -@@ -452,13 +494,13 @@ static int ext4_dx_readdir(struct file * - int ret; - - if (!info) { -- info = ext4_htree_create_dir_info(filp->f_pos); -+ info = ext4_htree_create_dir_info(filp, filp->f_pos); - if (!info) - return -ENOMEM; - filp->private_data = info; - } - -- if (filp->f_pos == EXT4_HTREE_EOF) -+ if (filp->f_pos == ext4_get_htree_eof(filp)) - return 0; /* EOF */ - - /* Some one has messed with f_pos; reset the world */ -@@ -466,8 +508,8 @@ static int ext4_dx_readdir(struct file * - free_rb_tree_fname(&info->root); - info->curr_node = NULL; - info->extra_fname = NULL; -- info->curr_hash = pos2maj_hash(filp->f_pos); -- info->curr_minor_hash = pos2min_hash(filp->f_pos); -+ info->curr_hash = pos2maj_hash(filp, filp->f_pos); -+ info->curr_minor_hash = pos2min_hash(filp, filp->f_pos); - } - - /* -@@ -499,7 +541,7 @@ static int ext4_dx_readdir(struct file * - if (ret < 0) - return ret; - if (ret == 0) { -- filp->f_pos = EXT4_HTREE_EOF; -+ filp->f_pos = ext4_get_htree_eof(filp); - break; - } - info->curr_node = rb_first(&info->root); -@@ -519,7 +561,7 @@ static int ext4_dx_readdir(struct file * - info->curr_minor_hash = fname->minor_hash; - } else { - if (info->next_hash == ~0) { -- filp->f_pos = EXT4_HTREE_EOF; -+ filp->f_pos = ext4_get_htree_eof(filp); - break; - } - info->curr_hash = info->next_hash; -diff -urp linux-stage.orig/fs/ext4/ext4.h linux-stage/fs/ext4/ext4.h ---- linux-stage.orig/fs/ext4/ext4.h 2012-06-21 10:26:23.000000000 -0400 -+++ linux-stage/fs/ext4/ext4.h 2012-06-21 10:39:43.000000000 -0400 -@@ -816,6 +816,16 @@ struct ext4_inode_info { - __u64 i_fs_version; - }; - -+#ifndef FMODE_32BITHASH -+/* 32bit hashes as llseek() offset (for directories) */ -+#define FMODE_32BITHASH ((__force fmode_t)0x200) -+#endif -+ -+#ifndef FMODE_64BITHASH -+/* 64bit hashes as llseek() offset (for directories) */ -+#define FMODE_64BITHASH ((__force fmode_t)0x400) -+#endif -+ - #define HAVE_DISK_INODE_VERSION - - /* -@@ -1450,7 +1460,11 @@ struct dx_hash_info - u32 *seed; - }; - --#define EXT4_HTREE_EOF 0x7fffffff -+ -+/* 32 and 64 bit signed EOF for dx directories */ -+#define EXT4_HTREE_EOF_32BIT ((1UL << (32 - 1)) - 1) -+#define EXT4_HTREE_EOF_64BIT ((1ULL << (64 - 1)) - 1) -+ - - /* - * Control parameters used by ext4_htree_next_block -diff -urp linux-stage.orig/fs/ext4/hash.c linux-stage/fs/ext4/hash.c ---- linux-stage.orig/fs/ext4/hash.c 2012-06-21 10:26:23.000000000 -0400 -+++ linux-stage/fs/ext4/hash.c 2012-06-21 10:29:02.000000000 -0400 -@@ -201,8 +201,8 @@ int ext4fs_dirhash(const char *name, int - return -1; - } - hash = hash & ~1; -- if (hash == (EXT4_HTREE_EOF << 1)) -- hash = (EXT4_HTREE_EOF-1) << 1; -+ if (hash == (EXT4_HTREE_EOF_32BIT << 1)) -+ hash = (EXT4_HTREE_EOF_32BIT - 1) << 1; - hinfo->hash = hash; - hinfo->minor_hash = minor_hash; - return 0; diff --git a/ldiskfs/kernel_patches/patches/rhel6.3/ext4-hash-indexed-dir-dotdot-update.patch b/ldiskfs/kernel_patches/patches/rhel6.3/ext4-hash-indexed-dir-dotdot-update.patch deleted file mode 100644 index 76416c7..0000000 --- a/ldiskfs/kernel_patches/patches/rhel6.3/ext4-hash-indexed-dir-dotdot-update.patch +++ /dev/null @@ -1,87 +0,0 @@ -Index: linux-stage/fs/ext4/namei.c -=================================================================== ---- linux-stage.orig/fs/ext4/namei.c 2009-08-10 22:44:33.000000000 +0800 -+++ linux-stage/fs/ext4/namei.c 2009-08-10 22:48:22.000000000 +0800 -@@ -1493,6 +1493,72 @@ - return add_dirent_to_buf(handle, dentry, inode, de, bh); - } - -+/* update ".." for hash-indexed directory, split the item "." if necessary */ -+static int ext4_update_dotdot(handle_t *handle, struct dentry *dentry, -+ struct inode *inode) -+{ -+ struct inode * dir = dentry->d_parent->d_inode; -+ struct buffer_head * dir_block; -+ struct ext4_dir_entry_2 * de; -+ int len, journal = 0, err = 0; -+ -+ if (IS_ERR(handle)) -+ return PTR_ERR(handle); -+ -+ if (IS_DIRSYNC(dir)) -+ handle->h_sync = 1; -+ -+ dir_block = ext4_bread(handle, dir, 0, 0, &err); -+ if (!dir_block) -+ goto out; -+ -+ de = (struct ext4_dir_entry_2 *)dir_block->b_data; -+ /* the first item must be "." */ -+ assert(de->name_len == 1 && de->name[0] == '.'); -+ len = le16_to_cpu(de->rec_len); -+ assert(len >= EXT4_DIR_REC_LEN(1)); -+ if (len > EXT4_DIR_REC_LEN(1)) { -+ BUFFER_TRACE(dir_block, "get_write_access"); -+ err = ext4_journal_get_write_access(handle, dir_block); -+ if (err) -+ goto out_journal; -+ -+ journal = 1; -+ de->rec_len = cpu_to_le16(EXT4_DIR_REC_LEN(1)); -+ } -+ -+ len -= EXT4_DIR_REC_LEN(1); -+ assert(len == 0 || len >= EXT4_DIR_REC_LEN(2)); -+ de = (struct ext4_dir_entry_2 *) -+ ((char *) de + le16_to_cpu(de->rec_len)); -+ if (!journal) { -+ BUFFER_TRACE(dir_block, "get_write_access"); -+ err = ext4_journal_get_write_access(handle, dir_block); -+ if (err) -+ goto out_journal; -+ } -+ -+ de->inode = cpu_to_le32(inode->i_ino); -+ if (len > 0) -+ de->rec_len = cpu_to_le16(len); -+ else -+ assert(le16_to_cpu(de->rec_len) >= EXT4_DIR_REC_LEN(2)); -+ de->name_len = 2; -+ strcpy (de->name, ".."); -+ ext4_set_de_type(dir->i_sb, de, S_IFDIR); -+ -+out_journal: -+ if (journal) { -+ BUFFER_TRACE(dir_block, "call ext4_handle_dirty_metadata"); -+ err = ext4_handle_dirty_metadata(handle, dir, dir_block); -+ ext4_mark_inode_dirty(handle, dir); -+ } -+ brelse (dir_block); -+ -+out: -+ return err; -+} -+ - /* - * ext4_add_entry() - * -@@ -1521,6 +1587,9 @@ - if (!dentry->d_name.len) - return -EINVAL; - if (is_dx(dir)) { -+ if (dentry->d_name.len == 2 && -+ memcmp(dentry->d_name.name, "..", 2) == 0) -+ return ext4_update_dotdot(handle, dentry, inode); - retval = ext4_dx_add_entry(handle, dentry, inode); - if (!retval || (retval != ERR_BAD_DX_DIR)) - return retval; diff --git a/ldiskfs/kernel_patches/patches/rhel6.3/ext4-inode-version.patch b/ldiskfs/kernel_patches/patches/rhel6.3/ext4-inode-version.patch deleted file mode 100644 index a104bed..0000000 --- a/ldiskfs/kernel_patches/patches/rhel6.3/ext4-inode-version.patch +++ /dev/null @@ -1,63 +0,0 @@ -Index: linux-2.6.32-el6-beta/fs/ext4/inode.c -=================================================================== ---- linux-2.6.32-el6-beta.orig/fs/ext4/inode.c -+++ linux-2.6.32-el6-beta/fs/ext4/inode.c -@@ -4920,11 +4920,11 @@ struct inode *ext4_iget(struct super_blo - EXT4_INODE_GET_XTIME(i_atime, inode, raw_inode); - EXT4_EINODE_GET_XTIME(i_crtime, ei, raw_inode); - -- inode->i_version = le32_to_cpu(raw_inode->i_disk_version); -+ ei->i_fs_version = le32_to_cpu(raw_inode->i_disk_version); - if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE) { - if (EXT4_FITS_IN_INODE(raw_inode, ei, i_version_hi)) -- inode->i_version |= -- (__u64)(le32_to_cpu(raw_inode->i_version_hi)) << 32; -+ ei->i_fs_version |= (__u64)(le32_to_cpu(raw_inode->i_version_hi)) -+ << 32; - } - - ret = 0; -@@ -5134,11 +5134,11 @@ static int ext4_do_update_inode(handle_t - for (block = 0; block < EXT4_N_BLOCKS; block++) - raw_inode->i_block[block] = ei->i_data[block]; - -- raw_inode->i_disk_version = cpu_to_le32(inode->i_version); -+ raw_inode->i_disk_version = cpu_to_le32(ei->i_fs_version); - if (ei->i_extra_isize) { - if (EXT4_FITS_IN_INODE(raw_inode, ei, i_version_hi)) -- raw_inode->i_version_hi = -- cpu_to_le32(inode->i_version >> 32); -+ raw_inode->i_version_hi = cpu_to_le32(ei->i_fs_version -+ >> 32); - raw_inode->i_extra_isize = cpu_to_le16(ei->i_extra_isize); - } - -Index: linux-2.6.32-el6-beta/fs/ext4/ialloc.c -=================================================================== ---- linux-2.6.32-el6-beta.orig/fs/ext4/ialloc.c -+++ linux-2.6.32-el6-beta/fs/ext4/ialloc.c -@@ -1018,6 +1018,7 @@ got: - ei->i_dtime = 0; - ei->i_block_group = group; - ei->i_last_alloc_group = ~0; -+ ei->i_fs_version = 0; - - ext4_set_inode_flags(inode); - if (IS_DIRSYNC(inode)) -Index: linux-2.6.32-el6-beta/fs/ext4/ext4.h -=================================================================== ---- linux-2.6.32-el6-beta.orig/fs/ext4/ext4.h -+++ linux-2.6.32-el6-beta/fs/ext4/ext4.h -@@ -714,8 +714,12 @@ struct ext4_inode_info { - */ - tid_t i_sync_tid; - tid_t i_datasync_tid; -+ -+ __u64 i_fs_version; - }; - -+#define HAVE_DISK_INODE_VERSION -+ - /* - * File system states - */ diff --git a/ldiskfs/kernel_patches/patches/rhel6.3/ext4-journal-path-opt.patch b/ldiskfs/kernel_patches/patches/rhel6.3/ext4-journal-path-opt.patch deleted file mode 100644 index 73d7839..0000000 --- a/ldiskfs/kernel_patches/patches/rhel6.3/ext4-journal-path-opt.patch +++ /dev/null @@ -1,67 +0,0 @@ -diff -ur linux-stage.orig/fs/ext4/super.c linux-stage/fs/ext4/super.c ---- linux-stage.orig/fs/ext4/super.c 2013-09-26 11:25:51.970361560 -0400 -+++ linux-stage/fs/ext4/super.c 2013-09-26 11:46:25.078236831 -0400 -@@ -1274,7 +1274,7 @@ - Opt_user_xattr, Opt_nouser_xattr, Opt_acl, Opt_noacl, - Opt_auto_da_alloc, Opt_noauto_da_alloc, Opt_noload, Opt_nobh, Opt_bh, - Opt_commit, Opt_min_batch_time, Opt_max_batch_time, -- Opt_journal_update, Opt_journal_dev, -+ Opt_journal_update, Opt_journal_dev, Opt_journal_path, - Opt_journal_checksum, Opt_journal_async_commit, - Opt_abort, Opt_data_journal, Opt_data_ordered, Opt_data_writeback, - Opt_data_err_abort, Opt_data_err_ignore, -@@ -1323,6 +1323,7 @@ - {Opt_max_batch_time, "max_batch_time=%u"}, - {Opt_journal_update, "journal=update"}, - {Opt_journal_dev, "journal_dev=%u"}, -+ {Opt_journal_path, "journal_path=%s"}, - {Opt_journal_checksum, "journal_checksum"}, - {Opt_journal_async_commit, "journal_async_commit"}, - {Opt_abort, "abort"}, -@@ -1533,6 +1534,46 @@ - return 0; - *journal_devnum = option; - break; -+ case Opt_journal_path: { -+ char *journal_path; -+ struct inode *journal_inode; -+ struct path path; -+ int error; -+ -+ if (is_remount) { -+ ext4_msg(sb, KERN_ERR, -+ "Cannot specify journal on remount"); -+ return -1; -+ } -+ journal_path = match_strdup(&args[0]); -+ if (!journal_path) { -+ ext4_msg(sb, KERN_ERR, "error: could not dup " -+ "journal device string"); -+ return -1; -+ } -+ -+ error = kern_path(journal_path, LOOKUP_FOLLOW, &path); -+ if (error) { -+ ext4_msg(sb, KERN_ERR, "error: could not find " -+ "journal device path: error %d", error); -+ kfree(journal_path); -+ return -1; -+ } -+ -+ journal_inode = path.dentry->d_inode; -+ if (!S_ISBLK(journal_inode->i_mode)) { -+ ext4_msg(sb, KERN_ERR, "error: journal path %s " -+ "is not a block device", journal_path); -+ path_put(&path); -+ kfree(journal_path); -+ return -1; -+ } -+ -+ *journal_devnum = new_encode_dev(journal_inode->i_rdev); -+ path_put(&path); -+ kfree(journal_path); -+ break; -+ } - case Opt_journal_checksum: - set_opt(sbi->s_mount_opt, JOURNAL_CHECKSUM); - break; diff --git a/ldiskfs/kernel_patches/patches/rhel6.3/ext4-max-dir-size.patch b/ldiskfs/kernel_patches/patches/rhel6.3/ext4-max-dir-size.patch deleted file mode 100644 index 1820d69..0000000 --- a/ldiskfs/kernel_patches/patches/rhel6.3/ext4-max-dir-size.patch +++ /dev/null @@ -1,70 +0,0 @@ -Index: linux-stage/fs/ext4/namei.c -=================================================================== ---- linux-stage.orig/fs/ext4/namei.c -+++ linux-stage/fs/ext4/namei.c -@@ -60,6 +60,15 @@ struct buffer_head *ext4_append(handle_t - * have to be serialized -bzzz */ - down(&ei->i_append_sem); - -+ if (unlikely(S_ISDIR(inode->i_mode) && -+ EXT4_SB(inode->i_sb)->s_max_dir_size && -+ (inode->i_size >= -+ EXT4_SB(inode->i_sb)->s_max_dir_size))) { -+ *err = -ENOSPC; -+ up(&ei->i_append_sem); -+ return NULL; -+ } -+ - *block = inode->i_size >> inode->i_sb->s_blocksize_bits; - - bh = ext4_bread(handle, inode, *block, 1, err); -Index: linux-2.6.32-el6-beta/fs/ext4/super.c -=================================================================== ---- linux-2.6.32-el6-beta.orig/fs/ext4/super.c -+++ linux-2.6.32-el6-beta/fs/ext4/super.c -@@ -999,6 +999,9 @@ static int ext4_show_options(struct seq_ - seq_printf(seq, ",init_itable=%u", - (unsigned) sbi->s_li_wait_mult); - -+ if (sbi->s_max_dir_size) -+ seq_printf(seq, "max_dir_size=%lu", sbi->s_max_dir_size); -+ - ext4_show_quota_options(seq, sb); - - return 0; -@@ -2373,6 +2384,7 @@ EXT4_RO_ATTR(lifetime_write_kbytes); - EXT4_ATTR_OFFSET(inode_readahead_blks, 0644, sbi_ui_show, - inode_readahead_blks_store, s_inode_readahead_blks); - EXT4_RW_ATTR_SBI_UI(inode_goal, s_inode_goal); -+EXT4_RW_ATTR_SBI_UI(max_dir_size, s_max_dir_size); - EXT4_RW_ATTR_SBI_UI(mb_stats, s_mb_stats); - EXT4_RW_ATTR_SBI_UI(mb_max_to_scan, s_mb_max_to_scan); - EXT4_RW_ATTR_SBI_UI(mb_min_to_scan, s_mb_min_to_scan); -@@ -2388,6 +2400,7 @@ static struct attribute *ext4_attrs[] = - ATTR_LIST(lifetime_write_kbytes), - ATTR_LIST(inode_readahead_blks), - ATTR_LIST(inode_goal), -+ ATTR_LIST(max_dir_size), - ATTR_LIST(mb_stats), - ATTR_LIST(mb_max_to_scan), - ATTR_LIST(mb_min_to_scan), -@@ -2877,6 +2890,7 @@ static int ext4_fill_super(struct super_ - } - sb->s_fs_info = sbi; - sbi->s_mount_opt = 0; -+ sbi->s_max_dir_size = 0; - sbi->s_resuid = EXT4_DEF_RESUID; - sbi->s_resgid = EXT4_DEF_RESGID; - sbi->s_inode_readahead_blks = EXT4_DEF_INODE_READAHEAD_BLKS; -Index: linux-2.6.32-el6-beta/fs/ext4/ext4.h -=================================================================== ---- linux-2.6.32-el6-beta.orig/fs/ext4/ext4.h -+++ linux-2.6.32-el6-beta/fs/ext4/ext4.h -@@ -1113,6 +1113,7 @@ struct ext4_sb_info { - unsigned long s_mb_prealloc_table_size; - unsigned int s_mb_group_prealloc; - unsigned int s_max_writeback_mb_bump; -+ unsigned long s_max_dir_size; - /* where last allocation was done - for stream allocation */ - unsigned long s_mb_last_group; - unsigned long s_mb_last_start; diff --git a/ldiskfs/kernel_patches/patches/rhel6.3/ext4-nlink-2.6.patch b/ldiskfs/kernel_patches/patches/rhel6.3/ext4-nlink-2.6.patch deleted file mode 100644 index dcf3f33..0000000 --- a/ldiskfs/kernel_patches/patches/rhel6.3/ext4-nlink-2.6.patch +++ /dev/null @@ -1,36 +0,0 @@ -Index: linux-stage/fs/ext4/namei.c -=================================================================== ---- linux-stage.orig/fs/ext4/namei.c -+++ linux-stage/fs/ext4/namei.c -@@ -1609,7 +1709,7 @@ static void ext4_inc_count(handle_t *han - * DIR_NLINK feature is set if 1) nlinks > EXT4_LINK_MAX or 2) nlinks == 2, - * since this indicates that nlinks count was previously 1. - */ --static void ext4_inc_count(handle_t *handle, struct inode *inode) -+void ext4_inc_count(handle_t *handle, struct inode *inode) - { - inc_nlink(inode); - if (is_dx(inode) && inode->i_nlink > 1) { -@@ -1709,17 +1709,18 @@ static void ext4_inc_count(handle_t *han - } - } - } -+EXPORT_SYMBOL(ext4_inc_count); - - /* - * If a directory had nlink == 1, then we should let it be 1. This indicates - * directory has >EXT4_LINK_MAX subdirs. - */ --static void ext4_dec_count(handle_t *handle, struct inode *inode) -+void ext4_dec_count(handle_t *handle, struct inode *inode) - { -- drop_nlink(inode); -- if (S_ISDIR(inode->i_mode) && inode->i_nlink == 0) -- inc_nlink(inode); -+ if (!S_ISDIR(inode->i_mode) || inode->i_nlink > 2) -+ drop_nlink(inode); - } -+EXPORT_SYMBOL(ext4_dec_count); - - - static int ext4_add_nondir(handle_t *handle, diff --git a/ldiskfs/kernel_patches/patches/rhel6.3/ext4-nocmtime-2.6.patch b/ldiskfs/kernel_patches/patches/rhel6.3/ext4-nocmtime-2.6.patch deleted file mode 100644 index bbc8853..0000000 --- a/ldiskfs/kernel_patches/patches/rhel6.3/ext4-nocmtime-2.6.patch +++ /dev/null @@ -1,14 +0,0 @@ -Index: linux-stage/fs/ext4/ext4.h -=================================================================== ---- linux-stage.orig/fs/ext4/ext4.h -+++ linux-stage/fs/ext4/ext4.h -@@ -1213,6 +1213,9 @@ static inline struct ext4_inode_info *EX - - static inline struct timespec ext4_current_time(struct inode *inode) - { -+ if (IS_NOCMTIME(inode)) -+ return inode->i_ctime; -+ - return (inode->i_sb->s_time_gran < NSEC_PER_SEC) ? - current_fs_time(inode->i_sb) : CURRENT_TIME_SEC; - } diff --git a/ldiskfs/kernel_patches/patches/rhel6.3/ext4-not-discard-preallocation-umount.patch b/ldiskfs/kernel_patches/patches/rhel6.3/ext4-not-discard-preallocation-umount.patch deleted file mode 100644 index a52d91f..0000000 --- a/ldiskfs/kernel_patches/patches/rhel6.3/ext4-not-discard-preallocation-umount.patch +++ /dev/null @@ -1,14 +0,0 @@ -Index: linux-stage/fs/ext4/mballoc.c -=================================================================== ---- linux-stage.orig/fs/ext4/mballoc.c -+++ linux-stage/fs/ext4/mballoc.c -@@ -3781,7 +3781,8 @@ ext4_mb_release_inode_pa(struct ext4_bud - * from the bitmap and continue. - */ - } -- BUG_ON(pa->pa_free != free); -+ /* do not verify if the file system is being umounted */ -+ BUG_ON(atomic_read(&sb->s_active) > 0 && pa->pa_free != free); - atomic_add(free, &sbi->s_mb_discarded); - - return err; diff --git a/ldiskfs/kernel_patches/patches/rhel6.3/ext4-osd-iam-exports.patch b/ldiskfs/kernel_patches/patches/rhel6.3/ext4-osd-iam-exports.patch deleted file mode 100644 index 3bae32f..0000000 --- a/ldiskfs/kernel_patches/patches/rhel6.3/ext4-osd-iam-exports.patch +++ /dev/null @@ -1,64 +0,0 @@ -diff -rupN 2.6.27.21_2/fs/ext4/ext4.h 2.6.27.21_3/fs/ext4/ext4.h ---- 2.6.27.21_2/fs/ext4/ext4.h 2009-07-17 12:19:59.000000000 +0530 -+++ 2.6.27.21_3/fs/ext4/ext4.h 2009-07-17 12:38:59.000000000 +0530 -@@ -1181,6 +1181,9 @@ extern int ext4_orphan_add(handle_t *, s - #define ll_ext4_find_entry(inode, dentry, res_dir) ext4_find_entry(inode, &(dentry)->d_name, res_dir) - extern int ext4_add_dot_dotdot(handle_t *handle, struct inode *dir, - struct inode *inode); -+extern struct buffer_head *ext4_append(handle_t *handle, -+ struct inode *inode, -+ ext4_lblk_t *block, int *err); - - /* resize.c */ - extern int ext4_group_add(struct super_block *sb, -diff -rupN 2.6.27.21_2/fs/ext4/hash.c 2.6.27.21_3/fs/ext4/hash.c ---- 2.6.27.21_2/fs/ext4/hash.c 2009-07-17 12:12:56.000000000 +0530 -+++ 2.6.27.21_3/fs/ext4/hash.c 2009-07-17 12:40:22.000000000 +0530 -@@ -9,6 +9,7 @@ - * License. - */ - -+#include - #include - #include - #include -@@ -206,3 +207,4 @@ int ext4fs_dirhash(const char *name, int - hinfo->minor_hash = minor_hash; - return 0; - } -+EXPORT_SYMBOL(ext4fs_dirhash); -diff -rupN 2.6.27.21_2/fs/ext4/namei.c 2.6.27.21_3/fs/ext4/namei.c ---- 2.6.27.21_2/fs/ext4/namei.c 2009-07-17 12:23:51.000000000 +0530 -+++ 2.6.27.21_3/fs/ext4/namei.c 2009-07-17 12:37:59.000000000 +0530 -@@ -51,9 +51,9 @@ - #define NAMEI_RA_SIZE (NAMEI_RA_CHUNKS * NAMEI_RA_BLOCKS) - #define NAMEI_RA_INDEX(c,b) (((c) * NAMEI_RA_BLOCKS) + (b)) - --static struct buffer_head *ext4_append(handle_t *handle, -- struct inode *inode, -- ext4_lblk_t *block, int *err) -+struct buffer_head *ext4_append(handle_t *handle, -+ struct inode *inode, -+ ext4_lblk_t *block, int *err) - { - struct buffer_head *bh; - struct ext4_inode_info *ei = EXT4_I(inode); -@@ -72,6 +72,7 @@ static struct buffer_head *ext4_append(h - up(&ei->i_append_sem); - return bh; - } -+EXPORT_SYMBOL(ext4_append); - - #ifndef assert - #define assert(test) J_ASSERT(test) -diff -rupN 2.6.27.21_2/fs/ext4/super.c 2.6.27.21_3/fs/ext4/super.c ---- 2.6.27.21_2/fs/ext4/super.c 2009-07-17 12:12:57.000000000 +0530 -+++ 2.6.27.21_3/fs/ext4/super.c 2009-07-17 12:40:52.000000000 +0530 -@@ -377,6 +377,7 @@ void __ext4_std_error(struct super_block - - ext4_handle_error(sb); - } -+EXPORT_SYMBOL(__ext4_std_error); - - /* - * ext4_abort is a much stronger failure handler than ext4_error. The diff --git a/ldiskfs/kernel_patches/patches/rhel6.3/ext4-pdir-fix.patch b/ldiskfs/kernel_patches/patches/rhel6.3/ext4-pdir-fix.patch deleted file mode 100644 index 0f261d1..0000000 --- a/ldiskfs/kernel_patches/patches/rhel6.3/ext4-pdir-fix.patch +++ /dev/null @@ -1,52 +0,0 @@ -Index: linux-stage/fs/ext4/ext4.h -=================================================================== ---- linux-stage.orig/fs/ext4/ext4.h 2012-08-07 11:52:38.994200699 -0700 -+++ linux-stage/fs/ext4/ext4.h 2012-08-07 12:28:19.497442862 -0700 -@@ -706,6 +707,9 @@ - __u32 i_dtime; - ext4_fsblk_t i_file_acl; - -+ /* following fields for parallel directory operations -bzzz */ -+ struct semaphore i_append_sem; -+ - /* - * i_block_group is the number of the block group which contains - * this file's inode. Constant across the lifetime of the inode, -Index: linux-stage/fs/ext4/namei.c -=================================================================== ---- linux-stage.orig/fs/ext4/namei.c 2012-08-07 11:52:38.992199430 -0700 -+++ linux-stage/fs/ext4/namei.c 2012-08-07 12:27:24.845281099 -0700 -@@ -53,6 +53,11 @@ - ext4_lblk_t *block, int *err) - { - struct buffer_head *bh; -+ struct ext4_inode_info *ei = EXT4_I(inode); -+ -+ /* with parallel dir operations all appends -+ * have to be serialized -bzzz */ -+ down(&ei->i_append_sem); - - *block = inode->i_size >> inode->i_sb->s_blocksize_bits; - -@@ -65,7 +70,9 @@ - brelse(bh); - bh = NULL; - } -+ ei->i_disksize = inode->i_size; - } -+ up(&ei->i_append_sem); - return bh; - } - -Index: linux-stage/fs/ext4/super.c -=================================================================== ---- linux-stage.orig/fs/ext4/super.c 2012-08-07 11:52:39.009197356 -0700 -+++ linux-stage/fs/ext4/super.c 2012-08-07 12:28:29.499112997 -0700 -@@ -749,6 +749,7 @@ - - ei->vfs_inode.i_version = 1; - ei->vfs_inode.i_data.writeback_index = 0; -+ sema_init(&ei->i_append_sem, 1); - memset(&ei->i_cached_extent, 0, sizeof(struct ext4_ext_cache)); - INIT_LIST_HEAD(&ei->i_prealloc_list); - spin_lock_init(&ei->i_prealloc_lock); diff --git a/ldiskfs/kernel_patches/patches/rhel6.3/ext4-pdirop.patch b/ldiskfs/kernel_patches/patches/rhel6.3/ext4-pdirop.patch deleted file mode 100644 index 0bbed17..0000000 --- a/ldiskfs/kernel_patches/patches/rhel6.3/ext4-pdirop.patch +++ /dev/null @@ -1,1872 +0,0 @@ -Index: linux-2.6.32-504.3.3.el6.x86_64/include/linux/htree_lock.h -=================================================================== ---- /dev/null -+++ linux-2.6.32-504.3.3.el6.x86_64/include/linux/htree_lock.h -@@ -0,0 +1,187 @@ -+/* -+ * include/linux/htree_lock.h -+ * -+ * Copyright (c) 2011, 2012, Intel Corporation. -+ * -+ * Author: Liang Zhen -+ */ -+ -+/* -+ * htree lock -+ * -+ * htree_lock is an advanced lock, it can support five lock modes (concept is -+ * taken from DLM) and it's a sleeping lock. -+ * -+ * most common use case is: -+ * - create a htree_lock_head for data -+ * - each thread (contender) creates it's own htree_lock -+ * - contender needs to call htree_lock(lock_node, mode) to protect data and -+ * call htree_unlock to release lock -+ * -+ * Also, there is advanced use-case which is more complex, user can have -+ * PW/PR lock on particular key, it's mostly used while user holding shared -+ * lock on the htree (CW, CR) -+ * -+ * htree_lock(lock_node, HTREE_LOCK_CR); lock the htree with CR -+ * htree_node_lock(lock_node, HTREE_LOCK_PR, key...); lock @key with PR -+ * ... -+ * htree_node_unlock(lock_node);; unlock the key -+ * -+ * Another tip is, we can have N-levels of this kind of keys, all we need to -+ * do is specifying N-levels while creating htree_lock_head, then we can -+ * lock/unlock a specific level by: -+ * htree_node_lock(lock_node, mode1, key1, level1...); -+ * do something; -+ * htree_node_lock(lock_node, mode1, key2, level2...); -+ * do something; -+ * htree_node_unlock(lock_node, level2); -+ * htree_node_unlock(lock_node, level1); -+ * -+ * NB: for multi-level, should be careful about locking order to avoid deadlock -+ */ -+ -+#ifndef _LINUX_HTREE_LOCK_H -+#define _LINUX_HTREE_LOCK_H -+ -+#include -+#include -+#include -+ -+/* -+ * Lock Modes -+ * more details can be found here: -+ * http://en.wikipedia.org/wiki/Distributed_lock_manager -+ */ -+typedef enum { -+ HTREE_LOCK_EX = 0, /* exclusive lock: incompatible with all others */ -+ HTREE_LOCK_PW, /* protected write: allows only CR users */ -+ HTREE_LOCK_PR, /* protected read: allow PR, CR users */ -+ HTREE_LOCK_CW, /* concurrent write: allow CR, CW users */ -+ HTREE_LOCK_CR, /* concurrent read: allow all but EX users */ -+ HTREE_LOCK_MAX, /* number of lock modes */ -+} htree_lock_mode_t; -+ -+#define HTREE_LOCK_NL HTREE_LOCK_MAX -+#define HTREE_LOCK_INVAL 0xdead10c -+ -+enum { -+ HTREE_HBITS_MIN = 2, -+ HTREE_HBITS_DEF = 14, -+ HTREE_HBITS_MAX = 32, -+}; -+ -+enum { -+ HTREE_EVENT_DISABLE = (0), -+ HTREE_EVENT_RD = (1 << HTREE_LOCK_PR), -+ HTREE_EVENT_WR = (1 << HTREE_LOCK_PW), -+ HTREE_EVENT_RDWR = (HTREE_EVENT_RD | HTREE_EVENT_WR), -+}; -+ -+struct htree_lock; -+ -+typedef void (*htree_event_cb_t)(void *target, void *event); -+ -+struct htree_lock_child { -+ struct list_head lc_list; /* granted list */ -+ htree_event_cb_t lc_callback; /* event callback */ -+ unsigned lc_events; /* event types */ -+}; -+ -+struct htree_lock_head { -+ unsigned long lh_lock; /* bits lock */ -+ /* blocked lock list (htree_lock) */ -+ struct list_head lh_blocked_list; -+ /* # key levels */ -+ u16 lh_depth; -+ /* hash bits for key and limit number of locks */ -+ u16 lh_hbits; -+ /* counters for blocked locks */ -+ u16 lh_nblocked[HTREE_LOCK_MAX]; -+ /* counters for granted locks */ -+ u16 lh_ngranted[HTREE_LOCK_MAX]; -+ /* private data */ -+ void *lh_private; -+ /* array of children locks */ -+ struct htree_lock_child lh_children[0]; -+}; -+ -+/* htree_lock_node_t is child-lock for a specific key (ln_value) */ -+struct htree_lock_node { -+ htree_lock_mode_t ln_mode; -+ /* major hash key */ -+ u16 ln_major_key; -+ /* minor hash key */ -+ u16 ln_minor_key; -+ struct list_head ln_major_list; -+ struct list_head ln_minor_list; -+ /* alive list, all locks (granted, blocked, listening) are on it */ -+ struct list_head ln_alive_list; -+ /* blocked list */ -+ struct list_head ln_blocked_list; -+ /* granted list */ -+ struct list_head ln_granted_list; -+ void *ln_ev_target; -+}; -+ -+struct htree_lock { -+ struct task_struct *lk_task; -+ struct htree_lock_head *lk_head; -+ void *lk_private; -+ unsigned lk_depth; -+ htree_lock_mode_t lk_mode; -+ struct list_head lk_blocked_list; -+ struct htree_lock_node lk_nodes[0]; -+}; -+ -+/* create a lock head, which stands for a resource */ -+struct htree_lock_head *htree_lock_head_alloc(unsigned depth, -+ unsigned hbits, unsigned priv); -+/* free a lock head */ -+void htree_lock_head_free(struct htree_lock_head *lhead); -+/* register event callback for child lock at level @depth */ -+void htree_lock_event_attach(struct htree_lock_head *lhead, unsigned depth, -+ unsigned events, htree_event_cb_t callback); -+/* create a lock handle, which stands for a thread */ -+struct htree_lock *htree_lock_alloc(unsigned depth, unsigned pbytes); -+/* free a lock handle */ -+void htree_lock_free(struct htree_lock *lck); -+/* lock htree, when @wait is true, 0 is returned if the lock can't -+ * be granted immediately */ -+int htree_lock_try(struct htree_lock *lck, struct htree_lock_head *lhead, -+ htree_lock_mode_t mode, int wait); -+/* unlock htree */ -+void htree_unlock(struct htree_lock *lck); -+/* unlock and relock htree with @new_mode */ -+int htree_change_lock_try(struct htree_lock *lck, -+ htree_lock_mode_t new_mode, int wait); -+void htree_change_mode(struct htree_lock *lck, htree_lock_mode_t mode); -+/* require child lock (key) of htree at level @dep, @event will be sent to all -+ * listeners on this @key while lock being granted */ -+int htree_node_lock_try(struct htree_lock *lck, htree_lock_mode_t mode, -+ u32 key, unsigned dep, int wait, void *event); -+/* release child lock at level @dep, this lock will listen on it's key -+ * if @event isn't NULL, event_cb will be called against @lck while granting -+ * any other lock at level @dep with the same key */ -+void htree_node_unlock(struct htree_lock *lck, unsigned dep, void *event); -+/* stop listening on child lock at level @dep */ -+void htree_node_stop_listen(struct htree_lock *lck, unsigned dep); -+/* for debug */ -+void htree_lock_stat_print(int depth); -+void htree_lock_stat_reset(void); -+ -+#define htree_lock(lck, lh, mode) htree_lock_try(lck, lh, mode, 1) -+#define htree_change_lock(lck, mode) htree_change_lock_try(lck, mode, 1) -+ -+#define htree_lock_mode(lck) ((lck)->lk_mode) -+ -+#define htree_node_lock(lck, mode, key, dep) \ -+ htree_node_lock_try(lck, mode, key, dep, 1, NULL) -+/* this is only safe in thread context of lock owner */ -+#define htree_node_is_granted(lck, dep) \ -+ ((lck)->lk_nodes[dep].ln_mode != HTREE_LOCK_INVAL && \ -+ (lck)->lk_nodes[dep].ln_mode != HTREE_LOCK_NL) -+/* this is only safe in thread context of lock owner */ -+#define htree_node_is_listening(lck, dep) \ -+ ((lck)->lk_nodes[dep].ln_mode == HTREE_LOCK_NL) -+ -+#endif -Index: linux-2.6.32-504.3.3.el6.x86_64/fs/ext4/htree_lock.c -=================================================================== ---- /dev/null -+++ linux-2.6.32-504.3.3.el6.x86_64/fs/ext4/htree_lock.c -@@ -0,0 +1,880 @@ -+/* -+ * fs/ext4/htree_lock.c -+ * -+ * Copyright (c) 2011, 2012, Intel Corporation. -+ * -+ * Author: Liang Zhen -+ */ -+#include -+#include -+#include -+#include -+ -+enum { -+ HTREE_LOCK_BIT_EX = (1 << HTREE_LOCK_EX), -+ HTREE_LOCK_BIT_PW = (1 << HTREE_LOCK_PW), -+ HTREE_LOCK_BIT_PR = (1 << HTREE_LOCK_PR), -+ HTREE_LOCK_BIT_CW = (1 << HTREE_LOCK_CW), -+ HTREE_LOCK_BIT_CR = (1 << HTREE_LOCK_CR), -+}; -+ -+enum { -+ HTREE_LOCK_COMPAT_EX = 0, -+ HTREE_LOCK_COMPAT_PW = HTREE_LOCK_COMPAT_EX | HTREE_LOCK_BIT_CR, -+ HTREE_LOCK_COMPAT_PR = HTREE_LOCK_COMPAT_PW | HTREE_LOCK_BIT_PR, -+ HTREE_LOCK_COMPAT_CW = HTREE_LOCK_COMPAT_PW | HTREE_LOCK_BIT_CW, -+ HTREE_LOCK_COMPAT_CR = HTREE_LOCK_COMPAT_CW | HTREE_LOCK_BIT_PR | -+ HTREE_LOCK_BIT_PW, -+}; -+ -+static int htree_lock_compat[] = { -+ [HTREE_LOCK_EX] HTREE_LOCK_COMPAT_EX, -+ [HTREE_LOCK_PW] HTREE_LOCK_COMPAT_PW, -+ [HTREE_LOCK_PR] HTREE_LOCK_COMPAT_PR, -+ [HTREE_LOCK_CW] HTREE_LOCK_COMPAT_CW, -+ [HTREE_LOCK_CR] HTREE_LOCK_COMPAT_CR, -+}; -+ -+/* max allowed htree-lock depth. -+ * We only need depth=3 for ext4 although user can have higher value. */ -+#define HTREE_LOCK_DEP_MAX 16 -+ -+#ifdef HTREE_LOCK_DEBUG -+ -+static char *hl_name[] = { -+ [HTREE_LOCK_EX] "EX", -+ [HTREE_LOCK_PW] "PW", -+ [HTREE_LOCK_PR] "PR", -+ [HTREE_LOCK_CW] "CW", -+ [HTREE_LOCK_CR] "CR", -+}; -+ -+/* lock stats */ -+struct htree_lock_node_stats { -+ unsigned long long blocked[HTREE_LOCK_MAX]; -+ unsigned long long granted[HTREE_LOCK_MAX]; -+ unsigned long long retried[HTREE_LOCK_MAX]; -+ unsigned long long events; -+}; -+ -+struct htree_lock_stats { -+ struct htree_lock_node_stats nodes[HTREE_LOCK_DEP_MAX]; -+ unsigned long long granted[HTREE_LOCK_MAX]; -+ unsigned long long blocked[HTREE_LOCK_MAX]; -+}; -+ -+static struct htree_lock_stats hl_stats; -+ -+void htree_lock_stat_reset(void) -+{ -+ memset(&hl_stats, 0, sizeof(hl_stats)); -+} -+ -+void htree_lock_stat_print(int depth) -+{ -+ int i; -+ int j; -+ -+ printk(KERN_DEBUG "HTREE LOCK STATS:\n"); -+ for (i = 0; i < HTREE_LOCK_MAX; i++) { -+ printk(KERN_DEBUG "[%s]: G [%10llu], B [%10llu]\n", -+ hl_name[i], hl_stats.granted[i], hl_stats.blocked[i]); -+ } -+ for (i = 0; i < depth; i++) { -+ printk(KERN_DEBUG "HTREE CHILD [%d] STATS:\n", i); -+ for (j = 0; j < HTREE_LOCK_MAX; j++) { -+ printk(KERN_DEBUG -+ "[%s]: G [%10llu], B [%10llu], R [%10llu]\n", -+ hl_name[j], hl_stats.nodes[i].granted[j], -+ hl_stats.nodes[i].blocked[j], -+ hl_stats.nodes[i].retried[j]); -+ } -+ } -+} -+ -+#define lk_grant_inc(m) do { hl_stats.granted[m]++; } while (0) -+#define lk_block_inc(m) do { hl_stats.blocked[m]++; } while (0) -+#define ln_grant_inc(d, m) do { hl_stats.nodes[d].granted[m]++; } while (0) -+#define ln_block_inc(d, m) do { hl_stats.nodes[d].blocked[m]++; } while (0) -+#define ln_retry_inc(d, m) do { hl_stats.nodes[d].retried[m]++; } while (0) -+#define ln_event_inc(d) do { hl_stats.nodes[d].events++; } while (0) -+ -+#else /* !DEBUG */ -+ -+void htree_lock_stat_reset(void) {} -+void htree_lock_stat_print(int depth) {} -+ -+#define lk_grant_inc(m) do {} while (0) -+#define lk_block_inc(m) do {} while (0) -+#define ln_grant_inc(d, m) do {} while (0) -+#define ln_block_inc(d, m) do {} while (0) -+#define ln_retry_inc(d, m) do {} while (0) -+#define ln_event_inc(d) do {} while (0) -+ -+#endif /* DEBUG */ -+ -+EXPORT_SYMBOL(htree_lock_stat_reset); -+EXPORT_SYMBOL(htree_lock_stat_print); -+ -+#define HTREE_DEP_ROOT (-1) -+ -+#define htree_spin_lock(lhead, dep) \ -+ bit_spin_lock((dep) + 1, &(lhead)->lh_lock) -+#define htree_spin_unlock(lhead, dep) \ -+ bit_spin_unlock((dep) + 1, &(lhead)->lh_lock) -+ -+#define htree_key_event_ignore(child, ln) \ -+ (!((child)->lc_events & (1 << (ln)->ln_mode))) -+ -+static int -+htree_key_list_empty(struct htree_lock_node *ln) -+{ -+ return list_empty(&ln->ln_major_list) && list_empty(&ln->ln_minor_list); -+} -+ -+static void -+htree_key_list_del_init(struct htree_lock_node *ln) -+{ -+ struct htree_lock_node *tmp = NULL; -+ -+ if (!list_empty(&ln->ln_minor_list)) { -+ tmp = list_entry(ln->ln_minor_list.next, -+ struct htree_lock_node, ln_minor_list); -+ list_del_init(&ln->ln_minor_list); -+ } -+ -+ if (list_empty(&ln->ln_major_list)) -+ return; -+ -+ if (tmp == NULL) { /* not on minor key list */ -+ list_del_init(&ln->ln_major_list); -+ } else { -+ BUG_ON(!list_empty(&tmp->ln_major_list)); -+ list_replace_init(&ln->ln_major_list, &tmp->ln_major_list); -+ } -+} -+ -+static void -+htree_key_list_replace_init(struct htree_lock_node *old, -+ struct htree_lock_node *new) -+{ -+ if (!list_empty(&old->ln_major_list)) -+ list_replace_init(&old->ln_major_list, &new->ln_major_list); -+ -+ if (!list_empty(&old->ln_minor_list)) -+ list_replace_init(&old->ln_minor_list, &new->ln_minor_list); -+} -+ -+static void -+htree_key_event_enqueue(struct htree_lock_child *child, -+ struct htree_lock_node *ln, int dep, void *event) -+{ -+ struct htree_lock_node *tmp; -+ -+ /* NB: ALWAYS called holding lhead::lh_lock(dep) */ -+ BUG_ON(ln->ln_mode == HTREE_LOCK_NL); -+ if (event == NULL || htree_key_event_ignore(child, ln)) -+ return; -+ -+ /* shouldn't be a very long list */ -+ list_for_each_entry(tmp, &ln->ln_alive_list, ln_alive_list) { -+ if (tmp->ln_mode == HTREE_LOCK_NL) { -+ ln_event_inc(dep); -+ if (child->lc_callback != NULL) -+ child->lc_callback(tmp->ln_ev_target, event); -+ } -+ } -+} -+ -+static int -+htree_node_lock_enqueue(struct htree_lock *newlk, struct htree_lock *curlk, -+ unsigned dep, int wait, void *event) -+{ -+ struct htree_lock_child *child = &newlk->lk_head->lh_children[dep]; -+ struct htree_lock_node *newln = &newlk->lk_nodes[dep]; -+ struct htree_lock_node *curln = &curlk->lk_nodes[dep]; -+ -+ /* NB: ALWAYS called holding lhead::lh_lock(dep) */ -+ /* NB: we only expect PR/PW lock mode at here, only these two modes are -+ * allowed for htree_node_lock(asserted in htree_node_lock_internal), -+ * NL is only used for listener, user can't directly require NL mode */ -+ if ((curln->ln_mode == HTREE_LOCK_NL) || -+ (curln->ln_mode != HTREE_LOCK_PW && -+ newln->ln_mode != HTREE_LOCK_PW)) { -+ /* no conflict, attach it on granted list of @curlk */ -+ if (curln->ln_mode != HTREE_LOCK_NL) { -+ list_add(&newln->ln_granted_list, -+ &curln->ln_granted_list); -+ } else { -+ /* replace key owner */ -+ htree_key_list_replace_init(curln, newln); -+ } -+ -+ list_add(&newln->ln_alive_list, &curln->ln_alive_list); -+ htree_key_event_enqueue(child, newln, dep, event); -+ ln_grant_inc(dep, newln->ln_mode); -+ return 1; /* still hold lh_lock */ -+ } -+ -+ if (!wait) { /* can't grant and don't want to wait */ -+ ln_retry_inc(dep, newln->ln_mode); -+ newln->ln_mode = HTREE_LOCK_INVAL; -+ return -1; /* don't wait and just return -1 */ -+ } -+ -+ newlk->lk_task = current; -+ set_current_state(TASK_UNINTERRUPTIBLE); -+ /* conflict, attach it on blocked list of curlk */ -+ list_add_tail(&newln->ln_blocked_list, &curln->ln_blocked_list); -+ list_add(&newln->ln_alive_list, &curln->ln_alive_list); -+ ln_block_inc(dep, newln->ln_mode); -+ -+ htree_spin_unlock(newlk->lk_head, dep); -+ /* wait to be given the lock */ -+ if (newlk->lk_task != NULL) -+ schedule(); -+ /* granted, no doubt, wake up will set me RUNNING */ -+ if (event == NULL || htree_key_event_ignore(child, newln)) -+ return 0; /* granted without lh_lock */ -+ -+ htree_spin_lock(newlk->lk_head, dep); -+ htree_key_event_enqueue(child, newln, dep, event); -+ return 1; /* still hold lh_lock */ -+} -+ -+/* -+ * get PR/PW access to particular tree-node according to @dep and @key, -+ * it will return -1 if @wait is false and can't immediately grant this lock. -+ * All listeners(HTREE_LOCK_NL) on @dep and with the same @key will get -+ * @event if it's not NULL. -+ * NB: ALWAYS called holding lhead::lh_lock -+ */ -+static int -+htree_node_lock_internal(struct htree_lock_head *lhead, struct htree_lock *lck, -+ htree_lock_mode_t mode, u32 key, unsigned dep, -+ int wait, void *event) -+{ -+ LIST_HEAD (list); -+ struct htree_lock *tmp; -+ struct htree_lock *tmp2; -+ u16 major; -+ u16 minor; -+ u8 reverse; -+ u8 ma_bits; -+ u8 mi_bits; -+ -+ BUG_ON(mode != HTREE_LOCK_PW && mode != HTREE_LOCK_PR); -+ BUG_ON(htree_node_is_granted(lck, dep)); -+ -+ key = hash_long(key, lhead->lh_hbits); -+ -+ mi_bits = lhead->lh_hbits >> 1; -+ ma_bits = lhead->lh_hbits - mi_bits; -+ -+ lck->lk_nodes[dep].ln_major_key = major = key & ((1U << ma_bits) - 1); -+ lck->lk_nodes[dep].ln_minor_key = minor = key >> ma_bits; -+ lck->lk_nodes[dep].ln_mode = mode; -+ -+ /* -+ * The major key list is an ordered list, so searches are started -+ * at the end of the list that is numerically closer to major_key, -+ * so at most half of the list will be walked (for well-distributed -+ * keys). The list traversal aborts early if the expected key -+ * location is passed. -+ */ -+ reverse = (major >= (1 << (ma_bits - 1))); -+ -+ if (reverse) { -+ list_for_each_entry_reverse(tmp, -+ &lhead->lh_children[dep].lc_list, -+ lk_nodes[dep].ln_major_list) { -+ if (tmp->lk_nodes[dep].ln_major_key == major) { -+ goto search_minor; -+ -+ } else if (tmp->lk_nodes[dep].ln_major_key < major) { -+ /* attach _after_ @tmp */ -+ list_add(&lck->lk_nodes[dep].ln_major_list, -+ &tmp->lk_nodes[dep].ln_major_list); -+ goto out_grant_major; -+ } -+ } -+ -+ list_add(&lck->lk_nodes[dep].ln_major_list, -+ &lhead->lh_children[dep].lc_list); -+ goto out_grant_major; -+ -+ } else { -+ list_for_each_entry(tmp, &lhead->lh_children[dep].lc_list, -+ lk_nodes[dep].ln_major_list) { -+ if (tmp->lk_nodes[dep].ln_major_key == major) { -+ goto search_minor; -+ -+ } else if (tmp->lk_nodes[dep].ln_major_key > major) { -+ /* insert _before_ @tmp */ -+ list_add_tail(&lck->lk_nodes[dep].ln_major_list, -+ &tmp->lk_nodes[dep].ln_major_list); -+ goto out_grant_major; -+ } -+ } -+ -+ list_add_tail(&lck->lk_nodes[dep].ln_major_list, -+ &lhead->lh_children[dep].lc_list); -+ goto out_grant_major; -+ } -+ -+ search_minor: -+ /* -+ * NB: minor_key list doesn't have a "head", @list is just a -+ * temporary stub for helping list searching, make sure it's removed -+ * after searching. -+ * minor_key list is an ordered list too. -+ */ -+ list_add_tail(&list, &tmp->lk_nodes[dep].ln_minor_list); -+ -+ reverse = (minor >= (1 << (mi_bits - 1))); -+ -+ if (reverse) { -+ list_for_each_entry_reverse(tmp2, &list, -+ lk_nodes[dep].ln_minor_list) { -+ if (tmp2->lk_nodes[dep].ln_minor_key == minor) { -+ goto out_enqueue; -+ -+ } else if (tmp2->lk_nodes[dep].ln_minor_key < minor) { -+ /* attach _after_ @tmp2 */ -+ list_add(&lck->lk_nodes[dep].ln_minor_list, -+ &tmp2->lk_nodes[dep].ln_minor_list); -+ goto out_grant_minor; -+ } -+ } -+ -+ list_add(&lck->lk_nodes[dep].ln_minor_list, &list); -+ -+ } else { -+ list_for_each_entry(tmp2, &list, -+ lk_nodes[dep].ln_minor_list) { -+ if (tmp2->lk_nodes[dep].ln_minor_key == minor) { -+ goto out_enqueue; -+ -+ } else if (tmp2->lk_nodes[dep].ln_minor_key > minor) { -+ /* insert _before_ @tmp2 */ -+ list_add_tail(&lck->lk_nodes[dep].ln_minor_list, -+ &tmp2->lk_nodes[dep].ln_minor_list); -+ goto out_grant_minor; -+ } -+ } -+ -+ list_add_tail(&lck->lk_nodes[dep].ln_minor_list, &list); -+ } -+ -+ out_grant_minor: -+ if (list.next == &lck->lk_nodes[dep].ln_minor_list) { -+ /* new lock @lck is the first one on minor_key list, which -+ * means it has the smallest minor_key and it should -+ * replace @tmp as minor_key owner */ -+ list_replace_init(&tmp->lk_nodes[dep].ln_major_list, -+ &lck->lk_nodes[dep].ln_major_list); -+ } -+ /* remove the temporary head */ -+ list_del(&list); -+ -+ out_grant_major: -+ ln_grant_inc(dep, lck->lk_nodes[dep].ln_mode); -+ return 1; /* granted with holding lh_lock */ -+ -+ out_enqueue: -+ list_del(&list); /* remove temprary head */ -+ return htree_node_lock_enqueue(lck, tmp2, dep, wait, event); -+} -+ -+/* -+ * release the key of @lck at level @dep, and grant any blocked locks. -+ * caller will still listen on @key if @event is not NULL, which means -+ * caller can see a event (by event_cb) while granting any lock with -+ * the same key at level @dep. -+ * NB: ALWAYS called holding lhead::lh_lock -+ * NB: listener will not block anyone because listening mode is HTREE_LOCK_NL -+ */ -+static void -+htree_node_unlock_internal(struct htree_lock_head *lhead, -+ struct htree_lock *curlk, unsigned dep, void *event) -+{ -+ struct htree_lock_node *curln = &curlk->lk_nodes[dep]; -+ struct htree_lock *grtlk = NULL; -+ struct htree_lock_node *grtln; -+ struct htree_lock *poslk; -+ struct htree_lock *tmplk; -+ -+ if (!htree_node_is_granted(curlk, dep)) -+ return; -+ -+ if (!list_empty(&curln->ln_granted_list)) { -+ /* there is another granted lock */ -+ grtlk = list_entry(curln->ln_granted_list.next, -+ struct htree_lock, -+ lk_nodes[dep].ln_granted_list); -+ list_del_init(&curln->ln_granted_list); -+ } -+ -+ if (grtlk == NULL && !list_empty(&curln->ln_blocked_list)) { -+ /* -+ * @curlk is the only granted lock, so we confirmed: -+ * a) curln is key owner (attached on major/minor_list), -+ * so if there is any blocked lock, it should be attached -+ * on curln->ln_blocked_list -+ * b) we always can grant the first blocked lock -+ */ -+ grtlk = list_entry(curln->ln_blocked_list.next, -+ struct htree_lock, -+ lk_nodes[dep].ln_blocked_list); -+ BUG_ON(grtlk->lk_task == NULL); -+ wake_up_process(grtlk->lk_task); -+ } -+ -+ if (event != NULL && -+ lhead->lh_children[dep].lc_events != HTREE_EVENT_DISABLE) { -+ curln->ln_ev_target = event; -+ curln->ln_mode = HTREE_LOCK_NL; /* listen! */ -+ } else { -+ curln->ln_mode = HTREE_LOCK_INVAL; -+ } -+ -+ if (grtlk == NULL) { /* I must be the only one locking this key */ -+ struct htree_lock_node *tmpln; -+ -+ BUG_ON(htree_key_list_empty(curln)); -+ -+ if (curln->ln_mode == HTREE_LOCK_NL) /* listening */ -+ return; -+ -+ /* not listening */ -+ if (list_empty(&curln->ln_alive_list)) { /* no more listener */ -+ htree_key_list_del_init(curln); -+ return; -+ } -+ -+ tmpln = list_entry(curln->ln_alive_list.next, -+ struct htree_lock_node, ln_alive_list); -+ -+ BUG_ON(tmpln->ln_mode != HTREE_LOCK_NL); -+ -+ htree_key_list_replace_init(curln, tmpln); -+ list_del_init(&curln->ln_alive_list); -+ -+ return; -+ } -+ -+ /* have a granted lock */ -+ grtln = &grtlk->lk_nodes[dep]; -+ if (!list_empty(&curln->ln_blocked_list)) { -+ /* only key owner can be on both lists */ -+ BUG_ON(htree_key_list_empty(curln)); -+ -+ if (list_empty(&grtln->ln_blocked_list)) { -+ list_add(&grtln->ln_blocked_list, -+ &curln->ln_blocked_list); -+ } -+ list_del_init(&curln->ln_blocked_list); -+ } -+ /* -+ * NB: this is the tricky part: -+ * We have only two modes for child-lock (PR and PW), also, -+ * only owner of the key (attached on major/minor_list) can be on -+ * both blocked_list and granted_list, so @grtlk must be one -+ * of these two cases: -+ * -+ * a) @grtlk is taken from granted_list, which means we've granted -+ * more than one lock so @grtlk has to be PR, the first blocked -+ * lock must be PW and we can't grant it at all. -+ * So even @grtlk is not owner of the key (empty blocked_list), -+ * we don't care because we can't grant any lock. -+ * b) we just grant a new lock which is taken from head of blocked -+ * list, and it should be the first granted lock, and it should -+ * be the first one linked on blocked_list. -+ * -+ * Either way, we can get correct result by iterating blocked_list -+ * of @grtlk, and don't have to bother on how to find out -+ * owner of current key. -+ */ -+ list_for_each_entry_safe(poslk, tmplk, &grtln->ln_blocked_list, -+ lk_nodes[dep].ln_blocked_list) { -+ if (grtlk->lk_nodes[dep].ln_mode == HTREE_LOCK_PW || -+ poslk->lk_nodes[dep].ln_mode == HTREE_LOCK_PW) -+ break; -+ /* grant all readers */ -+ list_del_init(&poslk->lk_nodes[dep].ln_blocked_list); -+ list_add(&poslk->lk_nodes[dep].ln_granted_list, -+ &grtln->ln_granted_list); -+ -+ BUG_ON(poslk->lk_task == NULL); -+ wake_up_process(poslk->lk_task); -+ } -+ -+ /* if @curln is the owner of this key, replace it with @grtln */ -+ if (!htree_key_list_empty(curln)) -+ htree_key_list_replace_init(curln, grtln); -+ -+ if (curln->ln_mode == HTREE_LOCK_INVAL) -+ list_del_init(&curln->ln_alive_list); -+} -+ -+/* -+ * it's just wrapper of htree_node_lock_internal, it returns 1 on granted -+ * and 0 only if @wait is false and can't grant it immediately -+ */ -+int -+htree_node_lock_try(struct htree_lock *lck, htree_lock_mode_t mode, -+ u32 key, unsigned dep, int wait, void *event) -+{ -+ struct htree_lock_head *lhead = lck->lk_head; -+ int rc; -+ -+ BUG_ON(dep >= lck->lk_depth); -+ BUG_ON(lck->lk_mode == HTREE_LOCK_INVAL); -+ -+ htree_spin_lock(lhead, dep); -+ rc = htree_node_lock_internal(lhead, lck, mode, key, dep, wait, event); -+ if (rc != 0) -+ htree_spin_unlock(lhead, dep); -+ return rc >= 0; -+} -+EXPORT_SYMBOL(htree_node_lock_try); -+ -+/* it's wrapper of htree_node_unlock_internal */ -+void -+htree_node_unlock(struct htree_lock *lck, unsigned dep, void *event) -+{ -+ struct htree_lock_head *lhead = lck->lk_head; -+ -+ BUG_ON(dep >= lck->lk_depth); -+ BUG_ON(lck->lk_mode == HTREE_LOCK_INVAL); -+ -+ htree_spin_lock(lhead, dep); -+ htree_node_unlock_internal(lhead, lck, dep, event); -+ htree_spin_unlock(lhead, dep); -+} -+EXPORT_SYMBOL(htree_node_unlock); -+ -+/* stop listening on child-lock level @dep */ -+void -+htree_node_stop_listen(struct htree_lock *lck, unsigned dep) -+{ -+ struct htree_lock_node *ln = &lck->lk_nodes[dep]; -+ struct htree_lock_node *tmp; -+ -+ BUG_ON(htree_node_is_granted(lck, dep)); -+ BUG_ON(!list_empty(&ln->ln_blocked_list)); -+ BUG_ON(!list_empty(&ln->ln_granted_list)); -+ -+ if (!htree_node_is_listening(lck, dep)) -+ return; -+ -+ htree_spin_lock(lck->lk_head, dep); -+ ln->ln_mode = HTREE_LOCK_INVAL; -+ ln->ln_ev_target = NULL; -+ -+ if (htree_key_list_empty(ln)) { /* not owner */ -+ list_del_init(&ln->ln_alive_list); -+ goto out; -+ } -+ -+ /* I'm the owner... */ -+ if (list_empty(&ln->ln_alive_list)) { /* no more listener */ -+ htree_key_list_del_init(ln); -+ goto out; -+ } -+ -+ tmp = list_entry(ln->ln_alive_list.next, -+ struct htree_lock_node, ln_alive_list); -+ -+ BUG_ON(tmp->ln_mode != HTREE_LOCK_NL); -+ htree_key_list_replace_init(ln, tmp); -+ list_del_init(&ln->ln_alive_list); -+ out: -+ htree_spin_unlock(lck->lk_head, dep); -+} -+EXPORT_SYMBOL(htree_node_stop_listen); -+ -+/* release all child-locks if we have any */ -+static void -+htree_node_release_all(struct htree_lock *lck) -+{ -+ int i; -+ -+ for (i = 0; i < lck->lk_depth; i++) { -+ if (htree_node_is_granted(lck, i)) -+ htree_node_unlock(lck, i, NULL); -+ else if (htree_node_is_listening(lck, i)) -+ htree_node_stop_listen(lck, i); -+ } -+} -+ -+/* -+ * obtain htree lock, it could be blocked inside if there's conflict -+ * with any granted or blocked lock and @wait is true. -+ * NB: ALWAYS called holding lhead::lh_lock -+ */ -+static int -+htree_lock_internal(struct htree_lock *lck, int wait) -+{ -+ struct htree_lock_head *lhead = lck->lk_head; -+ int granted = 0; -+ int blocked = 0; -+ int i; -+ -+ for (i = 0; i < HTREE_LOCK_MAX; i++) { -+ if (lhead->lh_ngranted[i] != 0) -+ granted |= 1 << i; -+ if (lhead->lh_nblocked[i] != 0) -+ blocked |= 1 << i; -+ } -+ if ((htree_lock_compat[lck->lk_mode] & granted) != granted || -+ (htree_lock_compat[lck->lk_mode] & blocked) != blocked) { -+ /* will block current lock even it just conflicts with any -+ * other blocked lock, so lock like EX wouldn't starve */ -+ if (!wait) -+ return -1; -+ lhead->lh_nblocked[lck->lk_mode]++; -+ lk_block_inc(lck->lk_mode); -+ -+ lck->lk_task = current; -+ list_add_tail(&lck->lk_blocked_list, &lhead->lh_blocked_list); -+ -+ set_current_state(TASK_UNINTERRUPTIBLE); -+ htree_spin_unlock(lhead, HTREE_DEP_ROOT); -+ /* wait to be given the lock */ -+ if (lck->lk_task != NULL) -+ schedule(); -+ /* granted, no doubt. wake up will set me RUNNING */ -+ return 0; /* without lh_lock */ -+ } -+ lhead->lh_ngranted[lck->lk_mode]++; -+ lk_grant_inc(lck->lk_mode); -+ return 1; -+} -+ -+/* release htree lock. NB: ALWAYS called holding lhead::lh_lock */ -+static void -+htree_unlock_internal(struct htree_lock *lck) -+{ -+ struct htree_lock_head *lhead = lck->lk_head; -+ struct htree_lock *tmp; -+ struct htree_lock *tmp2; -+ int granted = 0; -+ int i; -+ -+ BUG_ON(lhead->lh_ngranted[lck->lk_mode] == 0); -+ -+ lhead->lh_ngranted[lck->lk_mode]--; -+ lck->lk_mode = HTREE_LOCK_INVAL; -+ -+ for (i = 0; i < HTREE_LOCK_MAX; i++) { -+ if (lhead->lh_ngranted[i] != 0) -+ granted |= 1 << i; -+ } -+ list_for_each_entry_safe(tmp, tmp2, -+ &lhead->lh_blocked_list, lk_blocked_list) { -+ /* conflict with any granted lock? */ -+ if ((htree_lock_compat[tmp->lk_mode] & granted) != granted) -+ break; -+ -+ list_del_init(&tmp->lk_blocked_list); -+ -+ BUG_ON(lhead->lh_nblocked[tmp->lk_mode] == 0); -+ -+ lhead->lh_nblocked[tmp->lk_mode]--; -+ lhead->lh_ngranted[tmp->lk_mode]++; -+ granted |= 1 << tmp->lk_mode; -+ -+ BUG_ON(tmp->lk_task == NULL); -+ wake_up_process(tmp->lk_task); -+ } -+} -+ -+/* it's wrapper of htree_lock_internal and exported interface. -+ * It always return 1 with granted lock if @wait is true, it can return 0 -+ * if @wait is false and locking request can't be granted immediately */ -+int -+htree_lock_try(struct htree_lock *lck, struct htree_lock_head *lhead, -+ htree_lock_mode_t mode, int wait) -+{ -+ int rc; -+ -+ BUG_ON(lck->lk_depth > lhead->lh_depth); -+ BUG_ON(lck->lk_head != NULL); -+ BUG_ON(lck->lk_task != NULL); -+ -+ lck->lk_head = lhead; -+ lck->lk_mode = mode; -+ -+ htree_spin_lock(lhead, HTREE_DEP_ROOT); -+ rc = htree_lock_internal(lck, wait); -+ if (rc != 0) -+ htree_spin_unlock(lhead, HTREE_DEP_ROOT); -+ return rc >= 0; -+} -+EXPORT_SYMBOL(htree_lock_try); -+ -+/* it's wrapper of htree_unlock_internal and exported interface. -+ * It will release all htree_node_locks and htree_lock */ -+void -+htree_unlock(struct htree_lock *lck) -+{ -+ BUG_ON(lck->lk_head == NULL); -+ BUG_ON(lck->lk_mode == HTREE_LOCK_INVAL); -+ -+ htree_node_release_all(lck); -+ -+ htree_spin_lock(lck->lk_head, HTREE_DEP_ROOT); -+ htree_unlock_internal(lck); -+ htree_spin_unlock(lck->lk_head, HTREE_DEP_ROOT); -+ lck->lk_head = NULL; -+ lck->lk_task = NULL; -+} -+EXPORT_SYMBOL(htree_unlock); -+ -+/* change lock mode */ -+void -+htree_change_mode(struct htree_lock *lck, htree_lock_mode_t mode) -+{ -+ BUG_ON(lck->lk_mode == HTREE_LOCK_INVAL); -+ lck->lk_mode = mode; -+} -+EXPORT_SYMBOL(htree_change_mode); -+ -+/* release htree lock, and lock it again with new mode. -+ * This function will first release all htree_node_locks and htree_lock, -+ * then try to gain htree_lock with new @mode. -+ * It always return 1 with granted lock if @wait is true, it can return 0 -+ * if @wait is false and locking request can't be granted immediately */ -+int -+htree_change_lock_try(struct htree_lock *lck, htree_lock_mode_t mode, int wait) -+{ -+ struct htree_lock_head *lhead = lck->lk_head; -+ int rc; -+ -+ BUG_ON(lhead == NULL); -+ BUG_ON(lck->lk_mode == mode); -+ BUG_ON(lck->lk_mode == HTREE_LOCK_INVAL || mode == HTREE_LOCK_INVAL); -+ -+ htree_node_release_all(lck); -+ -+ htree_spin_lock(lhead, HTREE_DEP_ROOT); -+ htree_unlock_internal(lck); -+ lck->lk_mode = mode; -+ rc = htree_lock_internal(lck, wait); -+ if (rc != 0) -+ htree_spin_unlock(lhead, HTREE_DEP_ROOT); -+ return rc >= 0; -+} -+EXPORT_SYMBOL(htree_change_lock_try); -+ -+/* create a htree_lock head with @depth levels (number of child-locks), -+ * it is a per resoruce structure */ -+struct htree_lock_head * -+htree_lock_head_alloc(unsigned depth, unsigned hbits, unsigned priv) -+{ -+ struct htree_lock_head *lhead; -+ int i; -+ -+ if (depth > HTREE_LOCK_DEP_MAX) { -+ printk(KERN_ERR "%d is larger than max htree_lock depth %d\n", -+ depth, HTREE_LOCK_DEP_MAX); -+ return NULL; -+ } -+ -+ lhead = kzalloc(offsetof(struct htree_lock_head, -+ lh_children[depth]) + priv, GFP_NOFS); -+ if (lhead == NULL) -+ return NULL; -+ -+ if (hbits < HTREE_HBITS_MIN) -+ lhead->lh_hbits = HTREE_HBITS_MIN; -+ else if (hbits > HTREE_HBITS_MAX) -+ lhead->lh_hbits = HTREE_HBITS_MAX; -+ -+ lhead->lh_lock = 0; -+ lhead->lh_depth = depth; -+ INIT_LIST_HEAD(&lhead->lh_blocked_list); -+ if (priv > 0) { -+ lhead->lh_private = (void *)lhead + -+ offsetof(struct htree_lock_head, lh_children[depth]); -+ } -+ -+ for (i = 0; i < depth; i++) { -+ INIT_LIST_HEAD(&lhead->lh_children[i].lc_list); -+ lhead->lh_children[i].lc_events = HTREE_EVENT_DISABLE; -+ } -+ return lhead; -+} -+EXPORT_SYMBOL(htree_lock_head_alloc); -+ -+/* free the htree_lock head */ -+void -+htree_lock_head_free(struct htree_lock_head *lhead) -+{ -+ int i; -+ -+ BUG_ON(!list_empty(&lhead->lh_blocked_list)); -+ for (i = 0; i < lhead->lh_depth; i++) -+ BUG_ON(!list_empty(&lhead->lh_children[i].lc_list)); -+ kfree(lhead); -+} -+EXPORT_SYMBOL(htree_lock_head_free); -+ -+/* register event callback for @events of child-lock at level @dep */ -+void -+htree_lock_event_attach(struct htree_lock_head *lhead, unsigned dep, -+ unsigned events, htree_event_cb_t callback) -+{ -+ BUG_ON(lhead->lh_depth <= dep); -+ lhead->lh_children[dep].lc_events = events; -+ lhead->lh_children[dep].lc_callback = callback; -+} -+EXPORT_SYMBOL(htree_lock_event_attach); -+ -+/* allocate a htree_lock, which is per-thread structure, @pbytes is some -+ * extra-bytes as private data for caller */ -+struct htree_lock * -+htree_lock_alloc(unsigned depth, unsigned pbytes) -+{ -+ struct htree_lock *lck; -+ int i = offsetof(struct htree_lock, lk_nodes[depth]); -+ -+ if (depth > HTREE_LOCK_DEP_MAX) { -+ printk(KERN_ERR "%d is larger than max htree_lock depth %d\n", -+ depth, HTREE_LOCK_DEP_MAX); -+ return NULL; -+ } -+ lck = kzalloc(i + pbytes, GFP_NOFS); -+ if (lck == NULL) -+ return NULL; -+ -+ if (pbytes != 0) -+ lck->lk_private = (void *)lck + i; -+ lck->lk_mode = HTREE_LOCK_INVAL; -+ lck->lk_depth = depth; -+ INIT_LIST_HEAD(&lck->lk_blocked_list); -+ -+ for (i = 0; i < depth; i++) { -+ struct htree_lock_node *node = &lck->lk_nodes[i]; -+ -+ node->ln_mode = HTREE_LOCK_INVAL; -+ INIT_LIST_HEAD(&node->ln_major_list); -+ INIT_LIST_HEAD(&node->ln_minor_list); -+ INIT_LIST_HEAD(&node->ln_alive_list); -+ INIT_LIST_HEAD(&node->ln_blocked_list); -+ INIT_LIST_HEAD(&node->ln_granted_list); -+ } -+ -+ return lck; -+} -+EXPORT_SYMBOL(htree_lock_alloc); -+ -+/* free htree_lock node */ -+void -+htree_lock_free(struct htree_lock *lck) -+{ -+ BUG_ON(lck->lk_mode != HTREE_LOCK_INVAL); -+ kfree(lck); -+} -+EXPORT_SYMBOL(htree_lock_free); -Index: linux-2.6.32-504.3.3.el6.x86_64/fs/ext4/ext4.h -=================================================================== ---- linux-2.6.32-504.3.3.el6.x86_64.orig/fs/ext4/ext4.h -+++ linux-2.6.32-504.3.3.el6.x86_64/fs/ext4/ext4.h -@@ -27,6 +27,7 @@ - #include - #include - #include -+#include - #include - #include - #ifdef __KERNEL__ -@@ -1625,6 +1626,71 @@ ext4_dir_htree_level(struct super_block - EXT4_HTREE_LEVEL : EXT4_HTREE_LEVEL_COMPAT; - } - -+/* assume name-hash is protected by upper layer */ -+#define EXT4_HTREE_LOCK_HASH 0 -+ -+enum ext4_pdo_lk_types { -+#if EXT4_HTREE_LOCK_HASH -+ EXT4_LK_HASH, -+#endif -+ EXT4_LK_DX, /* index block */ -+ EXT4_LK_DE, /* directory entry block */ -+ EXT4_LK_SPIN, /* spinlock */ -+ EXT4_LK_MAX, -+}; -+ -+/* read-only bit */ -+#define EXT4_LB_RO(b) (1 << (b)) -+/* read + write, high bits for writer */ -+#define EXT4_LB_RW(b) ((1 << (b)) | (1 << (EXT4_LK_MAX + (b)))) -+ -+enum ext4_pdo_lock_bits { -+ /* DX lock bits */ -+ EXT4_LB_DX_RO = EXT4_LB_RO(EXT4_LK_DX), -+ EXT4_LB_DX = EXT4_LB_RW(EXT4_LK_DX), -+ /* DE lock bits */ -+ EXT4_LB_DE_RO = EXT4_LB_RO(EXT4_LK_DE), -+ EXT4_LB_DE = EXT4_LB_RW(EXT4_LK_DE), -+ /* DX spinlock bits */ -+ EXT4_LB_SPIN_RO = EXT4_LB_RO(EXT4_LK_SPIN), -+ EXT4_LB_SPIN = EXT4_LB_RW(EXT4_LK_SPIN), -+ /* accurate searching */ -+ EXT4_LB_EXACT = EXT4_LB_RO(EXT4_LK_MAX << 1), -+}; -+ -+enum ext4_pdo_lock_opc { -+ /* external */ -+ EXT4_HLOCK_READDIR = (EXT4_LB_DE_RO | EXT4_LB_DX_RO), -+ EXT4_HLOCK_LOOKUP = (EXT4_LB_DE_RO | EXT4_LB_SPIN_RO | -+ EXT4_LB_EXACT), -+ EXT4_HLOCK_DEL = (EXT4_LB_DE | EXT4_LB_SPIN_RO | -+ EXT4_LB_EXACT), -+ EXT4_HLOCK_ADD = (EXT4_LB_DE | EXT4_LB_SPIN_RO), -+ -+ /* internal */ -+ EXT4_HLOCK_LOOKUP_SAFE = (EXT4_LB_DE_RO | EXT4_LB_DX_RO | -+ EXT4_LB_EXACT), -+ EXT4_HLOCK_DEL_SAFE = (EXT4_LB_DE | EXT4_LB_DX_RO | EXT4_LB_EXACT), -+ EXT4_HLOCK_SPLIT = (EXT4_LB_DE | EXT4_LB_DX | EXT4_LB_SPIN), -+}; -+ -+extern struct htree_lock_head *ext4_htree_lock_head_alloc(unsigned hbits); -+#define ext4_htree_lock_head_free(lhead) htree_lock_head_free(lhead) -+ -+extern struct htree_lock *ext4_htree_lock_alloc(void); -+#define ext4_htree_lock_free(lck) htree_lock_free(lck) -+ -+extern void ext4_htree_lock(struct htree_lock *lck, -+ struct htree_lock_head *lhead, -+ struct inode *dir, unsigned flags); -+#define ext4_htree_unlock(lck) htree_unlock(lck) -+ -+extern struct buffer_head * __ext4_find_entry(struct inode *dir, -+ const struct qstr *d_name, -+ struct ext4_dir_entry_2 **res_dir, -+ struct htree_lock *lck); -+extern int __ext4_add_entry(handle_t *handle, struct dentry *dentry, -+ struct inode *inode, struct htree_lock *lck); - void ext4_get_group_no_and_offset(struct super_block *sb, ext4_fsblk_t blocknr, - ext4_group_t *blockgrpp, ext4_grpblk_t *offsetp); - -Index: linux-2.6.32-504.3.3.el6.x86_64/fs/ext4/namei.c -=================================================================== ---- linux-2.6.32-504.3.3.el6.x86_64.orig/fs/ext4/namei.c -+++ linux-2.6.32-504.3.3.el6.x86_64/fs/ext4/namei.c -@@ -176,7 +176,7 @@ static struct dx_frame *dx_probe(const s - struct inode *dir, - struct dx_hash_info *hinfo, - struct dx_frame *frame, -- int *err); -+ struct htree_lock *lck, int *err); - static void dx_release(struct dx_frame *frames); - static int dx_make_map(struct ext4_dir_entry_2 *de, unsigned blocksize, - struct dx_hash_info *hinfo, struct dx_map_entry map[]); -@@ -189,13 +189,13 @@ static void dx_insert_block(struct dx_fr - static int ext4_htree_next_block(struct inode *dir, __u32 hash, - struct dx_frame *frame, - struct dx_frame *frames, -- __u32 *start_hash); -+ __u32 *start_hash, struct htree_lock *lck); - static struct buffer_head * ext4_dx_find_entry(struct inode *dir, - const struct qstr *d_name, - struct ext4_dir_entry_2 **res_dir, -- int *err); -+ struct htree_lock *lck, int *err); - static int ext4_dx_add_entry(handle_t *handle, struct dentry *dentry, -- struct inode *inode); -+ struct inode *inode, struct htree_lock *lck); - - /* - * p is at least 6 bytes before the end of page -@@ -368,6 +368,225 @@ struct stats dx_show_entries(struct dx_h - } - #endif /* DX_DEBUG */ - -+/* private data for htree_lock */ -+struct ext4_dir_lock_data { -+ unsigned ld_flags; /* bits-map for lock types */ -+ unsigned ld_count; /* # entries of the last DX block */ -+ struct dx_entry ld_at_entry; /* copy of leaf dx_entry */ -+ struct dx_entry *ld_at; /* position of leaf dx_entry */ -+}; -+ -+#define ext4_htree_lock_data(l) ((struct ext4_dir_lock_data *)(l)->lk_private) -+#define ext4_find_entry(dir, name, dirent) __ext4_find_entry(dir, name, dirent, NULL) -+#define ext4_add_entry(handle, dentry, inode) __ext4_add_entry(handle, dentry, inode, NULL) -+ -+/* NB: ext4_lblk_t is 32 bits so we use high bits to identify invalid blk */ -+#define EXT4_HTREE_NODE_CHANGED (0xcafeULL << 32) -+ -+static void ext4_htree_event_cb(void *target, void *event) -+{ -+ u64 *block = (u64 *)target; -+ -+ if (*block == dx_get_block((struct dx_entry *)event)) -+ *block = EXT4_HTREE_NODE_CHANGED; -+} -+ -+struct htree_lock_head *ext4_htree_lock_head_alloc(unsigned hbits) -+{ -+ struct htree_lock_head *lhead; -+ -+ lhead = htree_lock_head_alloc(EXT4_LK_MAX, hbits, 0); -+ if (lhead != NULL) { -+ htree_lock_event_attach(lhead, EXT4_LK_SPIN, HTREE_EVENT_WR, -+ ext4_htree_event_cb); -+ } -+ return lhead; -+} -+EXPORT_SYMBOL(ext4_htree_lock_head_alloc); -+ -+struct htree_lock *ext4_htree_lock_alloc(void) -+{ -+ return htree_lock_alloc(EXT4_LK_MAX, -+ sizeof(struct ext4_dir_lock_data)); -+} -+EXPORT_SYMBOL(ext4_htree_lock_alloc); -+ -+static htree_lock_mode_t ext4_htree_mode(unsigned flags) -+{ -+ switch (flags) { -+ default: /* 0 or unknown flags require EX lock */ -+ return HTREE_LOCK_EX; -+ case EXT4_HLOCK_READDIR: -+ return HTREE_LOCK_PR; -+ case EXT4_HLOCK_LOOKUP: -+ return HTREE_LOCK_CR; -+ case EXT4_HLOCK_DEL: -+ case EXT4_HLOCK_ADD: -+ return HTREE_LOCK_CW; -+ } -+} -+ -+/* return PR for read-only operations, otherwise return EX */ -+static inline htree_lock_mode_t ext4_htree_safe_mode(unsigned flags) -+{ -+ int writer = (flags & EXT4_LB_DE) == EXT4_LB_DE; -+ -+ /* 0 requires EX lock */ -+ return (flags == 0 || writer) ? HTREE_LOCK_EX : HTREE_LOCK_PR; -+} -+ -+static int ext4_htree_safe_locked(struct htree_lock *lck) -+{ -+ int writer; -+ -+ if (lck == NULL || lck->lk_mode == HTREE_LOCK_EX) -+ return 1; -+ -+ writer = (ext4_htree_lock_data(lck)->ld_flags & EXT4_LB_DE) == -+ EXT4_LB_DE; -+ if (writer) /* all readers & writers are excluded? */ -+ return lck->lk_mode == HTREE_LOCK_EX; -+ -+ /* all writers are excluded? */ -+ return lck->lk_mode == HTREE_LOCK_PR || -+ lck->lk_mode == HTREE_LOCK_PW || -+ lck->lk_mode == HTREE_LOCK_EX; -+} -+ -+/* relock htree_lock with EX mode if it's change operation, otherwise -+ * relock it with PR mode. It's noop if PDO is disabled. */ -+static void ext4_htree_safe_relock(struct htree_lock *lck) -+{ -+ if (!ext4_htree_safe_locked(lck)) { -+ unsigned flags = ext4_htree_lock_data(lck)->ld_flags; -+ -+ htree_change_lock(lck, ext4_htree_safe_mode(flags)); -+ } -+} -+ -+void ext4_htree_lock(struct htree_lock *lck, struct htree_lock_head *lhead, -+ struct inode *dir, unsigned flags) -+{ -+ htree_lock_mode_t mode = is_dx(dir) ? ext4_htree_mode(flags) : -+ ext4_htree_safe_mode(flags); -+ -+ ext4_htree_lock_data(lck)->ld_flags = flags; -+ htree_lock(lck, lhead, mode); -+ if (!is_dx(dir)) -+ ext4_htree_safe_relock(lck); /* make sure it's safe locked */ -+} -+EXPORT_SYMBOL(ext4_htree_lock); -+ -+static int ext4_htree_node_lock(struct htree_lock *lck, struct dx_entry *at, -+ unsigned lmask, int wait, void *ev) -+{ -+ u32 key = (at == NULL) ? 0 : dx_get_block(at); -+ u32 mode; -+ -+ /* NOOP if htree is well protected or caller doesn't require the lock */ -+ if (ext4_htree_safe_locked(lck) || -+ !(ext4_htree_lock_data(lck)->ld_flags & lmask)) -+ return 1; -+ -+ mode = (ext4_htree_lock_data(lck)->ld_flags & lmask) == lmask ? -+ HTREE_LOCK_PW : HTREE_LOCK_PR; -+ while (1) { -+ if (htree_node_lock_try(lck, mode, key, ffz(~lmask), wait, ev)) -+ return 1; -+ if (!(lmask & EXT4_LB_SPIN)) /* not a spinlock */ -+ return 0; -+ cpu_relax(); /* spin until granted */ -+ } -+} -+ -+static int ext4_htree_node_locked(struct htree_lock *lck, unsigned lmask) -+{ -+ return ext4_htree_safe_locked(lck) || -+ htree_node_is_granted(lck, ffz(~lmask)); -+} -+ -+static void ext4_htree_node_unlock(struct htree_lock *lck, -+ unsigned lmask, void *buf) -+{ -+ /* NB: it's safe to call mutiple times or even it's not locked */ -+ if (!ext4_htree_safe_locked(lck) && -+ htree_node_is_granted(lck, ffz(~lmask))) -+ htree_node_unlock(lck, ffz(~lmask), buf); -+} -+ -+#define ext4_htree_dx_lock(lck, key) \ -+ ext4_htree_node_lock(lck, key, EXT4_LB_DX, 1, NULL) -+#define ext4_htree_dx_lock_try(lck, key) \ -+ ext4_htree_node_lock(lck, key, EXT4_LB_DX, 0, NULL) -+#define ext4_htree_dx_unlock(lck) \ -+ ext4_htree_node_unlock(lck, EXT4_LB_DX, NULL) -+#define ext4_htree_dx_locked(lck) \ -+ ext4_htree_node_locked(lck, EXT4_LB_DX) -+ -+static void ext4_htree_dx_need_lock(struct htree_lock *lck) -+{ -+ struct ext4_dir_lock_data *ld; -+ -+ if (ext4_htree_safe_locked(lck)) -+ return; -+ -+ ld = ext4_htree_lock_data(lck); -+ switch (ld->ld_flags) { -+ default: -+ return; -+ case EXT4_HLOCK_LOOKUP: -+ ld->ld_flags = EXT4_HLOCK_LOOKUP_SAFE; -+ return; -+ case EXT4_HLOCK_DEL: -+ ld->ld_flags = EXT4_HLOCK_DEL_SAFE; -+ return; -+ case EXT4_HLOCK_ADD: -+ ld->ld_flags = EXT4_HLOCK_SPLIT; -+ return; -+ } -+} -+ -+#define ext4_htree_de_lock(lck, key) \ -+ ext4_htree_node_lock(lck, key, EXT4_LB_DE, 1, NULL) -+#define ext4_htree_de_unlock(lck) \ -+ ext4_htree_node_unlock(lck, EXT4_LB_DE, NULL) -+ -+#define ext4_htree_spin_lock(lck, key, event) \ -+ ext4_htree_node_lock(lck, key, EXT4_LB_SPIN, 0, event) -+#define ext4_htree_spin_unlock(lck) \ -+ ext4_htree_node_unlock(lck, EXT4_LB_SPIN, NULL) -+#define ext4_htree_spin_unlock_listen(lck, p) \ -+ ext4_htree_node_unlock(lck, EXT4_LB_SPIN, p) -+ -+static void ext4_htree_spin_stop_listen(struct htree_lock *lck) -+{ -+ if (!ext4_htree_safe_locked(lck) && -+ htree_node_is_listening(lck, ffz(~EXT4_LB_SPIN))) -+ htree_node_stop_listen(lck, ffz(~EXT4_LB_SPIN)); -+} -+ -+enum { -+ DX_HASH_COL_IGNORE, /* ignore collision while probing frames */ -+ DX_HASH_COL_YES, /* there is collision and it does matter */ -+ DX_HASH_COL_NO, /* there is no collision */ -+}; -+ -+static int dx_probe_hash_collision(struct htree_lock *lck, -+ struct dx_entry *entries, -+ struct dx_entry *at, u32 hash) -+{ -+ if (!(lck && ext4_htree_lock_data(lck)->ld_flags & EXT4_LB_EXACT)) { -+ return DX_HASH_COL_IGNORE; /* don't care about collision */ -+ -+ } else if (at == entries + dx_get_count(entries) - 1) { -+ return DX_HASH_COL_IGNORE; /* not in any leaf of this DX */ -+ -+ } else { /* hash collision? */ -+ return ((dx_get_hash(at + 1) & ~1) == hash) ? -+ DX_HASH_COL_YES : DX_HASH_COL_NO; -+ } -+} -+ - /* - * Probe for a directory leaf block to search. - * -@@ -379,10 +598,11 @@ struct stats dx_show_entries(struct dx_h - */ - static struct dx_frame * - dx_probe(const struct qstr *d_name, struct inode *dir, -- struct dx_hash_info *hinfo, struct dx_frame *frame_in, int *err) -+ struct dx_hash_info *hinfo, struct dx_frame *frame_in, -+ struct htree_lock *lck, int *err) - { - unsigned count, indirect; -- struct dx_entry *at, *entries, *p, *q, *m; -+ struct dx_entry *at, *entries, *p, *q, *m, *dx = NULL; - struct dx_root_info * info; - struct buffer_head *bh; - struct dx_frame *frame = frame_in; -@@ -447,8 +667,15 @@ dx_probe(const struct qstr *d_name, stru - dxtrace(printk("Look up %x", hash)); - while (1) - { -+ if (indirect == 0) { /* the last index level */ -+ /* NB: ext4_htree_dx_lock() could be noop if -+ * DX-lock flag is not set for current operation */ -+ ext4_htree_dx_lock(lck, dx); -+ ext4_htree_spin_lock(lck, dx, NULL); -+ } - count = dx_get_count(entries); -- if (!count || count > dx_get_limit(entries)) { -+ if (count == 0 || count > dx_get_limit(entries)) { -+ ext4_htree_spin_unlock(lck); /* release spin */ - ext4_warning(dir->i_sb, - "dx entry: no count or count > limit"); - brelse(bh); -@@ -489,9 +716,73 @@ dx_probe(const struct qstr *d_name, stru - frame->bh = bh; - frame->entries = entries; - frame->at = at; -- if (!indirect--) return frame; -+ -+ if (indirect == 0) { /* the last index level */ -+ struct ext4_dir_lock_data *ld; -+ u64 myblock; -+ -+ /* By default we only lock DE-block, however, we will -+ * also lock the last level DX-block if: -+ * a) there is hash collision -+ * we will set DX-lock flag (a few lines below) -+ * and redo to lock DX-block -+ * see detail in dx_probe_hash_collision() -+ * b) it's a retry from splitting -+ * we need to lock the last level DX-block so nobody -+ * else can split any leaf blocks under the same -+ * DX-block, see detail in ext4_dx_add_entry() -+ */ -+ if (ext4_htree_dx_locked(lck)) { -+ /* DX-block is locked, just lock DE-block -+ * and return */ -+ ext4_htree_spin_unlock(lck); -+ if (!ext4_htree_safe_locked(lck)) -+ ext4_htree_de_lock(lck, frame->at); -+ return frame; -+ } -+ /* it's pdirop and no DX lock */ -+ if (dx_probe_hash_collision(lck, entries, at, hash) == -+ DX_HASH_COL_YES) { -+ /* found hash collision, set DX-lock flag -+ * and retry to abtain DX-lock */ -+ ext4_htree_spin_unlock(lck); -+ ext4_htree_dx_need_lock(lck); -+ continue; -+ } -+ ld = ext4_htree_lock_data(lck); -+ /* because I don't lock DX, so @at can't be trusted -+ * after I release spinlock so I have to save it */ -+ ld->ld_at = at; -+ ld->ld_at_entry = *at; -+ ld->ld_count = dx_get_count(entries); -+ -+ frame->at = &ld->ld_at_entry; -+ myblock = dx_get_block(at); -+ -+ /* NB: ordering locking */ -+ ext4_htree_spin_unlock_listen(lck, &myblock); -+ /* other thread can split this DE-block because: -+ * a) I don't have lock for the DE-block yet -+ * b) I released spinlock on DX-block -+ * if it happened I can detect it by listening -+ * splitting event on this DE-block */ -+ ext4_htree_de_lock(lck, frame->at); -+ ext4_htree_spin_stop_listen(lck); -+ -+ if (myblock == EXT4_HTREE_NODE_CHANGED) { -+ /* someone split this DE-block before -+ * I locked it, I need to retry and lock -+ * valid DE-block */ -+ ext4_htree_de_unlock(lck); -+ continue; -+ } -+ return frame; -+ } -+ dx = at; -+ indirect--; - if (!(bh = ext4_bread (NULL,dir, dx_get_block(at), 0, err))) - goto fail2; -+ - at = entries = ((struct dx_node *) bh->b_data)->entries; - if (dx_get_limit(entries) != dx_node_limit (dir)) { - ext4_warning(dir->i_sb, -@@ -553,7 +844,7 @@ static void dx_release (struct dx_frame - static int ext4_htree_next_block(struct inode *dir, __u32 hash, - struct dx_frame *frame, - struct dx_frame *frames, -- __u32 *start_hash) -+ __u32 *start_hash, struct htree_lock *lck) - { - struct dx_frame *p; - struct buffer_head *bh; -@@ -568,12 +859,22 @@ static int ext4_htree_next_block(struct - * this loop, num_frames indicates the number of interior - * nodes need to be read. - */ -+ ext4_htree_de_unlock(lck); - while (1) { -- if (++(p->at) < p->entries + dx_get_count(p->entries)) -- break; -+ if (num_frames > 0 || ext4_htree_dx_locked(lck)) { -+ /* num_frames > 0 : -+ * DX block -+ * ext4_htree_dx_locked: -+ * frame->at is reliable pointer returned by dx_probe, -+ * otherwise dx_probe already knew no collision */ -+ if (++(p->at) < p->entries + dx_get_count(p->entries)) -+ break; -+ } - if (p == frames) - return 0; - num_frames++; -+ if (num_frames == 1) -+ ext4_htree_dx_unlock(lck); - p--; - } - -@@ -596,6 +897,13 @@ static int ext4_htree_next_block(struct - * block so no check is necessary - */ - while (num_frames--) { -+ if (num_frames == 0) { -+ /* it's not always necessary, we just don't want to -+ * detect hash collision again */ -+ ext4_htree_dx_need_lock(lck); -+ ext4_htree_dx_lock(lck, p->at); -+ } -+ - if (!(bh = ext4_bread(NULL, dir, dx_get_block(p->at), - 0, &err))) - return err; /* Failure */ -@@ -604,6 +912,7 @@ static int ext4_htree_next_block(struct - p->bh = bh; - p->at = p->entries = ((struct dx_node *) bh->b_data)->entries; - } -+ ext4_htree_de_lock(lck, p->at); - return 1; - } - -@@ -696,10 +1005,10 @@ int ext4_htree_fill_tree(struct file *di - } - hinfo.hash = start_hash; - hinfo.minor_hash = 0; -- frame = dx_probe(NULL, dir, &hinfo, frames, &err); -+ /* assume it's PR locked */ -+ frame = dx_probe(NULL, dir, &hinfo, frames, NULL, &err); - if (!frame) - return err; -- - /* Add '.' and '..' from the htree header */ - if (!start_hash && !start_minor_hash) { - de = (struct ext4_dir_entry_2 *) frames[0].bh->b_data; -@@ -726,7 +1035,7 @@ int ext4_htree_fill_tree(struct file *di - count += ret; - hashval = ~0; - ret = ext4_htree_next_block(dir, HASH_NB_ALWAYS, -- frame, frames, &hashval); -+ frame, frames, &hashval, NULL); - *next_hash = hashval; - if (ret < 0) { - err = ret; -@@ -826,9 +1135,17 @@ static void dx_insert_block(struct dx_fr - - static void ext4_update_dx_flag(struct inode *inode) - { -+ /* Disable it for ldiskfs, because going from a DX directory to -+ * a non-DX directory while it is in use will completely break -+ * the htree-locking. -+ * If we really want to support this operation in the future, -+ * we need to exclusively lock the directory at here which will -+ * increase complexity of code */ -+#if 0 - if (!EXT4_HAS_COMPAT_FEATURE(inode->i_sb, - EXT4_FEATURE_COMPAT_DIR_INDEX)) - ext4_clear_inode_flag(inode, EXT4_INODE_INDEX); -+#endif - } - - /* -@@ -900,9 +1217,10 @@ static inline int search_dirblock(struct - * The returned buffer_head has ->b_count elevated. The caller is expected - * to brelse() it when appropriate. - */ --static struct buffer_head * ext4_find_entry (struct inode *dir, -+struct buffer_head * __ext4_find_entry(struct inode *dir, - const struct qstr *d_name, -- struct ext4_dir_entry_2 ** res_dir) -+ struct ext4_dir_entry_2 **res_dir, -+ struct htree_lock *lck) - { - struct super_block *sb; - struct buffer_head *bh_use[NAMEI_RA_SIZE]; -@@ -923,7 +1241,7 @@ static struct buffer_head * ext4_find_en - if (namelen > EXT4_NAME_LEN) - return NULL; - if (is_dx(dir)) { -- bh = ext4_dx_find_entry(dir, d_name, res_dir, &err); -+ bh = ext4_dx_find_entry(dir, d_name, res_dir, lck, &err); - /* - * On success, or if the error was file not found, - * return. Otherwise, fall back to doing a search the -@@ -933,6 +1251,7 @@ static struct buffer_head * ext4_find_en - return bh; - dxtrace(printk(KERN_DEBUG "ext4_find_entry: dx failed, " - "falling back\n")); -+ ext4_htree_safe_relock(lck); - } - nblocks = dir->i_size >> EXT4_BLOCK_SIZE_BITS(sb); - start = EXT4_I(dir)->i_dir_start_lookup; -@@ -1008,9 +1327,12 @@ cleanup_and_exit: - brelse(bh_use[ra_ptr]); - return ret; - } -+EXPORT_SYMBOL(__ext4_find_entry); - --static struct buffer_head * ext4_dx_find_entry(struct inode *dir, const struct qstr *d_name, -- struct ext4_dir_entry_2 **res_dir, int *err) -+static struct buffer_head * ext4_dx_find_entry(struct inode *dir, -+ const struct qstr *d_name, -+ struct ext4_dir_entry_2 **res_dir, -+ struct htree_lock *lck, int *err) - { - struct super_block * sb; - struct dx_hash_info hinfo; -@@ -1026,13 +1348,16 @@ static struct buffer_head * ext4_dx_find - sb = dir->i_sb; - /* NFS may look up ".." - look at dx_root directory block */ - if (namelen > 2 || name[0] != '.'||(name[1] != '.' && name[1] != '\0')){ -- if (!(frame = dx_probe(d_name, dir, &hinfo, frames, err))) -+ if (!(frame = dx_probe(d_name, dir, &hinfo, frames, lck, err))) - return NULL; - } else { - frame = frames; - frame->bh = NULL; /* for dx_release() */ - frame->at = (struct dx_entry *)frames; /* hack for zero entry*/ - dx_set_block(frame->at, 0); /* dx_root block is 0 */ -+ /* "." and ".." are stored in root DX lock */ -+ ext4_htree_dx_need_lock(lck); -+ ext4_htree_dx_lock(lck, NULL); - } - hash = hinfo.hash; - do { -@@ -1061,7 +1386,7 @@ static struct buffer_head * ext4_dx_find - brelse(bh); - /* Check to see if we should continue to search */ - retval = ext4_htree_next_block(dir, hash, frame, -- frames, NULL); -+ frames, NULL, lck); - if (retval < 0) { - ext4_warning(sb, - "error reading index page in directory #%lu", -@@ -1244,8 +1569,9 @@ static struct ext4_dir_entry_2* dx_pack_ - * Returns pointer to de in block into which the new entry will be inserted. - */ - static struct ext4_dir_entry_2 *do_split(handle_t *handle, struct inode *dir, -- struct buffer_head **bh,struct dx_frame *frame, -- struct dx_hash_info *hinfo, int *error) -+ struct buffer_head **bh, struct dx_frame *frames, -+ struct dx_frame *frame, struct dx_hash_info *hinfo, -+ struct htree_lock *lck, int *error) - { - unsigned blocksize = dir->i_sb->s_blocksize; - unsigned count, continued; -@@ -1302,7 +1628,14 @@ static struct ext4_dir_entry_2 *do_split - hash2, split, count-split)); - - /* Fancy dance to stay within two buffers */ -- de2 = dx_move_dirents(data1, data2, map + split, count - split, blocksize); -+ if (hinfo->hash < hash2) { -+ de2 = dx_move_dirents(data1, data2, map + split, -+ count - split, blocksize); -+ } else { -+ /* make sure we will add entry to the same block which -+ * we have already locked */ -+ de2 = dx_move_dirents(data1, data2, map, split, blocksize); -+ } - de = dx_pack_dirents(data1, blocksize); - de->rec_len = ext4_rec_len_to_disk(data1 + blocksize - (char *) de, - blocksize); -@@ -1311,13 +1644,21 @@ static struct ext4_dir_entry_2 *do_split - dxtrace(dx_show_leaf (hinfo, (struct ext4_dir_entry_2 *) data1, blocksize, 1)); - dxtrace(dx_show_leaf (hinfo, (struct ext4_dir_entry_2 *) data2, blocksize, 1)); - -- /* Which block gets the new entry? */ -- if (hinfo->hash >= hash2) -- { -- swap(*bh, bh2); -- de = de2; -+ ext4_htree_spin_lock(lck, frame > frames ? (frame - 1)->at : NULL, -+ frame->at); /* notify block is being split */ -+ if (hinfo->hash < hash2) { -+ dx_insert_block(frame, hash2 + continued, newblock); -+ -+ } else { -+ /* switch block number */ -+ dx_insert_block(frame, hash2 + continued, -+ dx_get_block(frame->at)); -+ dx_set_block(frame->at, newblock); -+ (frame->at)++; - } -- dx_insert_block(frame, hash2 + continued, newblock); -+ ext4_htree_spin_unlock(lck); -+ ext4_htree_dx_unlock(lck); -+ - err = ext4_handle_dirty_metadata(handle, dir, bh2); - if (err) - goto journal_error; -@@ -1558,7 +1899,7 @@ static int make_indexed_dir(handle_t *ha - ext4_handle_dirty_metadata(handle, dir, frame->bh); - ext4_handle_dirty_metadata(handle, dir, bh); - -- de = do_split(handle,dir, &bh, frame, &hinfo, &retval); -+ de = do_split(handle,dir, &bh, frames, frame, &hinfo, NULL, &retval); - if (!de) { - /* - * Even if the block split failed, we have to properly write -@@ -1664,8 +2005,8 @@ out: - * may not sleep between calling this and putting something into - * the entry, as someone else might have used it while you slept. - */ --static int ext4_add_entry(handle_t *handle, struct dentry *dentry, -- struct inode *inode) -+int __ext4_add_entry(handle_t *handle, struct dentry *dentry, -+ struct inode *inode, struct htree_lock *lck) - { - struct inode *dir = dentry->d_parent->d_inode; - struct buffer_head *bh; -@@ -1684,9 +2025,10 @@ static int ext4_add_entry(handle_t *hand - if (dentry->d_name.len == 2 && - memcmp(dentry->d_name.name, "..", 2) == 0) - return ext4_update_dotdot(handle, dentry, inode); -- retval = ext4_dx_add_entry(handle, dentry, inode); -+ retval = ext4_dx_add_entry(handle, dentry, inode, lck); - if (!retval || (retval != ERR_BAD_DX_DIR)) - return retval; -+ ext4_htree_safe_relock(lck); - ext4_clear_inode_flag(dir, EXT4_INODE_INDEX); - dx_fallback++; - ext4_mark_inode_dirty(handle, dir); -@@ -1717,12 +2059,13 @@ static int ext4_add_entry(handle_t *hand - brelse(bh); - return retval; - } -+EXPORT_SYMBOL(__ext4_add_entry); - - /* - * Returns 0 for success, or a negative error value - */ - static int ext4_dx_add_entry(handle_t *handle, struct dentry *dentry, -- struct inode *inode) -+ struct inode *inode, struct htree_lock *lck) - { - struct dx_frame frames[EXT4_HTREE_LEVEL], *frame; - struct dx_entry *entries, *at; -@@ -1736,7 +2079,7 @@ static int ext4_dx_add_entry(handle_t *h - - again: - restart = 0; -- frame = dx_probe(&dentry->d_name, dir, &hinfo, frames, &err); -+ frame = dx_probe(&dentry->d_name, dir, &hinfo, frames, lck, &err); - if (!frame) - return err; - entries = frame->entries; -@@ -1763,6 +2106,11 @@ again: - struct dx_node *node2; - struct buffer_head *bh2; - -+ if (!ext4_htree_safe_locked(lck)) { /* retry with EX lock */ -+ ext4_htree_safe_relock(lck); -+ restart = 1; -+ goto cleanup; -+ } - while (frame > frames) { - if (dx_get_count((frame - 1)->entries) < - dx_get_limit((frame - 1)->entries)) { -@@ -1860,16 +2208,43 @@ again: - restart = 1; - goto cleanup; - } -+ } else if (!ext4_htree_dx_locked(lck)) { -+ struct ext4_dir_lock_data *ld = ext4_htree_lock_data(lck); -+ -+ /* not well protected, require DX lock */ -+ ext4_htree_dx_need_lock(lck); -+ at = frame > frames ? (frame - 1)->at : NULL; -+ -+ /* NB: no risk of deadlock because it's just a try. -+ * -+ * NB: we check ld_count for twice, the first time before -+ * having DX lock, the second time after holding DX lock. -+ * -+ * NB: We never free blocks for directory so far, which -+ * means value returned by dx_get_count() should equal to -+ * ld->ld_count if nobody split any DE-block under @at, -+ * and ld->ld_at still points to valid dx_entry. */ -+ if ((ld->ld_count != dx_get_count(entries)) || -+ !ext4_htree_dx_lock_try(lck, at) || -+ (ld->ld_count != dx_get_count(entries))) { -+ restart = 1; -+ goto cleanup; -+ } -+ /* OK, I've got DX lock and nothing changed */ -+ frame->at = ld->ld_at; - } -- de = do_split(handle, dir, &bh, frame, &hinfo, &err); -+ de = do_split(handle, dir, &bh, frames, frame, &hinfo, lck, &err); - if (!de) - goto cleanup; -+ - err = add_dirent_to_buf(handle, dentry, inode, de, bh); - goto cleanup; - - journal_error: - ext4_std_error(dir->i_sb, err); - cleanup: -+ ext4_htree_dx_unlock(lck); -+ ext4_htree_de_unlock(lck); - if (bh) - brelse(bh); - dx_release(frames); -Index: linux-2.6.32-504.3.3.el6.x86_64/fs/ext4/Makefile -=================================================================== ---- linux-2.6.32-504.3.3.el6.x86_64.orig/fs/ext4/Makefile -+++ linux-2.6.32-504.3.3.el6.x86_64/fs/ext4/Makefile -@@ -6,6 +6,7 @@ obj-$(CONFIG_EXT4_FS) += ext4.o - - ext4-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \ - ioctl.o namei.o super.o symlink.o hash.o resize.o extents.o \ -+ htree_lock.o \ - ext4_jbd2.o migrate.o mballoc.o block_validity.o move_extent.o \ - mmp.o - diff --git a/ldiskfs/kernel_patches/patches/rhel6.3/ext4-remove-cond_resched-calls.patch b/ldiskfs/kernel_patches/patches/rhel6.3/ext4-remove-cond_resched-calls.patch deleted file mode 100644 index b854280..0000000 --- a/ldiskfs/kernel_patches/patches/rhel6.3/ext4-remove-cond_resched-calls.patch +++ /dev/null @@ -1,29 +0,0 @@ -Index: linux-2.6.18.i386/fs/ext4/ialloc.c -=================================================================== ---- linux-2.6.18.i386.orig/fs/ext4/ialloc.c -+++ linux-2.6.18.i386/fs/ext4/ialloc.c -@@ -1057,7 +1057,6 @@ unsigned long ext4_count_free_inodes (st - if (!gdp) - continue; - desc_count += ext4_free_inodes_count(sb, gdp); -- cond_resched(); - } - return desc_count; - #endif -Index: linux-2.6.18.i386/fs/ext4/super.c -=================================================================== ---- linux-2.6.18.i386.orig/fs/ext4/super.c -+++ linux-2.6.18.i386/fs/ext4/super.c -@@ -3100,11 +3100,9 @@ static int ext4_statfs(struct dentry *de - * block group descriptors. If the sparse superblocks - * feature is turned on, then not all groups have this. - */ -- for (i = 0; i < ngroups; i++) { -+ for (i = 0; i < ngroups; i++) - overhead += ext4_bg_has_super(sb, i) + - ext4_bg_num_gdb(sb, i); -- cond_resched(); -- } - - /* - * Every block group has an inode bitmap, a block diff --git a/ldiskfs/kernel_patches/patches/rhel6.5/ext4-fix-journal-quota.patch b/ldiskfs/kernel_patches/patches/rhel6.5/ext4-fix-journal-quota.patch deleted file mode 100644 index 220de39..0000000 --- a/ldiskfs/kernel_patches/patches/rhel6.5/ext4-fix-journal-quota.patch +++ /dev/null @@ -1,15 +0,0 @@ -diff --git a/fs/ext4/super.c b/fs/ext4/super.c -index 1ed737f..77e2fb3 100644 ---- a/fs/ext4/super.c -+++ b/fs/ext4/super.c -@@ -4672,7 +4672,9 @@ static int ext4_release_dquot(struct dquot *dquot) - static int ext4_mark_dquot_dirty(struct dquot *dquot) - { - /* Are we journaling quotas? */ -- if (EXT4_SB(dquot->dq_sb)->s_qf_names[USRQUOTA] || -+ if (EXT4_HAS_RO_COMPAT_FEATURE(dquot->dq_sb, -+ EXT4_FEATURE_RO_COMPAT_QUOTA) || -+ EXT4_SB(dquot->dq_sb)->s_qf_names[USRQUOTA] || - EXT4_SB(dquot->dq_sb)->s_qf_names[GRPQUOTA]) { - dquot_mark_dquot_dirty(dquot); - return ext4_write_dquot(dquot); diff --git a/ldiskfs/kernel_patches/patches/rhel6.5/ext4-give-warning-with-dir-htree-growing.patch b/ldiskfs/kernel_patches/patches/rhel6.5/ext4-give-warning-with-dir-htree-growing.patch deleted file mode 100644 index 7cdebaa..0000000 --- a/ldiskfs/kernel_patches/patches/rhel6.5/ext4-give-warning-with-dir-htree-growing.patch +++ /dev/null @@ -1,168 +0,0 @@ -diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h -index 938487a..47313fd 100644 ---- a/fs/ext4/ext4.h -+++ b/fs/ext4/ext4.h -@@ -1178,6 +1178,7 @@ struct ext4_sb_info { - unsigned int s_mb_group_prealloc; - unsigned int s_max_writeback_mb_bump; - unsigned long s_max_dir_size; -+ unsigned long s_warning_dir_size; - /* where last allocation was done - for stream allocation */ - unsigned long s_mb_last_group; - unsigned long s_mb_last_start; -diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c -index 992dc58..57ff920 100644 ---- a/fs/ext4/namei.c -+++ b/fs/ext4/namei.c -@@ -370,11 +370,19 @@ struct ext4_dir_lock_data { - - #define ext4_htree_lock_data(l) ((struct ext4_dir_lock_data *)(l)->lk_private) - #define ext4_find_entry(dir, name, dirent) __ext4_find_entry(dir, name, dirent, NULL) --#define ext4_add_entry(handle, dentry, inode) __ext4_add_entry(handle, dentry, inode, NULL) -- - /* NB: ext4_lblk_t is 32 bits so we use high bits to identify invalid blk */ - #define EXT4_HTREE_NODE_CHANGED (0xcafeULL << 32) - -+inline int ext4_add_entry(handle_t *handle, struct dentry *dentry, -+ struct inode *inode) -+{ -+ int ret = __ext4_add_entry(handle, dentry, inode, NULL); -+ -+ if (ret == -ENOBUFS) -+ ret = 0; -+ return ret; -+} -+ - static void ext4_htree_event_cb(void *target, void *event) - { - u64 *block = (u64 *)target; -@@ -2053,6 +2061,54 @@ int __ext4_add_entry(handle_t *handle, struct dentry *dentry, - } - EXPORT_SYMBOL(__ext4_add_entry); - -+static unsigned long __ext4_max_dir_size(struct dx_frame *frames, -+ struct dx_frame *frame, struct inode *dir) -+{ -+ unsigned long max_dir_size; -+ -+ if (EXT4_SB(dir->i_sb)->s_max_dir_size) { -+ max_dir_size = EXT4_SB(dir->i_sb)->s_max_dir_size; -+ } else { -+ max_dir_size = EXT4_BLOCK_SIZE(dir->i_sb); -+ while (frame >= frames) { -+ max_dir_size *= dx_get_limit(frame->entries); -+ if (frame == frames) -+ break; -+ frame--; -+ } -+ /* use 75% of max dir size in average */ -+ max_dir_size = max_dir_size / 4 * 3; -+ } -+ return max_dir_size; -+} -+ -+/* -+ * With hash tree growing, it is easy to hit ENOSPC, but it is hard -+ * to predict when it will happen. let's give administrators warning -+ * when reaching 5/8 and 11/16 of limit -+ */ -+static inline bool dir_size_in_warning_range(struct dx_frame *frames, -+ struct dx_frame *frame, -+ struct inode *dir) -+{ -+ unsigned long size1, size2; -+ struct super_block *sb = dir->i_sb; -+ -+ if (unlikely(!EXT4_SB(sb)->s_warning_dir_size)) -+ EXT4_SB(sb)->s_warning_dir_size = -+ __ext4_max_dir_size(frames, frame, dir); -+ -+ size1 = EXT4_SB(sb)->s_warning_dir_size / 16 * 10; -+ size1 = size1 & ~(EXT4_BLOCK_SIZE(sb) - 1); -+ size2 = EXT4_SB(sb)->s_warning_dir_size / 16 * 11; -+ size2 = size2 & ~(EXT4_BLOCK_SIZE(sb) - 1); -+ if (in_range(dir->i_size, size1, EXT4_BLOCK_SIZE(sb)) || -+ in_range(dir->i_size, size2, EXT4_BLOCK_SIZE(sb))) -+ return true; -+ -+ return false; -+} -+ - /* - * Returns 0 for success, or a negative error value - */ -@@ -2068,6 +2124,7 @@ static int ext4_dx_add_entry(handle_t *handle, struct dentry *dentry, - struct ext4_dir_entry_2 *de; - int restart; - int err; -+ bool ret_warn = false; - - again: - restart = 0; -@@ -2088,6 +2145,11 @@ again: - /* Block full, should compress but for now just split */ - dxtrace(printk(KERN_DEBUG "using %u of %u node entries\n", - dx_get_count(entries), dx_get_limit(entries))); -+ -+ if (frame - frames + 1 >= ext4_dir_htree_level(sb) || -+ EXT4_SB(dir->i_sb)->s_max_dir_size) -+ ret_warn = dir_size_in_warning_range(frames, frame, dir); -+ - /* Need to split index? */ - if (dx_get_count(entries) == dx_get_limit(entries)) { - ext4_lblk_t newblock; -@@ -2119,7 +2181,7 @@ again: - "reach max htree level :%d", - dir->i_ino, levels); - if (ext4_dir_htree_level(sb) < EXT4_HTREE_LEVEL) { -- ext4_warning(sb, "Large directory feature is" -+ ext4_warning(sb, "Large directory feature is " - "not enabled on this " - "filesystem"); - } -@@ -2248,6 +2310,8 @@ cleanup: - * repeat dx_probe() to find out valid htree-path */ - if (restart && err == 0) - goto again; -+ if (err == 0 && ret_warn) -+ err = -ENOBUFS; - return err; - } - -diff --git a/fs/ext4/super.c b/fs/ext4/super.c -index f02a632..b8ed072 100644 ---- a/fs/ext4/super.c -+++ b/fs/ext4/super.c -@@ -1813,6 +1813,8 @@ set_qf_format: - if (option < 0) - return 0; - sbi->s_max_dir_size = option * 1024; -+ /* reset s_warning_dir_size and make it re-calculated */ -+ sbi->s_warning_dir_size = 0; - break; - case Opt_stripe: - if (match_int(&args[0], &option)) -@@ -2577,6 +2579,7 @@ EXT4_ATTR_OFFSET(inode_readahead_blks, 0644, sbi_ui_show, - inode_readahead_blks_store, s_inode_readahead_blks); - EXT4_RW_ATTR_SBI_UI(inode_goal, s_inode_goal); - EXT4_RW_ATTR_SBI_UI(max_dir_size, s_max_dir_size); -+EXT4_RW_ATTR_SBI_UI(warning_dir_size, s_warning_dir_size); - EXT4_RW_ATTR_SBI_UI(mb_stats, s_mb_stats); - EXT4_RW_ATTR_SBI_UI(mb_max_to_scan, s_mb_max_to_scan); - EXT4_RW_ATTR_SBI_UI(mb_min_to_scan, s_mb_min_to_scan); -@@ -2594,6 +2597,7 @@ static struct attribute *ext4_attrs[] = { - ATTR_LIST(inode_readahead_blks), - ATTR_LIST(inode_goal), - ATTR_LIST(max_dir_size), -+ ATTR_LIST(warning_dir_size), - ATTR_LIST(mb_stats), - ATTR_LIST(mb_max_to_scan), - ATTR_LIST(mb_min_to_scan), -@@ -3119,6 +3123,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) - sb->s_fs_info = sbi; - sbi->s_mount_opt = 0; - sbi->s_max_dir_size = 0; -+ sbi->s_warning_dir_size = 0; - sbi->s_resuid = EXT4_DEF_RESUID; - sbi->s_resgid = EXT4_DEF_RESGID; - sbi->s_inode_readahead_blks = EXT4_DEF_INODE_READAHEAD_BLKS; diff --git a/ldiskfs/kernel_patches/patches/rhel7.2/ext4-dont-check-before-replay.patch b/ldiskfs/kernel_patches/patches/rhel7.2/ext4-dont-check-before-replay.patch deleted file mode 100644 index de1b7f6..0000000 --- a/ldiskfs/kernel_patches/patches/rhel7.2/ext4-dont-check-before-replay.patch +++ /dev/null @@ -1,33 +0,0 @@ -Index: linux-stage/fs/ext4/super.c -When ldiskfs run in failover mode whith read-only disk. -Part of allocation updates are lost and ldiskfs may fail -while mounting this is due to inconsistent state of -group-descriptor. Group-descriptor check is added after -journal replay. -=================================================================== ---- linux-stage/fs/ext4/super.c 2016-11-06 15:15:30.892386878 +0530 -+++ linux-stage.orig.1/fs/ext4/super.c 2016-11-08 10:56:45.579892189 +0530 -@@ -3980,10 +3980,6 @@ - goto failed_mount2; - } - } -- if (!ext4_check_descriptors(sb, &first_not_zeroed)) { -- ext4_msg(sb, KERN_ERR, "group descriptors corrupted!"); -- goto failed_mount2; -- } - - sbi->s_gdb_count = db_count; - get_random_bytes(&sbi->s_next_generation, sizeof(u32)); -@@ -4104,6 +4100,12 @@ - sbi->s_journal->j_commit_callback = ext4_journal_commit_callback; - - no_journal: -+ -+ if (!ext4_check_descriptors(sb, &first_not_zeroed)) { -+ ext4_msg(sb, KERN_ERR, "group descriptors corrupted!"); -+ goto failed_mount_wq; -+ } -+ - /* - * Get the # of file system overhead blocks from the - * superblock if present. diff --git a/ldiskfs/kernel_patches/patches/rhel7.2/ext4-dont-check-in-ro.patch b/ldiskfs/kernel_patches/patches/rhel7.2/ext4-dont-check-in-ro.patch deleted file mode 100644 index 9fa9194..0000000 --- a/ldiskfs/kernel_patches/patches/rhel7.2/ext4-dont-check-in-ro.patch +++ /dev/null @@ -1,29 +0,0 @@ ---- linux-stage/fs/ext4/mballoc.c 2016-11-25 04:15:25.824396109 +0530 -+++ linux-stage.orig/fs/ext4/mballoc.c 2016-11-25 02:59:13.505151246 +0530 -@@ -3594,6 +3594,11 @@ - unsigned short max = EXT4_CLUSTERS_PER_GROUP(sb); - unsigned short i, first, free = 0; - -+#ifdef HAVE_CLEAR_RDONLY_ON_PUT -+ /* be quiet if readonly device */ -+ if (dev_check_rdonly(sb->s_bdev)) -+ return 0; -+#endif - i = mb_find_next_zero_bit(bitmap, max, 0); - - while (i < max) { -@@ -3969,6 +3974,14 @@ - bit = next + 1; - } - -+ -+#ifdef HAVE_CLEAR_RDONLY_ON_PUT -+ /* be quiet if readonly device */ -+ if (dev_check_rdonly(sb->s_bdev)) { -+ atomic_add(free, &sbi->s_mb_discarded); -+ return err; -+ } -+#endif - /* "free < pa->pa_free" means we maybe double alloc the same blocks, - * otherwise maybe leave some free blocks unavailable, no need to BUG.*/ - if ((free > pa->pa_free && !pa->pa_error) || (free < pa->pa_free)) { diff --git a/ldiskfs/kernel_patches/patches/rhel7.2/ext4-large-eas.patch b/ldiskfs/kernel_patches/patches/rhel7.2/ext4-large-eas.patch deleted file mode 100644 index 35ca4d5..0000000 --- a/ldiskfs/kernel_patches/patches/rhel7.2/ext4-large-eas.patch +++ /dev/null @@ -1,1093 +0,0 @@ -This patch implements the large EA support in ext4. If the size of -an EA value is larger than the blocksize, then the EA value would -not be saved in the external EA block, instead it would be saved -in an external EA inode. So, the patch also helps support a larger -number of EAs. - -Index: linux-stage/fs/ext4/ext4.h -=================================================================== ---- linux-stage.orig/fs/ext4/ext4.h -+++ linux-stage/fs/ext4/ext4.h -@@ -1579,6 +1579,7 @@ static inline void ext4_clear_state_flag - EXT4_FEATURE_INCOMPAT_EXTENTS| \ - EXT4_FEATURE_INCOMPAT_64BIT| \ - EXT4_FEATURE_INCOMPAT_FLEX_BG| \ -+ EXT4_FEATURE_INCOMPAT_EA_INODE| \ - EXT4_FEATURE_INCOMPAT_MMP | \ - EXT4_FEATURE_INCOMPAT_DIRDATA| \ - EXT4_FEATURE_INCOMPAT_INLINE_DATA) -@@ -1990,6 +1997,10 @@ struct mmpd_data { - # define ATTRIB_NORET __attribute__((noreturn)) - # define NORET_AND noreturn, - -+struct ext4_xattr_ino_array { -+ unsigned int xia_count; /* # of used item in the array */ -+ unsigned int xia_inodes[0]; -+}; - /* bitmap.c */ - extern unsigned int ext4_count_free(char *bitmap, unsigned numchars); - void ext4_inode_bitmap_csum_set(struct super_block *sb, ext4_group_t group, -@@ -2194,6 +2205,7 @@ extern void ext4_set_inode_flags(struct - extern void ext4_get_inode_flags(struct ext4_inode_info *); - extern int ext4_alloc_da_blocks(struct inode *inode); - extern void ext4_set_aops(struct inode *inode); -+extern int ext4_meta_trans_blocks(struct inode *, int nrblocks, int chunk); - extern int ext4_writepage_trans_blocks(struct inode *); - extern int ext4_chunk_trans_blocks(struct inode *, int nrblocks); - extern int ext4_zero_partial_blocks(handle_t *handle, struct inode *inode, -Index: linux-stage/fs/ext4/inode.c -=================================================================== ---- linux-stage.orig/fs/ext4/inode.c -+++ linux-stage/fs/ext4/inode.c -@@ -134,8 +134,6 @@ static void ext4_invalidatepage(struct p - unsigned int length); - static int __ext4_journalled_writepage(struct page *page, unsigned int len); - static int ext4_bh_delay_or_unwritten(handle_t *handle, struct buffer_head *bh); --static int ext4_meta_trans_blocks(struct inode *inode, int lblocks, -- int pextents); - - /* - * Test whether an inode is a fast symlink. -@@ -184,6 +182,8 @@ void ext4_evict_inode(struct inode *inod - { - handle_t *handle; - int err; -+ int extra_credits = 3; -+ struct ext4_xattr_ino_array *lea_ino_array = NULL; - - trace_ext4_evict_inode(inode); - -@@ -236,8 +236,8 @@ void ext4_evict_inode(struct inode *inod - * protection against it - */ - sb_start_intwrite(inode->i_sb); -- handle = ext4_journal_start(inode, EXT4_HT_TRUNCATE, -- ext4_blocks_for_truncate(inode)+3); -+ -+ handle = ext4_journal_start(inode, EXT4_HT_TRUNCATE, extra_credits); - if (IS_ERR(handle)) { - ext4_std_error(inode->i_sb, PTR_ERR(handle)); - /* -@@ -252,6 +252,32 @@ void ext4_evict_inode(struct inode *inod - - if (IS_SYNC(inode)) - ext4_handle_sync(handle); -+ -+ /* Delete xattr inode before deleting the main inode. */ -+ err = ext4_xattr_delete_inode(handle, inode, &lea_ino_array); -+ if (err) { -+ ext4_warning(inode->i_sb, -+ "couldn't delete inode's xattr (err %d)", err); -+ goto stop_handle; -+ } -+ -+ if (!IS_NOQUOTA(inode)) -+ extra_credits += 2 * EXT4_QUOTA_DEL_BLOCKS(inode->i_sb); -+ -+ if (!ext4_handle_has_enough_credits(handle, -+ ext4_blocks_for_truncate(inode) + extra_credits)) { -+ err = ext4_journal_extend(handle, -+ ext4_blocks_for_truncate(inode) + extra_credits); -+ if (err > 0) -+ err = ext4_journal_restart(handle, -+ ext4_blocks_for_truncate(inode) + extra_credits); -+ if (err != 0) { -+ ext4_warning(inode->i_sb, -+ "couldn't extend journal (err %d)", err); -+ goto stop_handle; -+ } -+ } -+ - inode->i_size = 0; - err = ext4_mark_inode_dirty(handle, inode); - if (err) { -@@ -269,10 +296,10 @@ void ext4_evict_inode(struct inode *inod - * enough credits left in the handle to remove the inode from - * the orphan list and set the dtime field. - */ -- if (!ext4_handle_has_enough_credits(handle, 3)) { -- err = ext4_journal_extend(handle, 3); -+ if (!ext4_handle_has_enough_credits(handle, extra_credits)) { -+ err = ext4_journal_extend(handle, extra_credits); - if (err > 0) -- err = ext4_journal_restart(handle, 3); -+ err = ext4_journal_restart(handle, extra_credits); - if (err != 0) { - ext4_warning(inode->i_sb, - "couldn't extend journal (err %d)", err); -@@ -308,6 +335,9 @@ void ext4_evict_inode(struct inode *inod - ext4_free_inode(handle, inode); - ext4_journal_stop(handle); - sb_end_intwrite(inode->i_sb); -+ -+ if (lea_ino_array != NULL) -+ ext4_xattr_inode_array_free(inode, lea_ino_array); - return; - no_delete: - ext4_clear_inode(inode); /* We must guarantee clearing of inode... */ -@@ -4681,7 +4711,7 @@ static int ext4_index_trans_blocks(struc - * - * Also account for superblock, inode, quota and xattr blocks - */ --static int ext4_meta_trans_blocks(struct inode *inode, int lblocks, -+int ext4_meta_trans_blocks(struct inode *inode, int lblocks, - int pextents) - { - ext4_group_t groups, ngroups = ext4_get_groups_count(inode->i_sb); -Index: linux-stage/fs/ext4/xattr.c -=================================================================== ---- linux-stage.orig/fs/ext4/xattr.c -+++ linux-stage/fs/ext4/xattr.c -@@ -201,6 +201,7 @@ ext4_xattr_check_names(struct ext4_xattr - - while (!IS_LAST_ENTRY(entry)) { - if (entry->e_value_size != 0 && -+ entry->e_value_inum == 0 && - (value_start + le16_to_cpu(entry->e_value_offs) < - (void *)e + sizeof(__u32) || - value_start + le16_to_cpu(entry->e_value_offs) + -@@ -233,19 +234,26 @@ ext4_xattr_check_block(struct inode *ino - } - - static inline int --ext4_xattr_check_entry(struct ext4_xattr_entry *entry, size_t size) -+ext4_xattr_check_entry(struct ext4_xattr_entry *entry, size_t size, -+ struct inode *inode) - { - size_t value_size = le32_to_cpu(entry->e_value_size); - -- if (entry->e_value_block != 0 || value_size > size || -+ if (!entry->e_value_inum && - le16_to_cpu(entry->e_value_offs) + value_size > size) -+ return -EIO; -+ if (entry->e_value_inum && -+ (le32_to_cpu(entry->e_value_inum) < EXT4_FIRST_INO(inode->i_sb) || -+ le32_to_cpu(entry->e_value_inum) > -+ le32_to_cpu(EXT4_SB(inode->i_sb)->s_es->s_inodes_count))) - return -EIO; - return 0; - } - - static int - ext4_xattr_find_entry(struct ext4_xattr_entry **pentry, int name_index, -- const char *name, size_t size, int sorted) -+ const char *name, size_t size, int sorted, -+ struct inode *inode) - { - struct ext4_xattr_entry *entry; - size_t name_len; -@@ -265,11 +273,109 @@ ext4_xattr_find_entry(struct ext4_xattr_ - break; - } - *pentry = entry; -- if (!cmp && ext4_xattr_check_entry(entry, size)) -+ if (!cmp && ext4_xattr_check_entry(entry, size, inode)) - return -EIO; - return cmp ? -ENODATA : 0; - } - -+/* -+ * Read the EA value from an inode. -+ */ -+static int ext4_xattr_inode_read(struct inode *ea_inode, void *buf, size_t *size) -+{ -+ unsigned long block = 0; -+ struct buffer_head *bh = NULL; -+ int err, blocksize; -+ size_t csize, ret_size = 0; -+ -+ if (*size == 0) -+ return 0; -+ -+ blocksize = ea_inode->i_sb->s_blocksize; -+ -+ while (ret_size < *size) { -+ csize = (*size - ret_size) > blocksize ? blocksize : -+ *size - ret_size; -+ bh = ext4_bread(NULL, ea_inode, block, 0, &err); -+ if (!bh) { -+ *size = ret_size; -+ return err; -+ } -+ memcpy(buf, bh->b_data, csize); -+ brelse(bh); -+ -+ buf += csize; -+ block += 1; -+ ret_size += csize; -+ } -+ -+ *size = ret_size; -+ -+ return err; -+} -+ -+/* -+ * Fetch the xattr inode from disk. -+ * -+ * The xattr inode stores the parent inode number and generation so that -+ * the kernel and e2fsck can verify the xattr inode is valid upon access. -+ */ -+struct inode *ext4_xattr_inode_iget(struct inode *parent, -+ unsigned long ea_ino, int *err) -+{ -+ struct inode *ea_inode = NULL; -+ -+ ea_inode = ext4_iget(parent->i_sb, ea_ino); -+ if (IS_ERR(ea_inode) || is_bad_inode(ea_inode)) { -+ int rc = IS_ERR(ea_inode) ? PTR_ERR(ea_inode) : 0; -+ ext4_error(parent->i_sb, "error while reading EA inode %lu " -+ "/ %d %d", ea_ino, rc, is_bad_inode(ea_inode)); -+ *err = rc != 0 ? rc : -EIO; -+ return NULL; -+ } -+ -+ if (EXT4_XATTR_INODE_GET_PARENT(ea_inode) != parent->i_ino || -+ ea_inode->i_generation != parent->i_generation) { -+ ext4_error(parent->i_sb, "Backpointer from EA inode %lu " -+ "to parent invalid.", ea_ino); -+ *err = -EINVAL; -+ goto error; -+ } -+ -+ if (!(EXT4_I(ea_inode)->i_flags & EXT4_EA_INODE_FL)) { -+ ext4_error(parent->i_sb, "EA inode %lu does not have " -+ "EXT4_EA_INODE_FL flag set.\n", ea_ino); -+ *err = -EINVAL; -+ goto error; -+ } -+ -+ *err = 0; -+ return ea_inode; -+ -+error: -+ iput(ea_inode); -+ return NULL; -+} -+ -+/* -+ * Read the value from the EA inode. -+ */ -+static int ext4_xattr_inode_get(struct inode *inode, unsigned long ea_ino, -+ void *buffer, size_t *size) -+{ -+ struct inode *ea_inode = NULL; -+ int err; -+ -+ ea_inode = ext4_xattr_inode_iget(inode, ea_ino, &err); -+ if (err) -+ return err; -+ -+ err = ext4_xattr_inode_read(ea_inode, buffer, size); -+ iput(ea_inode); -+ -+ return err; -+} -+ - static int - ext4_xattr_block_get(struct inode *inode, int name_index, const char *name, - void *buffer, size_t buffer_size) -@@ -301,7 +401,8 @@ bad_block: - } - ext4_xattr_cache_insert(bh); - entry = BFIRST(bh); -- error = ext4_xattr_find_entry(&entry, name_index, name, bh->b_size, 1); -+ error = ext4_xattr_find_entry(&entry, name_index, name, bh->b_size, 1, -+ inode); - if (error == -EIO) - goto bad_block; - if (error) -@@ -311,8 +412,16 @@ bad_block: - error = -ERANGE; - if (size > buffer_size) - goto cleanup; -- memcpy(buffer, bh->b_data + le16_to_cpu(entry->e_value_offs), -- size); -+ if (entry->e_value_inum) { -+ error = ext4_xattr_inode_get(inode, -+ le32_to_cpu(entry->e_value_inum), -+ buffer, &size); -+ if (error) -+ goto cleanup; -+ } else { -+ memcpy(buffer, bh->b_data + -+ le16_to_cpu(entry->e_value_offs), size); -+ } - } - error = size; - -@@ -346,7 +455,7 @@ ext4_xattr_ibody_get(struct inode *inode - if (error) - goto cleanup; - error = ext4_xattr_find_entry(&entry, name_index, name, -- end - (void *)entry, 0); -+ end - (void *)entry, 0, inode); - if (error) - goto cleanup; - size = le32_to_cpu(entry->e_value_size); -@@ -354,8 +463,16 @@ ext4_xattr_ibody_get(struct inode *inode - error = -ERANGE; - if (size > buffer_size) - goto cleanup; -- memcpy(buffer, (void *)IFIRST(header) + -- le16_to_cpu(entry->e_value_offs), size); -+ if (entry->e_value_inum) { -+ error = ext4_xattr_inode_get(inode, -+ le32_to_cpu(entry->e_value_inum), -+ buffer, &size); -+ if (error) -+ goto cleanup; -+ } else { -+ memcpy(buffer, (void *)IFIRST(header) + -+ le16_to_cpu(entry->e_value_offs), size); -+ } - } - error = size; - -@@ -600,7 +717,7 @@ static size_t ext4_xattr_free_space(stru - size_t *min_offs, void *base, int *total) - { - for (; !IS_LAST_ENTRY(last); last = EXT4_XATTR_NEXT(last)) { -- if (!last->e_value_block && last->e_value_size) { -+ if (!last->e_value_inum && last->e_value_size) { - size_t offs = le16_to_cpu(last->e_value_offs); - if (offs < *min_offs) - *min_offs = offs; -@@ -611,16 +728,198 @@ static size_t ext4_xattr_free_space(stru - return (*min_offs - ((void *)last - base) - sizeof(__u32)); - } - -+/* -+ * Write the value of the EA in an inode. -+ */ - static int --ext4_xattr_set_entry(struct ext4_xattr_info *i, struct ext4_xattr_search *s) -+ext4_xattr_inode_write(handle_t *handle, struct inode *ea_inode, -+ const void *buf, int bufsize) -+{ -+ struct buffer_head *bh = NULL; -+ unsigned long block = 0; -+ unsigned blocksize = ea_inode->i_sb->s_blocksize; -+ unsigned max_blocks = (bufsize + blocksize - 1) >> ea_inode->i_blkbits; -+ int csize, wsize = 0; -+ int ret = 0; -+ int retries = 0; -+ -+retry: -+ while (ret >= 0 && ret < max_blocks) { -+ struct ext4_map_blocks map; -+ map.m_lblk = block += ret; -+ map.m_len = max_blocks -= ret; -+ -+ ret = ext4_map_blocks(handle, ea_inode, &map, -+ EXT4_GET_BLOCKS_CREATE); -+ if (ret <= 0) { -+ ext4_mark_inode_dirty(handle, ea_inode); -+ if (ret == -ENOSPC && -+ ext4_should_retry_alloc(ea_inode->i_sb, &retries)) { -+ ret = 0; -+ goto retry; -+ } -+ break; -+ } -+ } -+ -+ if (ret < 0) -+ return ret; -+ -+ block = 0; -+ while (wsize < bufsize) { -+ if (bh != NULL) -+ brelse(bh); -+ csize = (bufsize - wsize) > blocksize ? blocksize : -+ bufsize - wsize; -+ bh = ext4_getblk(handle, ea_inode, block, 0, &ret); -+ if (!bh) -+ goto out; -+ ret = ext4_journal_get_write_access(handle, bh); -+ if (ret) -+ goto out; -+ -+ memcpy(bh->b_data, buf, csize); -+ set_buffer_uptodate(bh); -+ ext4_handle_dirty_metadata(handle, ea_inode, bh); -+ -+ buf += csize; -+ wsize += csize; -+ block += 1; -+ } -+ -+ mutex_lock(&ea_inode->i_mutex); -+ i_size_write(ea_inode, wsize); -+ ext4_update_i_disksize(ea_inode, wsize); -+ mutex_unlock(&ea_inode->i_mutex); -+ -+ ext4_mark_inode_dirty(handle, ea_inode); -+ -+out: -+ brelse(bh); -+ -+ return ret; -+} -+ -+static void ext4_xattr_inode_set_ref(struct inode *ea_inode, __u64 ref_count) -+{ -+ ea_inode->i_ctime.tv_sec = (__u32)(ref_count >> 32); -+ ea_inode->i_version = (__u32)ref_count; -+} -+ -+static void ext4_xattr_inode_set_hash(struct inode *ea_inode, __u32 hash) -+{ -+ ea_inode->i_atime.tv_sec = hash; -+} -+ -+/* -+ * Create an inode to store the value of a large EA. -+ */ -+static struct inode * -+ext4_xattr_inode_create(handle_t *handle, struct inode *inode, __u32 hash) -+{ -+ struct inode *ea_inode = NULL; -+ -+ /* -+ * Let the next inode be the goal, so we try and allocate the EA inode -+ * in the same group, or nearby one. -+ */ -+ ea_inode = ext4_new_inode(handle, inode->i_sb->s_root->d_inode, -+ S_IFREG|0600, NULL, inode->i_ino + 1, NULL); -+ -+ if (!IS_ERR(ea_inode)) { -+ ea_inode->i_op = &ext4_file_inode_operations; -+ ea_inode->i_fop = &ext4_file_operations; -+ ext4_set_aops(ea_inode); -+ ea_inode->i_generation = inode->i_generation; -+ EXT4_I(ea_inode)->i_flags |= EXT4_EA_INODE_FL; -+ -+ /* -+ * A back-pointer from EA inode to parent inode will be useful -+ * for e2fsck. -+ */ -+ EXT4_XATTR_INODE_SET_PARENT(ea_inode, inode->i_ino); -+ unlock_new_inode(ea_inode); -+ -+ ext4_xattr_inode_set_ref(ea_inode, 1); -+ ext4_xattr_inode_set_hash(ea_inode, hash); -+ } -+ -+ return ea_inode; -+} -+ -+/* -+ * Unlink the inode storing the value of the EA. -+ */ -+int -+ext4_xattr_inode_unlink(struct inode *inode, unsigned long ea_ino) -+{ -+ struct inode *ea_inode = NULL; -+ int err; -+ -+ ea_inode = ext4_xattr_inode_iget(inode, ea_ino, &err); -+ if (err) -+ return err; -+ -+ clear_nlink(ea_inode); -+ iput(ea_inode); -+ -+ return 0; -+} -+ -+static __u32 -+ext4_xattr_inode_hash(struct ext4_sb_info *sbi, const void *buffer, size_t size) -+{ -+ if (ext4_has_metadata_csum(sbi->s_sb)) -+ return ext4_chksum(sbi, sbi->s_csum_seed, buffer, size); -+ return 0; -+} -+ -+/* -+ * Add value of the EA in an inode. -+ */ -+static int -+ext4_xattr_inode_set(handle_t *handle, struct inode *inode, unsigned long *ea_ino, -+ const void *value, size_t value_len) -+{ -+ struct inode *ea_inode = NULL; -+ __u32 hash; -+ int err; -+ -+ /* Create an inode for the EA value */ -+ hash = ext4_xattr_inode_hash(EXT4_SB(inode->i_sb), value, value_len); -+ ea_inode = ext4_xattr_inode_create(handle, inode, hash); -+ if (IS_ERR(ea_inode)) -+ return -1; -+ -+ err = ext4_xattr_inode_write(handle, ea_inode, value, value_len); -+ if (err) -+ clear_nlink(ea_inode); -+ else -+ *ea_ino = ea_inode->i_ino; -+ -+ iput(ea_inode); -+ -+ return err; -+} -+ -+static int -+ext4_xattr_set_entry(struct ext4_xattr_info *i, struct ext4_xattr_search *s, -+ handle_t *handle, struct inode *inode) - { - struct ext4_xattr_entry *last; - size_t free, min_offs = s->end - s->base, name_len = strlen(i->name); -+ int in_inode = i->in_inode; -+ -+ if (EXT4_HAS_INCOMPAT_FEATURE(inode->i_sb, -+ EXT4_FEATURE_INCOMPAT_EA_INODE) && -+ (EXT4_XATTR_SIZE(i->value_len) > -+ EXT4_XATTR_MIN_LARGE_EA_SIZE(inode->i_sb->s_blocksize))) -+ in_inode = 1; - - /* Compute min_offs and last. */ - last = s->first; - for (; !IS_LAST_ENTRY(last); last = EXT4_XATTR_NEXT(last)) { -- if (!last->e_value_block && last->e_value_size) { -+ if (!last->e_value_inum && last->e_value_size) { - size_t offs = le16_to_cpu(last->e_value_offs); - if (offs < min_offs) - min_offs = offs; -@@ -628,15 +927,21 @@ ext4_xattr_set_entry(struct ext4_xattr_i - } - free = min_offs - ((void *)last - s->base) - sizeof(__u32); - if (!s->not_found) { -- if (!s->here->e_value_block && s->here->e_value_size) { -+ if (!in_inode && -+ !s->here->e_value_inum && s->here->e_value_size) { - size_t size = le32_to_cpu(s->here->e_value_size); - free += EXT4_XATTR_SIZE(size); - } - free += EXT4_XATTR_LEN(name_len); - } - if (i->value) { -- if (free < EXT4_XATTR_LEN(name_len) + -- EXT4_XATTR_SIZE(i->value_len)) -+ size_t value_len = EXT4_XATTR_SIZE(i->value_len); -+ -+ if (in_inode) -+ value_len = 0; -+ -+ if (free < value_len || -+ free < EXT4_XATTR_LEN(name_len) + value_len) - return -ENOSPC; - } - -@@ -651,7 +955,8 @@ ext4_xattr_set_entry(struct ext4_xattr_i - s->here->e_name_len = name_len; - memcpy(s->here->e_name, i->name, name_len); - } else { -- if (!s->here->e_value_block && s->here->e_value_size) { -+ if (!s->here->e_value_inum && s->here->e_value_size && -+ s->here->e_value_offs > 0) { - void *first_val = s->base + min_offs; - size_t offs = le16_to_cpu(s->here->e_value_offs); - void *val = s->base + offs; -@@ -685,13 +990,18 @@ ext4_xattr_set_entry(struct ext4_xattr_i - last = s->first; - while (!IS_LAST_ENTRY(last)) { - size_t o = le16_to_cpu(last->e_value_offs); -- if (!last->e_value_block && -+ if (!last->e_value_inum && - last->e_value_size && o < offs) - last->e_value_offs = - cpu_to_le16(o + size); - last = EXT4_XATTR_NEXT(last); - } - } -+ if (s->here->e_value_inum) { -+ ext4_xattr_inode_unlink(inode, -+ le32_to_cpu(s->here->e_value_inum)); -+ s->here->e_value_inum = 0; -+ } - if (!i->value) { - /* Remove the old name. */ - size_t size = EXT4_XATTR_LEN(name_len); -@@ -705,10 +1014,17 @@ ext4_xattr_set_entry(struct ext4_xattr_i - if (i->value) { - /* Insert the new value. */ - s->here->e_value_size = cpu_to_le32(i->value_len); -- if (i->value_len) { -+ if (in_inode) { -+ unsigned long ea_ino = le32_to_cpu(s->here->e_value_inum); -+ ext4_xattr_inode_set(handle, inode, &ea_ino, i->value, -+ i->value_len); -+ s->here->e_value_inum = cpu_to_le32(ea_ino); -+ s->here->e_value_offs = 0; -+ } else if (i->value_len) { - size_t size = EXT4_XATTR_SIZE(i->value_len); - void *val = s->base + min_offs - size; - s->here->e_value_offs = cpu_to_le16(min_offs - size); -+ s->here->e_value_inum = 0; - if (i->value == EXT4_ZERO_XATTR_VALUE) { - memset(val, 0, size); - } else { -@@ -758,7 +1074,7 @@ ext4_xattr_block_find(struct inode *inod - bs->s.end = bs->bh->b_data + bs->bh->b_size; - bs->s.here = bs->s.first; - error = ext4_xattr_find_entry(&bs->s.here, i->name_index, -- i->name, bs->bh->b_size, 1); -+ i->name, bs->bh->b_size, 1, inode); - if (error && error != -ENODATA) - goto cleanup; - bs->s.not_found = error; -@@ -782,8 +1098,6 @@ ext4_xattr_block_set(handle_t *handle, s - - #define header(x) ((struct ext4_xattr_header *)(x)) - -- if (i->value && i->value_len > sb->s_blocksize) -- return -ENOSPC; - if (s->base) { - ce = mb_cache_entry_get(ext4_xattr_cache, bs->bh->b_bdev, - bs->bh->b_blocknr); -@@ -799,7 +1113,7 @@ ext4_xattr_block_set(handle_t *handle, s - ce = NULL; - } - ea_bdebug(bs->bh, "modifying in-place"); -- error = ext4_xattr_set_entry(i, s); -+ error = ext4_xattr_set_entry(i, s, handle, inode); - if (!error) { - if (!IS_LAST_ENTRY(s->first)) - ext4_xattr_rehash(header(s->base), -@@ -850,7 +1164,7 @@ ext4_xattr_block_set(handle_t *handle, s - s->end = s->base + sb->s_blocksize; - } - -- error = ext4_xattr_set_entry(i, s); -+ error = ext4_xattr_set_entry(i, s, handle, inode); - if (error == -EIO) - goto bad_block; - if (error) -@@ -1000,7 +1314,7 @@ int ext4_xattr_ibody_find(struct inode * - /* Find the named attribute. */ - error = ext4_xattr_find_entry(&is->s.here, i->name_index, - i->name, is->s.end - -- (void *)is->s.base, 0); -+ (void *)is->s.base, 0, inode); - if (error && error != -ENODATA) - return error; - is->s.not_found = error; -@@ -1018,7 +1332,7 @@ int ext4_xattr_ibody_inline_set(handle_t - - if (EXT4_I(inode)->i_extra_isize == 0) - return -ENOSPC; -- error = ext4_xattr_set_entry(i, s); -+ error = ext4_xattr_set_entry(i, s, handle, inode); - if (error) { - if (error == -ENOSPC && - ext4_has_inline_data(inode)) { -@@ -1030,7 +1344,7 @@ int ext4_xattr_ibody_inline_set(handle_t - error = ext4_xattr_ibody_find(inode, i, is); - if (error) - return error; -- error = ext4_xattr_set_entry(i, s); -+ error = ext4_xattr_set_entry(i, s, handle, inode); - } - if (error) - return error; -@@ -1056,7 +1370,7 @@ static int ext4_xattr_ibody_set(handle_t - - if (EXT4_I(inode)->i_extra_isize == 0) - return -ENOSPC; -- error = ext4_xattr_set_entry(i, s); -+ error = ext4_xattr_set_entry(i, s, handle, inode); - if (error) - return error; - header = IHDR(inode, ext4_raw_inode(&is->iloc)); -@@ -1092,7 +1406,7 @@ ext4_xattr_set_handle(handle_t *handle, - .name = name, - .value = value, - .value_len = value_len, -- -+ .in_inode = 0, - }; - struct ext4_xattr_ibody_find is = { - .s = { .not_found = -ENODATA, }, -@@ -1157,6 +1471,15 @@ ext4_xattr_set_handle(handle_t *handle, - goto cleanup; - } - error = ext4_xattr_block_set(handle, inode, &i, &bs); -+ if (EXT4_HAS_INCOMPAT_FEATURE(inode->i_sb, -+ EXT4_FEATURE_INCOMPAT_EA_INODE) && -+ error == -ENOSPC) { -+ /* xattr not fit to block, store at external -+ * inode */ -+ i.in_inode = 1; -+ error = ext4_xattr_ibody_set(handle, inode, -+ &i, &is); -+ } - if (error) - goto cleanup; - if (!is.s.not_found) { -@@ -1203,9 +1526,22 @@ ext4_xattr_set(struct inode *inode, int - const void *value, size_t value_len, int flags) - { - handle_t *handle; -+ struct super_block *sb = inode->i_sb; - int error, retries = 0; - int credits = ext4_jbd2_credits_xattr(inode); - -+ if ((value_len >= EXT4_XATTR_MIN_LARGE_EA_SIZE(sb->s_blocksize)) && -+ EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EA_INODE)) { -+ int nrblocks = (value_len + sb->s_blocksize - 1) >> -+ sb->s_blocksize_bits; -+ -+ /* For new inode */ -+ credits += EXT4_SINGLEDATA_TRANS_BLOCKS(sb) + 3; -+ -+ /* For data blocks of EA inode */ -+ credits += ext4_meta_trans_blocks(inode, nrblocks, 0); -+ } -+ - retry: - handle = ext4_journal_start(inode, EXT4_HT_XATTR, credits); - if (IS_ERR(handle)) { -@@ -1217,7 +1553,7 @@ retry: - value, value_len, flags); - error2 = ext4_journal_stop(handle); - if (error == -ENOSPC && -- ext4_should_retry_alloc(inode->i_sb, &retries)) -+ ext4_should_retry_alloc(sb, &retries)) - goto retry; - if (error == 0) - error = error2; -@@ -1239,7 +1575,7 @@ static void ext4_xattr_shift_entries(str - - /* Adjust the value offsets of the entries */ - for (; !IS_LAST_ENTRY(last); last = EXT4_XATTR_NEXT(last)) { -- if (!last->e_value_block && last->e_value_size) { -+ if (!last->e_value_inum && last->e_value_size) { - new_offs = le16_to_cpu(last->e_value_offs) + - value_offs_shift; - BUG_ON(new_offs + le32_to_cpu(last->e_value_size) -@@ -1477,21 +1813,135 @@ cleanup: - } - - -+#define EIA_INCR 16 /* must be 2^n */ -+#define EIA_MASK (EIA_INCR - 1) -+/* Add the large xattr @ino into @lea_ino_array for later deletion. -+ * If @lea_ino_array is new or full it will be grown and the old -+ * contents copied over. -+ */ -+static int -+ext4_expand_ino_array(struct ext4_xattr_ino_array **lea_ino_array, __u32 ino) -+{ -+ if (*lea_ino_array == NULL) { -+ /* -+ * Start with 15 inodes, so it fits into a power-of-two size. -+ * If *lea_ino_array is NULL, this is essentially offsetof() -+ */ -+ (*lea_ino_array) = -+ kmalloc(offsetof(struct ext4_xattr_ino_array, -+ xia_inodes[EIA_MASK]), -+ GFP_NOFS); -+ if (*lea_ino_array == NULL) -+ return -ENOMEM; -+ (*lea_ino_array)->xia_count = 0; -+ } else if (((*lea_ino_array)->xia_count & EIA_MASK) == EIA_MASK) { -+ /* expand the array once all 15 + n * 16 slots are full */ -+ struct ext4_xattr_ino_array *new_array = NULL; -+ int count = (*lea_ino_array)->xia_count; -+ -+ /* if new_array is NULL, this is essentially offsetof() */ -+ new_array = kmalloc( -+ offsetof(struct ext4_xattr_ino_array, -+ xia_inodes[count + EIA_INCR]), -+ GFP_NOFS); -+ if (new_array == NULL) -+ return -ENOMEM; -+ memcpy(new_array, *lea_ino_array, -+ offsetof(struct ext4_xattr_ino_array, -+ xia_inodes[count])); -+ kfree(*lea_ino_array); -+ *lea_ino_array = new_array; -+ } -+ (*lea_ino_array)->xia_inodes[(*lea_ino_array)->xia_count++] = ino; -+ return 0; -+} -+ -+/** -+ * Add xattr inode to orphan list -+ */ -+static int -+ext4_xattr_inode_orphan_add(handle_t *handle, struct inode *inode, -+ int credits, struct ext4_xattr_ino_array *lea_ino_array) -+{ -+ struct inode *ea_inode = NULL; -+ int idx = 0, error = 0; -+ -+ if (lea_ino_array == NULL) -+ return 0; -+ -+ for (; idx < lea_ino_array->xia_count; ++idx) { -+ if (!ext4_handle_has_enough_credits(handle, credits)) { -+ error = ext4_journal_extend(handle, credits); -+ if (error > 0) -+ error = ext4_journal_restart(handle, credits); -+ -+ if (error != 0) { -+ ext4_warning(inode->i_sb, -+ "couldn't extend journal " -+ "(err %d)", error); -+ return error; -+ } -+ } -+ ea_inode = ext4_xattr_inode_iget(inode, -+ lea_ino_array->xia_inodes[idx], &error); -+ if (error) -+ continue; -+ ext4_orphan_add(handle, ea_inode); -+ /* the inode's i_count will be released by caller */ -+ } -+ -+ return 0; -+} - - /* - * ext4_xattr_delete_inode() - * -- * Free extended attribute resources associated with this inode. This -+ * Free extended attribute resources associated with this inode. Traverse -+ * all entries and unlink any xattr inodes associated with this inode. This - * is called immediately before an inode is freed. We have exclusive -- * access to the inode. -+ * access to the inode. If an orphan inode is deleted it will also delete any -+ * xattr block and all xattr inodes. They are checked by ext4_xattr_inode_iget() -+ * to ensure they belong to the parent inode and were not deleted already. - */ --void --ext4_xattr_delete_inode(handle_t *handle, struct inode *inode) -+int -+ext4_xattr_delete_inode(handle_t *handle, struct inode *inode, -+ struct ext4_xattr_ino_array **lea_ino_array) - { - struct buffer_head *bh = NULL; -+ struct ext4_xattr_ibody_header *header; -+ struct ext4_inode *raw_inode; -+ struct ext4_iloc iloc; -+ struct ext4_xattr_entry *entry; -+ int credits = 3, error = 0; - -- if (!EXT4_I(inode)->i_file_acl) -+ if (!ext4_test_inode_state(inode, EXT4_STATE_XATTR)) -+ goto delete_external_ea; -+ -+ error = ext4_get_inode_loc(inode, &iloc); -+ if (error) - goto cleanup; -+ raw_inode = ext4_raw_inode(&iloc); -+ header = IHDR(inode, raw_inode); -+ for (entry = IFIRST(header); !IS_LAST_ENTRY(entry); -+ entry = EXT4_XATTR_NEXT(entry)) { -+ if (!entry->e_value_inum) -+ continue; -+ if (ext4_expand_ino_array(lea_ino_array, -+ entry->e_value_inum) != 0) { -+ brelse(iloc.bh); -+ goto cleanup; -+ } -+ entry->e_value_inum = 0; -+ } -+ brelse(iloc.bh); -+ -+delete_external_ea: -+ if (!EXT4_I(inode)->i_file_acl) { -+ /* add xattr inode to orphan list */ -+ ext4_xattr_inode_orphan_add(handle, inode, credits, -+ *lea_ino_array); -+ goto cleanup; -+ } - bh = sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl); - if (!bh) { - EXT4_ERROR_INODE(inode, "block %llu read error", -@@ -1504,11 +1954,69 @@ ext4_xattr_delete_inode(handle_t *handle - EXT4_I(inode)->i_file_acl); - goto cleanup; - } -+ -+ for (entry = BFIRST(bh); !IS_LAST_ENTRY(entry); -+ entry = EXT4_XATTR_NEXT(entry)) { -+ if (!entry->e_value_inum) -+ continue; -+ if (ext4_expand_ino_array(lea_ino_array, -+ entry->e_value_inum) != 0) -+ goto cleanup; -+ entry->e_value_inum = 0; -+ } -+ -+ /* add xattr inode to orphan list */ -+ error = ext4_xattr_inode_orphan_add(handle, inode, credits, -+ *lea_ino_array); -+ if (error != 0) -+ goto cleanup; -+ -+ if (!IS_NOQUOTA(inode)) -+ credits += 2 * EXT4_QUOTA_DEL_BLOCKS(inode->i_sb); -+ -+ if (!ext4_handle_has_enough_credits(handle, credits)) { -+ error = ext4_journal_extend(handle, credits); -+ if (error > 0) -+ error = ext4_journal_restart(handle, credits); -+ if (error != 0) { -+ ext4_warning(inode->i_sb, -+ "couldn't extend journal (err %d)", error); -+ goto cleanup; -+ } -+ } -+ - ext4_xattr_release_block(handle, inode, bh); - EXT4_I(inode)->i_file_acl = 0; - - cleanup: - brelse(bh); -+ -+ return error; -+} -+ -+void -+ext4_xattr_inode_array_free(struct inode *inode, -+ struct ext4_xattr_ino_array *lea_ino_array) -+{ -+ struct inode *ea_inode = NULL; -+ int idx = 0; -+ int err; -+ -+ if (lea_ino_array == NULL) -+ return; -+ -+ for (; idx < lea_ino_array->xia_count; ++idx) { -+ ea_inode = ext4_xattr_inode_iget(inode, -+ lea_ino_array->xia_inodes[idx], &err); -+ if (err) -+ continue; -+ /* for inode's i_count get from ext4_xattr_delete_inode */ -+ if (!list_empty(&EXT4_I(ea_inode)->i_orphan)) -+ iput(ea_inode); -+ clear_nlink(ea_inode); -+ iput(ea_inode); -+ } -+ kfree(lea_ino_array); - } - - /* -@@ -1578,10 +2086,9 @@ ext4_xattr_cmp(struct ext4_xattr_header - entry1->e_name_index != entry2->e_name_index || - entry1->e_name_len != entry2->e_name_len || - entry1->e_value_size != entry2->e_value_size || -+ entry1->e_value_inum != entry2->e_value_inum || - memcmp(entry1->e_name, entry2->e_name, entry1->e_name_len)) - return 1; -- if (entry1->e_value_block != 0 || entry2->e_value_block != 0) -- return -EIO; - if (memcmp((char *)header1 + le16_to_cpu(entry1->e_value_offs), - (char *)header2 + le16_to_cpu(entry2->e_value_offs), - le32_to_cpu(entry1->e_value_size))) -@@ -1665,7 +2172,7 @@ static inline void ext4_xattr_hash_entry - *name++; - } - -- if (entry->e_value_block == 0 && entry->e_value_size != 0) { -+ if (!entry->e_value_inum && entry->e_value_size) { - __le32 *value = (__le32 *)((char *)header + - le16_to_cpu(entry->e_value_offs)); - for (n = (le32_to_cpu(entry->e_value_size) + -Index: linux-stage/fs/ext4/xattr.h -=================================================================== ---- linux-stage.orig/fs/ext4/xattr.h -+++ linux-stage/fs/ext4/xattr.h -@@ -42,7 +42,7 @@ struct ext4_xattr_entry { - __u8 e_name_len; /* length of name */ - __u8 e_name_index; /* attribute name index */ - __le16 e_value_offs; /* offset in disk block of value */ -- __le32 e_value_block; /* disk block attribute is stored on (n/i) */ -+ __le32 e_value_inum; /* inode in which the value is stored */ - __le32 e_value_size; /* size of attribute value */ - __le32 e_hash; /* hash value of name and value */ - char e_name[0]; /* attribute name */ -@@ -67,6 +67,26 @@ struct ext4_xattr_entry { - EXT4_I(inode)->i_extra_isize)) - #define IFIRST(hdr) ((struct ext4_xattr_entry *)((hdr)+1)) - -+/* -+ * Link EA inode back to parent one using i_mtime field. -+ * Extra integer type conversion added to ignore higher -+ * bits in i_mtime.tv_sec which might be set by ext4_get() -+ */ -+#define EXT4_XATTR_INODE_SET_PARENT(inode, inum) \ -+do { \ -+ (inode)->i_mtime.tv_sec = inum; \ -+} while(0) -+ -+#define EXT4_XATTR_INODE_GET_PARENT(inode) \ -+ ((__u32)(inode)->i_mtime.tv_sec) -+ -+/* -+ * The minimum size of EA value when you start storing it in an external inode -+ * size of block - size of header - size of 1 entry - 4 null bytes -+*/ -+#define EXT4_XATTR_MIN_LARGE_EA_SIZE(b) \ -+ ((b) - EXT4_XATTR_LEN(3) - sizeof(struct ext4_xattr_header) - 4) -+ - #define BHDR(bh) ((struct ext4_xattr_header *)((bh)->b_data)) - #define ENTRY(ptr) ((struct ext4_xattr_entry *)(ptr)) - #define BFIRST(bh) ENTRY(BHDR(bh)+1) -@@ -75,10 +84,11 @@ struct ext4_xattr_entry { - #define EXT4_ZERO_XATTR_VALUE ((void *)-1) - - struct ext4_xattr_info { -- int name_index; - const char *name; - const void *value; - size_t value_len; -+ int name_index; -+ int in_inode; - }; - - struct ext4_xattr_search { -@@ -106,7 +116,13 @@ extern int ext4_xattr_get(struct inode * - extern int ext4_xattr_set(struct inode *, int, const char *, const void *, size_t, int); - extern int ext4_xattr_set_handle(handle_t *, struct inode *, int, const char *, const void *, size_t, int); - --extern void ext4_xattr_delete_inode(handle_t *, struct inode *); -+extern struct inode *ext4_xattr_inode_iget(struct inode *parent, unsigned long ea_ino, -+ int *err); -+extern int ext4_xattr_inode_unlink(struct inode *inode, unsigned long ea_ino); -+extern int ext4_xattr_delete_inode(handle_t *handle, struct inode *inode, -+ struct ext4_xattr_ino_array **array); -+extern void ext4_xattr_inode_array_free(struct inode *inode, -+ struct ext4_xattr_ino_array *array); - extern void ext4_xattr_put_super(struct super_block *); - - extern int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize, -Index: linux-stage/fs/ext4/ialloc.c -=================================================================== ---- linux-stage.orig/fs/ext4/ialloc.c -+++ linux-stage/fs/ext4/ialloc.c -@@ -269,7 +269,6 @@ void ext4_free_inode(handle_t *handle, s - * as writing the quota to disk may need the lock as well. - */ - dquot_initialize(inode); -- ext4_xattr_delete_inode(handle, inode); - dquot_free_inode(inode); - dquot_drop(inode); - -Index: linux-stage/fs/ext4/inline.c -=================================================================== ---- linux-stage.orig/fs/ext4/inline.c -+++ linux-stage/fs/ext4/inline.c -@@ -59,7 +59,7 @@ static int get_max_inline_xattr_value_si - - /* Compute min_offs. */ - for (; !IS_LAST_ENTRY(entry); entry = EXT4_XATTR_NEXT(entry)) { -- if (!entry->e_value_block && entry->e_value_size) { -+ if (!entry->e_value_inum && entry->e_value_size) { - size_t offs = le16_to_cpu(entry->e_value_offs); - if (offs < min_offs) - min_offs = offs; diff --git a/ldiskfs/kernel_patches/patches/rhel7.2/ext4-pdirop.patch b/ldiskfs/kernel_patches/patches/rhel7.2/ext4-pdirop.patch deleted file mode 100644 index 2064fd2..0000000 --- a/ldiskfs/kernel_patches/patches/rhel7.2/ext4-pdirop.patch +++ /dev/null @@ -1,1932 +0,0 @@ -Single directory performance is a critical for HPC workloads. In a -typical use case an application creates a separate output file for -each node and task in a job. As nodes and tasks increase, hundreds -of thousands of files may be created in a single directory within -a short window of time. -Today, both filename lookup and file system modifying operations -(such as create and unlink) are protected with a single lock for -an entire ldiskfs directory. PDO project will remove this -bottleneck by introducing a parallel locking mechanism for entire -ldiskfs directories. This work will enable multiple application -threads to simultaneously lookup, create and unlink in parallel. - -This patch contains: - - pdirops support for ldiskfs - - integrate with osd-ldiskfs - -Index: linux-3.10.0-229.1.2.fc21.x86_64/include/linux/htree_lock.h -=================================================================== ---- /dev/null -+++ linux-3.10.0-229.1.2.fc21.x86_64/include/linux/htree_lock.h -@@ -0,0 +1,187 @@ -+/* -+ * include/linux/htree_lock.h -+ * -+ * Copyright (c) 2011, 2012, Intel Corporation. -+ * -+ * Author: Liang Zhen -+ */ -+ -+/* -+ * htree lock -+ * -+ * htree_lock is an advanced lock, it can support five lock modes (concept is -+ * taken from DLM) and it's a sleeping lock. -+ * -+ * most common use case is: -+ * - create a htree_lock_head for data -+ * - each thread (contender) creates it's own htree_lock -+ * - contender needs to call htree_lock(lock_node, mode) to protect data and -+ * call htree_unlock to release lock -+ * -+ * Also, there is advanced use-case which is more complex, user can have -+ * PW/PR lock on particular key, it's mostly used while user holding shared -+ * lock on the htree (CW, CR) -+ * -+ * htree_lock(lock_node, HTREE_LOCK_CR); lock the htree with CR -+ * htree_node_lock(lock_node, HTREE_LOCK_PR, key...); lock @key with PR -+ * ... -+ * htree_node_unlock(lock_node);; unlock the key -+ * -+ * Another tip is, we can have N-levels of this kind of keys, all we need to -+ * do is specifying N-levels while creating htree_lock_head, then we can -+ * lock/unlock a specific level by: -+ * htree_node_lock(lock_node, mode1, key1, level1...); -+ * do something; -+ * htree_node_lock(lock_node, mode1, key2, level2...); -+ * do something; -+ * htree_node_unlock(lock_node, level2); -+ * htree_node_unlock(lock_node, level1); -+ * -+ * NB: for multi-level, should be careful about locking order to avoid deadlock -+ */ -+ -+#ifndef _LINUX_HTREE_LOCK_H -+#define _LINUX_HTREE_LOCK_H -+ -+#include -+#include -+#include -+ -+/* -+ * Lock Modes -+ * more details can be found here: -+ * http://en.wikipedia.org/wiki/Distributed_lock_manager -+ */ -+typedef enum { -+ HTREE_LOCK_EX = 0, /* exclusive lock: incompatible with all others */ -+ HTREE_LOCK_PW, /* protected write: allows only CR users */ -+ HTREE_LOCK_PR, /* protected read: allow PR, CR users */ -+ HTREE_LOCK_CW, /* concurrent write: allow CR, CW users */ -+ HTREE_LOCK_CR, /* concurrent read: allow all but EX users */ -+ HTREE_LOCK_MAX, /* number of lock modes */ -+} htree_lock_mode_t; -+ -+#define HTREE_LOCK_NL HTREE_LOCK_MAX -+#define HTREE_LOCK_INVAL 0xdead10c -+ -+enum { -+ HTREE_HBITS_MIN = 2, -+ HTREE_HBITS_DEF = 14, -+ HTREE_HBITS_MAX = 32, -+}; -+ -+enum { -+ HTREE_EVENT_DISABLE = (0), -+ HTREE_EVENT_RD = (1 << HTREE_LOCK_PR), -+ HTREE_EVENT_WR = (1 << HTREE_LOCK_PW), -+ HTREE_EVENT_RDWR = (HTREE_EVENT_RD | HTREE_EVENT_WR), -+}; -+ -+struct htree_lock; -+ -+typedef void (*htree_event_cb_t)(void *target, void *event); -+ -+struct htree_lock_child { -+ struct list_head lc_list; /* granted list */ -+ htree_event_cb_t lc_callback; /* event callback */ -+ unsigned lc_events; /* event types */ -+}; -+ -+struct htree_lock_head { -+ unsigned long lh_lock; /* bits lock */ -+ /* blocked lock list (htree_lock) */ -+ struct list_head lh_blocked_list; -+ /* # key levels */ -+ u16 lh_depth; -+ /* hash bits for key and limit number of locks */ -+ u16 lh_hbits; -+ /* counters for blocked locks */ -+ u16 lh_nblocked[HTREE_LOCK_MAX]; -+ /* counters for granted locks */ -+ u16 lh_ngranted[HTREE_LOCK_MAX]; -+ /* private data */ -+ void *lh_private; -+ /* array of children locks */ -+ struct htree_lock_child lh_children[0]; -+}; -+ -+/* htree_lock_node_t is child-lock for a specific key (ln_value) */ -+struct htree_lock_node { -+ htree_lock_mode_t ln_mode; -+ /* major hash key */ -+ u16 ln_major_key; -+ /* minor hash key */ -+ u16 ln_minor_key; -+ struct list_head ln_major_list; -+ struct list_head ln_minor_list; -+ /* alive list, all locks (granted, blocked, listening) are on it */ -+ struct list_head ln_alive_list; -+ /* blocked list */ -+ struct list_head ln_blocked_list; -+ /* granted list */ -+ struct list_head ln_granted_list; -+ void *ln_ev_target; -+}; -+ -+struct htree_lock { -+ struct task_struct *lk_task; -+ struct htree_lock_head *lk_head; -+ void *lk_private; -+ unsigned lk_depth; -+ htree_lock_mode_t lk_mode; -+ struct list_head lk_blocked_list; -+ struct htree_lock_node lk_nodes[0]; -+}; -+ -+/* create a lock head, which stands for a resource */ -+struct htree_lock_head *htree_lock_head_alloc(unsigned depth, -+ unsigned hbits, unsigned priv); -+/* free a lock head */ -+void htree_lock_head_free(struct htree_lock_head *lhead); -+/* register event callback for child lock at level @depth */ -+void htree_lock_event_attach(struct htree_lock_head *lhead, unsigned depth, -+ unsigned events, htree_event_cb_t callback); -+/* create a lock handle, which stands for a thread */ -+struct htree_lock *htree_lock_alloc(unsigned depth, unsigned pbytes); -+/* free a lock handle */ -+void htree_lock_free(struct htree_lock *lck); -+/* lock htree, when @wait is true, 0 is returned if the lock can't -+ * be granted immediately */ -+int htree_lock_try(struct htree_lock *lck, struct htree_lock_head *lhead, -+ htree_lock_mode_t mode, int wait); -+/* unlock htree */ -+void htree_unlock(struct htree_lock *lck); -+/* unlock and relock htree with @new_mode */ -+int htree_change_lock_try(struct htree_lock *lck, -+ htree_lock_mode_t new_mode, int wait); -+void htree_change_mode(struct htree_lock *lck, htree_lock_mode_t mode); -+/* require child lock (key) of htree at level @dep, @event will be sent to all -+ * listeners on this @key while lock being granted */ -+int htree_node_lock_try(struct htree_lock *lck, htree_lock_mode_t mode, -+ u32 key, unsigned dep, int wait, void *event); -+/* release child lock at level @dep, this lock will listen on it's key -+ * if @event isn't NULL, event_cb will be called against @lck while granting -+ * any other lock at level @dep with the same key */ -+void htree_node_unlock(struct htree_lock *lck, unsigned dep, void *event); -+/* stop listening on child lock at level @dep */ -+void htree_node_stop_listen(struct htree_lock *lck, unsigned dep); -+/* for debug */ -+void htree_lock_stat_print(int depth); -+void htree_lock_stat_reset(void); -+ -+#define htree_lock(lck, lh, mode) htree_lock_try(lck, lh, mode, 1) -+#define htree_change_lock(lck, mode) htree_change_lock_try(lck, mode, 1) -+ -+#define htree_lock_mode(lck) ((lck)->lk_mode) -+ -+#define htree_node_lock(lck, mode, key, dep) \ -+ htree_node_lock_try(lck, mode, key, dep, 1, NULL) -+/* this is only safe in thread context of lock owner */ -+#define htree_node_is_granted(lck, dep) \ -+ ((lck)->lk_nodes[dep].ln_mode != HTREE_LOCK_INVAL && \ -+ (lck)->lk_nodes[dep].ln_mode != HTREE_LOCK_NL) -+/* this is only safe in thread context of lock owner */ -+#define htree_node_is_listening(lck, dep) \ -+ ((lck)->lk_nodes[dep].ln_mode == HTREE_LOCK_NL) -+ -+#endif -Index: linux-3.10.0-229.1.2.fc21.x86_64/fs/ext4/htree_lock.c -=================================================================== ---- /dev/null -+++ linux-3.10.0-229.1.2.fc21.x86_64/fs/ext4/htree_lock.c -@@ -0,0 +1,880 @@ -+/* -+ * fs/ext4/htree_lock.c -+ * -+ * Copyright (c) 2011, 2012, Intel Corporation. -+ * -+ * Author: Liang Zhen -+ */ -+#include -+#include -+#include -+#include -+ -+enum { -+ HTREE_LOCK_BIT_EX = (1 << HTREE_LOCK_EX), -+ HTREE_LOCK_BIT_PW = (1 << HTREE_LOCK_PW), -+ HTREE_LOCK_BIT_PR = (1 << HTREE_LOCK_PR), -+ HTREE_LOCK_BIT_CW = (1 << HTREE_LOCK_CW), -+ HTREE_LOCK_BIT_CR = (1 << HTREE_LOCK_CR), -+}; -+ -+enum { -+ HTREE_LOCK_COMPAT_EX = 0, -+ HTREE_LOCK_COMPAT_PW = HTREE_LOCK_COMPAT_EX | HTREE_LOCK_BIT_CR, -+ HTREE_LOCK_COMPAT_PR = HTREE_LOCK_COMPAT_PW | HTREE_LOCK_BIT_PR, -+ HTREE_LOCK_COMPAT_CW = HTREE_LOCK_COMPAT_PW | HTREE_LOCK_BIT_CW, -+ HTREE_LOCK_COMPAT_CR = HTREE_LOCK_COMPAT_CW | HTREE_LOCK_BIT_PR | -+ HTREE_LOCK_BIT_PW, -+}; -+ -+static int htree_lock_compat[] = { -+ [HTREE_LOCK_EX] HTREE_LOCK_COMPAT_EX, -+ [HTREE_LOCK_PW] HTREE_LOCK_COMPAT_PW, -+ [HTREE_LOCK_PR] HTREE_LOCK_COMPAT_PR, -+ [HTREE_LOCK_CW] HTREE_LOCK_COMPAT_CW, -+ [HTREE_LOCK_CR] HTREE_LOCK_COMPAT_CR, -+}; -+ -+/* max allowed htree-lock depth. -+ * We only need depth=3 for ext4 although user can have higher value. */ -+#define HTREE_LOCK_DEP_MAX 16 -+ -+#ifdef HTREE_LOCK_DEBUG -+ -+static char *hl_name[] = { -+ [HTREE_LOCK_EX] "EX", -+ [HTREE_LOCK_PW] "PW", -+ [HTREE_LOCK_PR] "PR", -+ [HTREE_LOCK_CW] "CW", -+ [HTREE_LOCK_CR] "CR", -+}; -+ -+/* lock stats */ -+struct htree_lock_node_stats { -+ unsigned long long blocked[HTREE_LOCK_MAX]; -+ unsigned long long granted[HTREE_LOCK_MAX]; -+ unsigned long long retried[HTREE_LOCK_MAX]; -+ unsigned long long events; -+}; -+ -+struct htree_lock_stats { -+ struct htree_lock_node_stats nodes[HTREE_LOCK_DEP_MAX]; -+ unsigned long long granted[HTREE_LOCK_MAX]; -+ unsigned long long blocked[HTREE_LOCK_MAX]; -+}; -+ -+static struct htree_lock_stats hl_stats; -+ -+void htree_lock_stat_reset(void) -+{ -+ memset(&hl_stats, 0, sizeof(hl_stats)); -+} -+ -+void htree_lock_stat_print(int depth) -+{ -+ int i; -+ int j; -+ -+ printk(KERN_DEBUG "HTREE LOCK STATS:\n"); -+ for (i = 0; i < HTREE_LOCK_MAX; i++) { -+ printk(KERN_DEBUG "[%s]: G [%10llu], B [%10llu]\n", -+ hl_name[i], hl_stats.granted[i], hl_stats.blocked[i]); -+ } -+ for (i = 0; i < depth; i++) { -+ printk(KERN_DEBUG "HTREE CHILD [%d] STATS:\n", i); -+ for (j = 0; j < HTREE_LOCK_MAX; j++) { -+ printk(KERN_DEBUG -+ "[%s]: G [%10llu], B [%10llu], R [%10llu]\n", -+ hl_name[j], hl_stats.nodes[i].granted[j], -+ hl_stats.nodes[i].blocked[j], -+ hl_stats.nodes[i].retried[j]); -+ } -+ } -+} -+ -+#define lk_grant_inc(m) do { hl_stats.granted[m]++; } while (0) -+#define lk_block_inc(m) do { hl_stats.blocked[m]++; } while (0) -+#define ln_grant_inc(d, m) do { hl_stats.nodes[d].granted[m]++; } while (0) -+#define ln_block_inc(d, m) do { hl_stats.nodes[d].blocked[m]++; } while (0) -+#define ln_retry_inc(d, m) do { hl_stats.nodes[d].retried[m]++; } while (0) -+#define ln_event_inc(d) do { hl_stats.nodes[d].events++; } while (0) -+ -+#else /* !DEBUG */ -+ -+void htree_lock_stat_reset(void) {} -+void htree_lock_stat_print(int depth) {} -+ -+#define lk_grant_inc(m) do {} while (0) -+#define lk_block_inc(m) do {} while (0) -+#define ln_grant_inc(d, m) do {} while (0) -+#define ln_block_inc(d, m) do {} while (0) -+#define ln_retry_inc(d, m) do {} while (0) -+#define ln_event_inc(d) do {} while (0) -+ -+#endif /* DEBUG */ -+ -+EXPORT_SYMBOL(htree_lock_stat_reset); -+EXPORT_SYMBOL(htree_lock_stat_print); -+ -+#define HTREE_DEP_ROOT (-1) -+ -+#define htree_spin_lock(lhead, dep) \ -+ bit_spin_lock((dep) + 1, &(lhead)->lh_lock) -+#define htree_spin_unlock(lhead, dep) \ -+ bit_spin_unlock((dep) + 1, &(lhead)->lh_lock) -+ -+#define htree_key_event_ignore(child, ln) \ -+ (!((child)->lc_events & (1 << (ln)->ln_mode))) -+ -+static int -+htree_key_list_empty(struct htree_lock_node *ln) -+{ -+ return list_empty(&ln->ln_major_list) && list_empty(&ln->ln_minor_list); -+} -+ -+static void -+htree_key_list_del_init(struct htree_lock_node *ln) -+{ -+ struct htree_lock_node *tmp = NULL; -+ -+ if (!list_empty(&ln->ln_minor_list)) { -+ tmp = list_entry(ln->ln_minor_list.next, -+ struct htree_lock_node, ln_minor_list); -+ list_del_init(&ln->ln_minor_list); -+ } -+ -+ if (list_empty(&ln->ln_major_list)) -+ return; -+ -+ if (tmp == NULL) { /* not on minor key list */ -+ list_del_init(&ln->ln_major_list); -+ } else { -+ BUG_ON(!list_empty(&tmp->ln_major_list)); -+ list_replace_init(&ln->ln_major_list, &tmp->ln_major_list); -+ } -+} -+ -+static void -+htree_key_list_replace_init(struct htree_lock_node *old, -+ struct htree_lock_node *new) -+{ -+ if (!list_empty(&old->ln_major_list)) -+ list_replace_init(&old->ln_major_list, &new->ln_major_list); -+ -+ if (!list_empty(&old->ln_minor_list)) -+ list_replace_init(&old->ln_minor_list, &new->ln_minor_list); -+} -+ -+static void -+htree_key_event_enqueue(struct htree_lock_child *child, -+ struct htree_lock_node *ln, int dep, void *event) -+{ -+ struct htree_lock_node *tmp; -+ -+ /* NB: ALWAYS called holding lhead::lh_lock(dep) */ -+ BUG_ON(ln->ln_mode == HTREE_LOCK_NL); -+ if (event == NULL || htree_key_event_ignore(child, ln)) -+ return; -+ -+ /* shouldn't be a very long list */ -+ list_for_each_entry(tmp, &ln->ln_alive_list, ln_alive_list) { -+ if (tmp->ln_mode == HTREE_LOCK_NL) { -+ ln_event_inc(dep); -+ if (child->lc_callback != NULL) -+ child->lc_callback(tmp->ln_ev_target, event); -+ } -+ } -+} -+ -+static int -+htree_node_lock_enqueue(struct htree_lock *newlk, struct htree_lock *curlk, -+ unsigned dep, int wait, void *event) -+{ -+ struct htree_lock_child *child = &newlk->lk_head->lh_children[dep]; -+ struct htree_lock_node *newln = &newlk->lk_nodes[dep]; -+ struct htree_lock_node *curln = &curlk->lk_nodes[dep]; -+ -+ /* NB: ALWAYS called holding lhead::lh_lock(dep) */ -+ /* NB: we only expect PR/PW lock mode at here, only these two modes are -+ * allowed for htree_node_lock(asserted in htree_node_lock_internal), -+ * NL is only used for listener, user can't directly require NL mode */ -+ if ((curln->ln_mode == HTREE_LOCK_NL) || -+ (curln->ln_mode != HTREE_LOCK_PW && -+ newln->ln_mode != HTREE_LOCK_PW)) { -+ /* no conflict, attach it on granted list of @curlk */ -+ if (curln->ln_mode != HTREE_LOCK_NL) { -+ list_add(&newln->ln_granted_list, -+ &curln->ln_granted_list); -+ } else { -+ /* replace key owner */ -+ htree_key_list_replace_init(curln, newln); -+ } -+ -+ list_add(&newln->ln_alive_list, &curln->ln_alive_list); -+ htree_key_event_enqueue(child, newln, dep, event); -+ ln_grant_inc(dep, newln->ln_mode); -+ return 1; /* still hold lh_lock */ -+ } -+ -+ if (!wait) { /* can't grant and don't want to wait */ -+ ln_retry_inc(dep, newln->ln_mode); -+ newln->ln_mode = HTREE_LOCK_INVAL; -+ return -1; /* don't wait and just return -1 */ -+ } -+ -+ newlk->lk_task = current; -+ set_current_state(TASK_UNINTERRUPTIBLE); -+ /* conflict, attach it on blocked list of curlk */ -+ list_add_tail(&newln->ln_blocked_list, &curln->ln_blocked_list); -+ list_add(&newln->ln_alive_list, &curln->ln_alive_list); -+ ln_block_inc(dep, newln->ln_mode); -+ -+ htree_spin_unlock(newlk->lk_head, dep); -+ /* wait to be given the lock */ -+ if (newlk->lk_task != NULL) -+ schedule(); -+ /* granted, no doubt, wake up will set me RUNNING */ -+ if (event == NULL || htree_key_event_ignore(child, newln)) -+ return 0; /* granted without lh_lock */ -+ -+ htree_spin_lock(newlk->lk_head, dep); -+ htree_key_event_enqueue(child, newln, dep, event); -+ return 1; /* still hold lh_lock */ -+} -+ -+/* -+ * get PR/PW access to particular tree-node according to @dep and @key, -+ * it will return -1 if @wait is false and can't immediately grant this lock. -+ * All listeners(HTREE_LOCK_NL) on @dep and with the same @key will get -+ * @event if it's not NULL. -+ * NB: ALWAYS called holding lhead::lh_lock -+ */ -+static int -+htree_node_lock_internal(struct htree_lock_head *lhead, struct htree_lock *lck, -+ htree_lock_mode_t mode, u32 key, unsigned dep, -+ int wait, void *event) -+{ -+ LIST_HEAD(list); -+ struct htree_lock *tmp; -+ struct htree_lock *tmp2; -+ u16 major; -+ u16 minor; -+ u8 reverse; -+ u8 ma_bits; -+ u8 mi_bits; -+ -+ BUG_ON(mode != HTREE_LOCK_PW && mode != HTREE_LOCK_PR); -+ BUG_ON(htree_node_is_granted(lck, dep)); -+ -+ key = hash_long(key, lhead->lh_hbits); -+ -+ mi_bits = lhead->lh_hbits >> 1; -+ ma_bits = lhead->lh_hbits - mi_bits; -+ -+ lck->lk_nodes[dep].ln_major_key = major = key & ((1U << ma_bits) - 1); -+ lck->lk_nodes[dep].ln_minor_key = minor = key >> ma_bits; -+ lck->lk_nodes[dep].ln_mode = mode; -+ -+ /* -+ * The major key list is an ordered list, so searches are started -+ * at the end of the list that is numerically closer to major_key, -+ * so at most half of the list will be walked (for well-distributed -+ * keys). The list traversal aborts early if the expected key -+ * location is passed. -+ */ -+ reverse = (major >= (1 << (ma_bits - 1))); -+ -+ if (reverse) { -+ list_for_each_entry_reverse(tmp, -+ &lhead->lh_children[dep].lc_list, -+ lk_nodes[dep].ln_major_list) { -+ if (tmp->lk_nodes[dep].ln_major_key == major) { -+ goto search_minor; -+ -+ } else if (tmp->lk_nodes[dep].ln_major_key < major) { -+ /* attach _after_ @tmp */ -+ list_add(&lck->lk_nodes[dep].ln_major_list, -+ &tmp->lk_nodes[dep].ln_major_list); -+ goto out_grant_major; -+ } -+ } -+ -+ list_add(&lck->lk_nodes[dep].ln_major_list, -+ &lhead->lh_children[dep].lc_list); -+ goto out_grant_major; -+ -+ } else { -+ list_for_each_entry(tmp, &lhead->lh_children[dep].lc_list, -+ lk_nodes[dep].ln_major_list) { -+ if (tmp->lk_nodes[dep].ln_major_key == major) { -+ goto search_minor; -+ -+ } else if (tmp->lk_nodes[dep].ln_major_key > major) { -+ /* insert _before_ @tmp */ -+ list_add_tail(&lck->lk_nodes[dep].ln_major_list, -+ &tmp->lk_nodes[dep].ln_major_list); -+ goto out_grant_major; -+ } -+ } -+ -+ list_add_tail(&lck->lk_nodes[dep].ln_major_list, -+ &lhead->lh_children[dep].lc_list); -+ goto out_grant_major; -+ } -+ -+ search_minor: -+ /* -+ * NB: minor_key list doesn't have a "head", @list is just a -+ * temporary stub for helping list searching, make sure it's removed -+ * after searching. -+ * minor_key list is an ordered list too. -+ */ -+ list_add_tail(&list, &tmp->lk_nodes[dep].ln_minor_list); -+ -+ reverse = (minor >= (1 << (mi_bits - 1))); -+ -+ if (reverse) { -+ list_for_each_entry_reverse(tmp2, &list, -+ lk_nodes[dep].ln_minor_list) { -+ if (tmp2->lk_nodes[dep].ln_minor_key == minor) { -+ goto out_enqueue; -+ -+ } else if (tmp2->lk_nodes[dep].ln_minor_key < minor) { -+ /* attach _after_ @tmp2 */ -+ list_add(&lck->lk_nodes[dep].ln_minor_list, -+ &tmp2->lk_nodes[dep].ln_minor_list); -+ goto out_grant_minor; -+ } -+ } -+ -+ list_add(&lck->lk_nodes[dep].ln_minor_list, &list); -+ -+ } else { -+ list_for_each_entry(tmp2, &list, -+ lk_nodes[dep].ln_minor_list) { -+ if (tmp2->lk_nodes[dep].ln_minor_key == minor) { -+ goto out_enqueue; -+ -+ } else if (tmp2->lk_nodes[dep].ln_minor_key > minor) { -+ /* insert _before_ @tmp2 */ -+ list_add_tail(&lck->lk_nodes[dep].ln_minor_list, -+ &tmp2->lk_nodes[dep].ln_minor_list); -+ goto out_grant_minor; -+ } -+ } -+ -+ list_add_tail(&lck->lk_nodes[dep].ln_minor_list, &list); -+ } -+ -+ out_grant_minor: -+ if (list.next == &lck->lk_nodes[dep].ln_minor_list) { -+ /* new lock @lck is the first one on minor_key list, which -+ * means it has the smallest minor_key and it should -+ * replace @tmp as minor_key owner */ -+ list_replace_init(&tmp->lk_nodes[dep].ln_major_list, -+ &lck->lk_nodes[dep].ln_major_list); -+ } -+ /* remove the temporary head */ -+ list_del(&list); -+ -+ out_grant_major: -+ ln_grant_inc(dep, lck->lk_nodes[dep].ln_mode); -+ return 1; /* granted with holding lh_lock */ -+ -+ out_enqueue: -+ list_del(&list); /* remove temprary head */ -+ return htree_node_lock_enqueue(lck, tmp2, dep, wait, event); -+} -+ -+/* -+ * release the key of @lck at level @dep, and grant any blocked locks. -+ * caller will still listen on @key if @event is not NULL, which means -+ * caller can see a event (by event_cb) while granting any lock with -+ * the same key at level @dep. -+ * NB: ALWAYS called holding lhead::lh_lock -+ * NB: listener will not block anyone because listening mode is HTREE_LOCK_NL -+ */ -+static void -+htree_node_unlock_internal(struct htree_lock_head *lhead, -+ struct htree_lock *curlk, unsigned dep, void *event) -+{ -+ struct htree_lock_node *curln = &curlk->lk_nodes[dep]; -+ struct htree_lock *grtlk = NULL; -+ struct htree_lock_node *grtln; -+ struct htree_lock *poslk; -+ struct htree_lock *tmplk; -+ -+ if (!htree_node_is_granted(curlk, dep)) -+ return; -+ -+ if (!list_empty(&curln->ln_granted_list)) { -+ /* there is another granted lock */ -+ grtlk = list_entry(curln->ln_granted_list.next, -+ struct htree_lock, -+ lk_nodes[dep].ln_granted_list); -+ list_del_init(&curln->ln_granted_list); -+ } -+ -+ if (grtlk == NULL && !list_empty(&curln->ln_blocked_list)) { -+ /* -+ * @curlk is the only granted lock, so we confirmed: -+ * a) curln is key owner (attached on major/minor_list), -+ * so if there is any blocked lock, it should be attached -+ * on curln->ln_blocked_list -+ * b) we always can grant the first blocked lock -+ */ -+ grtlk = list_entry(curln->ln_blocked_list.next, -+ struct htree_lock, -+ lk_nodes[dep].ln_blocked_list); -+ BUG_ON(grtlk->lk_task == NULL); -+ wake_up_process(grtlk->lk_task); -+ } -+ -+ if (event != NULL && -+ lhead->lh_children[dep].lc_events != HTREE_EVENT_DISABLE) { -+ curln->ln_ev_target = event; -+ curln->ln_mode = HTREE_LOCK_NL; /* listen! */ -+ } else { -+ curln->ln_mode = HTREE_LOCK_INVAL; -+ } -+ -+ if (grtlk == NULL) { /* I must be the only one locking this key */ -+ struct htree_lock_node *tmpln; -+ -+ BUG_ON(htree_key_list_empty(curln)); -+ -+ if (curln->ln_mode == HTREE_LOCK_NL) /* listening */ -+ return; -+ -+ /* not listening */ -+ if (list_empty(&curln->ln_alive_list)) { /* no more listener */ -+ htree_key_list_del_init(curln); -+ return; -+ } -+ -+ tmpln = list_entry(curln->ln_alive_list.next, -+ struct htree_lock_node, ln_alive_list); -+ -+ BUG_ON(tmpln->ln_mode != HTREE_LOCK_NL); -+ -+ htree_key_list_replace_init(curln, tmpln); -+ list_del_init(&curln->ln_alive_list); -+ -+ return; -+ } -+ -+ /* have a granted lock */ -+ grtln = &grtlk->lk_nodes[dep]; -+ if (!list_empty(&curln->ln_blocked_list)) { -+ /* only key owner can be on both lists */ -+ BUG_ON(htree_key_list_empty(curln)); -+ -+ if (list_empty(&grtln->ln_blocked_list)) { -+ list_add(&grtln->ln_blocked_list, -+ &curln->ln_blocked_list); -+ } -+ list_del_init(&curln->ln_blocked_list); -+ } -+ /* -+ * NB: this is the tricky part: -+ * We have only two modes for child-lock (PR and PW), also, -+ * only owner of the key (attached on major/minor_list) can be on -+ * both blocked_list and granted_list, so @grtlk must be one -+ * of these two cases: -+ * -+ * a) @grtlk is taken from granted_list, which means we've granted -+ * more than one lock so @grtlk has to be PR, the first blocked -+ * lock must be PW and we can't grant it at all. -+ * So even @grtlk is not owner of the key (empty blocked_list), -+ * we don't care because we can't grant any lock. -+ * b) we just grant a new lock which is taken from head of blocked -+ * list, and it should be the first granted lock, and it should -+ * be the first one linked on blocked_list. -+ * -+ * Either way, we can get correct result by iterating blocked_list -+ * of @grtlk, and don't have to bother on how to find out -+ * owner of current key. -+ */ -+ list_for_each_entry_safe(poslk, tmplk, &grtln->ln_blocked_list, -+ lk_nodes[dep].ln_blocked_list) { -+ if (grtlk->lk_nodes[dep].ln_mode == HTREE_LOCK_PW || -+ poslk->lk_nodes[dep].ln_mode == HTREE_LOCK_PW) -+ break; -+ /* grant all readers */ -+ list_del_init(&poslk->lk_nodes[dep].ln_blocked_list); -+ list_add(&poslk->lk_nodes[dep].ln_granted_list, -+ &grtln->ln_granted_list); -+ -+ BUG_ON(poslk->lk_task == NULL); -+ wake_up_process(poslk->lk_task); -+ } -+ -+ /* if @curln is the owner of this key, replace it with @grtln */ -+ if (!htree_key_list_empty(curln)) -+ htree_key_list_replace_init(curln, grtln); -+ -+ if (curln->ln_mode == HTREE_LOCK_INVAL) -+ list_del_init(&curln->ln_alive_list); -+} -+ -+/* -+ * it's just wrapper of htree_node_lock_internal, it returns 1 on granted -+ * and 0 only if @wait is false and can't grant it immediately -+ */ -+int -+htree_node_lock_try(struct htree_lock *lck, htree_lock_mode_t mode, -+ u32 key, unsigned dep, int wait, void *event) -+{ -+ struct htree_lock_head *lhead = lck->lk_head; -+ int rc; -+ -+ BUG_ON(dep >= lck->lk_depth); -+ BUG_ON(lck->lk_mode == HTREE_LOCK_INVAL); -+ -+ htree_spin_lock(lhead, dep); -+ rc = htree_node_lock_internal(lhead, lck, mode, key, dep, wait, event); -+ if (rc != 0) -+ htree_spin_unlock(lhead, dep); -+ return rc >= 0; -+} -+EXPORT_SYMBOL(htree_node_lock_try); -+ -+/* it's wrapper of htree_node_unlock_internal */ -+void -+htree_node_unlock(struct htree_lock *lck, unsigned dep, void *event) -+{ -+ struct htree_lock_head *lhead = lck->lk_head; -+ -+ BUG_ON(dep >= lck->lk_depth); -+ BUG_ON(lck->lk_mode == HTREE_LOCK_INVAL); -+ -+ htree_spin_lock(lhead, dep); -+ htree_node_unlock_internal(lhead, lck, dep, event); -+ htree_spin_unlock(lhead, dep); -+} -+EXPORT_SYMBOL(htree_node_unlock); -+ -+/* stop listening on child-lock level @dep */ -+void -+htree_node_stop_listen(struct htree_lock *lck, unsigned dep) -+{ -+ struct htree_lock_node *ln = &lck->lk_nodes[dep]; -+ struct htree_lock_node *tmp; -+ -+ BUG_ON(htree_node_is_granted(lck, dep)); -+ BUG_ON(!list_empty(&ln->ln_blocked_list)); -+ BUG_ON(!list_empty(&ln->ln_granted_list)); -+ -+ if (!htree_node_is_listening(lck, dep)) -+ return; -+ -+ htree_spin_lock(lck->lk_head, dep); -+ ln->ln_mode = HTREE_LOCK_INVAL; -+ ln->ln_ev_target = NULL; -+ -+ if (htree_key_list_empty(ln)) { /* not owner */ -+ list_del_init(&ln->ln_alive_list); -+ goto out; -+ } -+ -+ /* I'm the owner... */ -+ if (list_empty(&ln->ln_alive_list)) { /* no more listener */ -+ htree_key_list_del_init(ln); -+ goto out; -+ } -+ -+ tmp = list_entry(ln->ln_alive_list.next, -+ struct htree_lock_node, ln_alive_list); -+ -+ BUG_ON(tmp->ln_mode != HTREE_LOCK_NL); -+ htree_key_list_replace_init(ln, tmp); -+ list_del_init(&ln->ln_alive_list); -+ out: -+ htree_spin_unlock(lck->lk_head, dep); -+} -+EXPORT_SYMBOL(htree_node_stop_listen); -+ -+/* release all child-locks if we have any */ -+static void -+htree_node_release_all(struct htree_lock *lck) -+{ -+ int i; -+ -+ for (i = 0; i < lck->lk_depth; i++) { -+ if (htree_node_is_granted(lck, i)) -+ htree_node_unlock(lck, i, NULL); -+ else if (htree_node_is_listening(lck, i)) -+ htree_node_stop_listen(lck, i); -+ } -+} -+ -+/* -+ * obtain htree lock, it could be blocked inside if there's conflict -+ * with any granted or blocked lock and @wait is true. -+ * NB: ALWAYS called holding lhead::lh_lock -+ */ -+static int -+htree_lock_internal(struct htree_lock *lck, int wait) -+{ -+ struct htree_lock_head *lhead = lck->lk_head; -+ int granted = 0; -+ int blocked = 0; -+ int i; -+ -+ for (i = 0; i < HTREE_LOCK_MAX; i++) { -+ if (lhead->lh_ngranted[i] != 0) -+ granted |= 1 << i; -+ if (lhead->lh_nblocked[i] != 0) -+ blocked |= 1 << i; -+ } -+ if ((htree_lock_compat[lck->lk_mode] & granted) != granted || -+ (htree_lock_compat[lck->lk_mode] & blocked) != blocked) { -+ /* will block current lock even it just conflicts with any -+ * other blocked lock, so lock like EX wouldn't starve */ -+ if (!wait) -+ return -1; -+ lhead->lh_nblocked[lck->lk_mode]++; -+ lk_block_inc(lck->lk_mode); -+ -+ lck->lk_task = current; -+ list_add_tail(&lck->lk_blocked_list, &lhead->lh_blocked_list); -+ -+ set_current_state(TASK_UNINTERRUPTIBLE); -+ htree_spin_unlock(lhead, HTREE_DEP_ROOT); -+ /* wait to be given the lock */ -+ if (lck->lk_task != NULL) -+ schedule(); -+ /* granted, no doubt. wake up will set me RUNNING */ -+ return 0; /* without lh_lock */ -+ } -+ lhead->lh_ngranted[lck->lk_mode]++; -+ lk_grant_inc(lck->lk_mode); -+ return 1; -+} -+ -+/* release htree lock. NB: ALWAYS called holding lhead::lh_lock */ -+static void -+htree_unlock_internal(struct htree_lock *lck) -+{ -+ struct htree_lock_head *lhead = lck->lk_head; -+ struct htree_lock *tmp; -+ struct htree_lock *tmp2; -+ int granted = 0; -+ int i; -+ -+ BUG_ON(lhead->lh_ngranted[lck->lk_mode] == 0); -+ -+ lhead->lh_ngranted[lck->lk_mode]--; -+ lck->lk_mode = HTREE_LOCK_INVAL; -+ -+ for (i = 0; i < HTREE_LOCK_MAX; i++) { -+ if (lhead->lh_ngranted[i] != 0) -+ granted |= 1 << i; -+ } -+ list_for_each_entry_safe(tmp, tmp2, -+ &lhead->lh_blocked_list, lk_blocked_list) { -+ /* conflict with any granted lock? */ -+ if ((htree_lock_compat[tmp->lk_mode] & granted) != granted) -+ break; -+ -+ list_del_init(&tmp->lk_blocked_list); -+ -+ BUG_ON(lhead->lh_nblocked[tmp->lk_mode] == 0); -+ -+ lhead->lh_nblocked[tmp->lk_mode]--; -+ lhead->lh_ngranted[tmp->lk_mode]++; -+ granted |= 1 << tmp->lk_mode; -+ -+ BUG_ON(tmp->lk_task == NULL); -+ wake_up_process(tmp->lk_task); -+ } -+} -+ -+/* it's wrapper of htree_lock_internal and exported interface. -+ * It always return 1 with granted lock if @wait is true, it can return 0 -+ * if @wait is false and locking request can't be granted immediately */ -+int -+htree_lock_try(struct htree_lock *lck, struct htree_lock_head *lhead, -+ htree_lock_mode_t mode, int wait) -+{ -+ int rc; -+ -+ BUG_ON(lck->lk_depth > lhead->lh_depth); -+ BUG_ON(lck->lk_head != NULL); -+ BUG_ON(lck->lk_task != NULL); -+ -+ lck->lk_head = lhead; -+ lck->lk_mode = mode; -+ -+ htree_spin_lock(lhead, HTREE_DEP_ROOT); -+ rc = htree_lock_internal(lck, wait); -+ if (rc != 0) -+ htree_spin_unlock(lhead, HTREE_DEP_ROOT); -+ return rc >= 0; -+} -+EXPORT_SYMBOL(htree_lock_try); -+ -+/* it's wrapper of htree_unlock_internal and exported interface. -+ * It will release all htree_node_locks and htree_lock */ -+void -+htree_unlock(struct htree_lock *lck) -+{ -+ BUG_ON(lck->lk_head == NULL); -+ BUG_ON(lck->lk_mode == HTREE_LOCK_INVAL); -+ -+ htree_node_release_all(lck); -+ -+ htree_spin_lock(lck->lk_head, HTREE_DEP_ROOT); -+ htree_unlock_internal(lck); -+ htree_spin_unlock(lck->lk_head, HTREE_DEP_ROOT); -+ lck->lk_head = NULL; -+ lck->lk_task = NULL; -+} -+EXPORT_SYMBOL(htree_unlock); -+ -+/* change lock mode */ -+void -+htree_change_mode(struct htree_lock *lck, htree_lock_mode_t mode) -+{ -+ BUG_ON(lck->lk_mode == HTREE_LOCK_INVAL); -+ lck->lk_mode = mode; -+} -+EXPORT_SYMBOL(htree_change_mode); -+ -+/* release htree lock, and lock it again with new mode. -+ * This function will first release all htree_node_locks and htree_lock, -+ * then try to gain htree_lock with new @mode. -+ * It always return 1 with granted lock if @wait is true, it can return 0 -+ * if @wait is false and locking request can't be granted immediately */ -+int -+htree_change_lock_try(struct htree_lock *lck, htree_lock_mode_t mode, int wait) -+{ -+ struct htree_lock_head *lhead = lck->lk_head; -+ int rc; -+ -+ BUG_ON(lhead == NULL); -+ BUG_ON(lck->lk_mode == mode); -+ BUG_ON(lck->lk_mode == HTREE_LOCK_INVAL || mode == HTREE_LOCK_INVAL); -+ -+ htree_node_release_all(lck); -+ -+ htree_spin_lock(lhead, HTREE_DEP_ROOT); -+ htree_unlock_internal(lck); -+ lck->lk_mode = mode; -+ rc = htree_lock_internal(lck, wait); -+ if (rc != 0) -+ htree_spin_unlock(lhead, HTREE_DEP_ROOT); -+ return rc >= 0; -+} -+EXPORT_SYMBOL(htree_change_lock_try); -+ -+/* create a htree_lock head with @depth levels (number of child-locks), -+ * it is a per resoruce structure */ -+struct htree_lock_head * -+htree_lock_head_alloc(unsigned depth, unsigned hbits, unsigned priv) -+{ -+ struct htree_lock_head *lhead; -+ int i; -+ -+ if (depth > HTREE_LOCK_DEP_MAX) { -+ printk(KERN_ERR "%d is larger than max htree_lock depth %d\n", -+ depth, HTREE_LOCK_DEP_MAX); -+ return NULL; -+ } -+ -+ lhead = kzalloc(offsetof(struct htree_lock_head, -+ lh_children[depth]) + priv, GFP_NOFS); -+ if (lhead == NULL) -+ return NULL; -+ -+ if (hbits < HTREE_HBITS_MIN) -+ lhead->lh_hbits = HTREE_HBITS_MIN; -+ else if (hbits > HTREE_HBITS_MAX) -+ lhead->lh_hbits = HTREE_HBITS_MAX; -+ -+ lhead->lh_lock = 0; -+ lhead->lh_depth = depth; -+ INIT_LIST_HEAD(&lhead->lh_blocked_list); -+ if (priv > 0) { -+ lhead->lh_private = (void *)lhead + -+ offsetof(struct htree_lock_head, lh_children[depth]); -+ } -+ -+ for (i = 0; i < depth; i++) { -+ INIT_LIST_HEAD(&lhead->lh_children[i].lc_list); -+ lhead->lh_children[i].lc_events = HTREE_EVENT_DISABLE; -+ } -+ return lhead; -+} -+EXPORT_SYMBOL(htree_lock_head_alloc); -+ -+/* free the htree_lock head */ -+void -+htree_lock_head_free(struct htree_lock_head *lhead) -+{ -+ int i; -+ -+ BUG_ON(!list_empty(&lhead->lh_blocked_list)); -+ for (i = 0; i < lhead->lh_depth; i++) -+ BUG_ON(!list_empty(&lhead->lh_children[i].lc_list)); -+ kfree(lhead); -+} -+EXPORT_SYMBOL(htree_lock_head_free); -+ -+/* register event callback for @events of child-lock at level @dep */ -+void -+htree_lock_event_attach(struct htree_lock_head *lhead, unsigned dep, -+ unsigned events, htree_event_cb_t callback) -+{ -+ BUG_ON(lhead->lh_depth <= dep); -+ lhead->lh_children[dep].lc_events = events; -+ lhead->lh_children[dep].lc_callback = callback; -+} -+EXPORT_SYMBOL(htree_lock_event_attach); -+ -+/* allocate a htree_lock, which is per-thread structure, @pbytes is some -+ * extra-bytes as private data for caller */ -+struct htree_lock * -+htree_lock_alloc(unsigned depth, unsigned pbytes) -+{ -+ struct htree_lock *lck; -+ int i = offsetof(struct htree_lock, lk_nodes[depth]); -+ -+ if (depth > HTREE_LOCK_DEP_MAX) { -+ printk(KERN_ERR "%d is larger than max htree_lock depth %d\n", -+ depth, HTREE_LOCK_DEP_MAX); -+ return NULL; -+ } -+ lck = kzalloc(i + pbytes, GFP_NOFS); -+ if (lck == NULL) -+ return NULL; -+ -+ if (pbytes != 0) -+ lck->lk_private = (void *)lck + i; -+ lck->lk_mode = HTREE_LOCK_INVAL; -+ lck->lk_depth = depth; -+ INIT_LIST_HEAD(&lck->lk_blocked_list); -+ -+ for (i = 0; i < depth; i++) { -+ struct htree_lock_node *node = &lck->lk_nodes[i]; -+ -+ node->ln_mode = HTREE_LOCK_INVAL; -+ INIT_LIST_HEAD(&node->ln_major_list); -+ INIT_LIST_HEAD(&node->ln_minor_list); -+ INIT_LIST_HEAD(&node->ln_alive_list); -+ INIT_LIST_HEAD(&node->ln_blocked_list); -+ INIT_LIST_HEAD(&node->ln_granted_list); -+ } -+ -+ return lck; -+} -+EXPORT_SYMBOL(htree_lock_alloc); -+ -+/* free htree_lock node */ -+void -+htree_lock_free(struct htree_lock *lck) -+{ -+ BUG_ON(lck->lk_mode != HTREE_LOCK_INVAL); -+ kfree(lck); -+} -+EXPORT_SYMBOL(htree_lock_free); -Index: linux-3.10.0-229.1.2.fc21.x86_64/fs/ext4/Makefile -=================================================================== ---- linux-3.10.0-229.1.2.fc21.x86_64.orig/fs/ext4/Makefile -+++ linux-3.10.0-229.1.2.fc21.x86_64/fs/ext4/Makefile -@@ -6,6 +6,7 @@ obj-$(CONFIG_EXT4_FS) += ext4.o - - ext4-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o page-io.o \ - ioctl.o namei.o super.o symlink.o hash.o resize.o extents.o \ -+ htree_lock.o \ - ext4_jbd2.o migrate.o mballoc.o block_validity.o move_extent.o \ - mmp.o indirect.o extents_status.o xattr.o xattr_user.o \ - xattr_trusted.o inline.o -Index: linux-3.10.0-229.1.2.fc21.x86_64/fs/ext4/ext4.h -=================================================================== ---- linux-3.10.0-229.1.2.fc21.x86_64.orig/fs/ext4/ext4.h -+++ linux-3.10.0-229.1.2.fc21.x86_64/fs/ext4/ext4.h -@@ -27,6 +27,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -821,6 +822,9 @@ struct ext4_inode_info { - __u32 i_dtime; - ext4_fsblk_t i_file_acl; - -+ /* following fields for parallel directory operations -bzzz */ -+ struct semaphore i_append_sem; -+ - /* - * i_block_group is the number of the block group which contains - * this file's inode. Constant across the lifetime of the inode, -@@ -1846,6 +1850,71 @@ struct dx_hash_info - */ - #define HASH_NB_ALWAYS 1 - -+/* assume name-hash is protected by upper layer */ -+#define EXT4_HTREE_LOCK_HASH 0 -+ -+enum ext4_pdo_lk_types { -+#if EXT4_HTREE_LOCK_HASH -+ EXT4_LK_HASH, -+#endif -+ EXT4_LK_DX, /* index block */ -+ EXT4_LK_DE, /* directory entry block */ -+ EXT4_LK_SPIN, /* spinlock */ -+ EXT4_LK_MAX, -+}; -+ -+/* read-only bit */ -+#define EXT4_LB_RO(b) (1 << (b)) -+/* read + write, high bits for writer */ -+#define EXT4_LB_RW(b) ((1 << (b)) | (1 << (EXT4_LK_MAX + (b)))) -+ -+enum ext4_pdo_lock_bits { -+ /* DX lock bits */ -+ EXT4_LB_DX_RO = EXT4_LB_RO(EXT4_LK_DX), -+ EXT4_LB_DX = EXT4_LB_RW(EXT4_LK_DX), -+ /* DE lock bits */ -+ EXT4_LB_DE_RO = EXT4_LB_RO(EXT4_LK_DE), -+ EXT4_LB_DE = EXT4_LB_RW(EXT4_LK_DE), -+ /* DX spinlock bits */ -+ EXT4_LB_SPIN_RO = EXT4_LB_RO(EXT4_LK_SPIN), -+ EXT4_LB_SPIN = EXT4_LB_RW(EXT4_LK_SPIN), -+ /* accurate searching */ -+ EXT4_LB_EXACT = EXT4_LB_RO(EXT4_LK_MAX << 1), -+}; -+ -+enum ext4_pdo_lock_opc { -+ /* external */ -+ EXT4_HLOCK_READDIR = (EXT4_LB_DE_RO | EXT4_LB_DX_RO), -+ EXT4_HLOCK_LOOKUP = (EXT4_LB_DE_RO | EXT4_LB_SPIN_RO | -+ EXT4_LB_EXACT), -+ EXT4_HLOCK_DEL = (EXT4_LB_DE | EXT4_LB_SPIN_RO | -+ EXT4_LB_EXACT), -+ EXT4_HLOCK_ADD = (EXT4_LB_DE | EXT4_LB_SPIN_RO), -+ -+ /* internal */ -+ EXT4_HLOCK_LOOKUP_SAFE = (EXT4_LB_DE_RO | EXT4_LB_DX_RO | -+ EXT4_LB_EXACT), -+ EXT4_HLOCK_DEL_SAFE = (EXT4_LB_DE | EXT4_LB_DX_RO | EXT4_LB_EXACT), -+ EXT4_HLOCK_SPLIT = (EXT4_LB_DE | EXT4_LB_DX | EXT4_LB_SPIN), -+}; -+ -+extern struct htree_lock_head *ext4_htree_lock_head_alloc(unsigned hbits); -+#define ext4_htree_lock_head_free(lhead) htree_lock_head_free(lhead) -+ -+extern struct htree_lock *ext4_htree_lock_alloc(void); -+#define ext4_htree_lock_free(lck) htree_lock_free(lck) -+ -+extern void ext4_htree_lock(struct htree_lock *lck, -+ struct htree_lock_head *lhead, -+ struct inode *dir, unsigned flags); -+#define ext4_htree_unlock(lck) htree_unlock(lck) -+ -+extern struct buffer_head *__ext4_find_entry(struct inode *dir, -+ const struct qstr *d_name, -+ struct ext4_dir_entry_2 **res_dir, -+ int *inlined, struct htree_lock *lck); -+extern int __ext4_add_entry(handle_t *handle, struct dentry *dentry, -+ struct inode *inode, struct htree_lock *lck); - - /* - * Describe an inode's exact location on disk and in memory -@@ -2088,9 +2157,17 @@ void ext4_insert_dentry(struct inode *in - const char *name, int namelen, void *data); - static inline void ext4_update_dx_flag(struct inode *inode) - { -+ /* Disable it for ldiskfs, because going from a DX directory to -+ * a non-DX directory while it is in use will completely break -+ * the htree-locking. -+ * If we really want to support this operation in the future, -+ * we need to exclusively lock the directory at here which will -+ * increase complexity of code */ -+#if 0 - if (!EXT4_HAS_COMPAT_FEATURE(inode->i_sb, - EXT4_FEATURE_COMPAT_DIR_INDEX)) - ext4_clear_inode_flag(inode, EXT4_INODE_INDEX); -+#endif - } - static unsigned char ext4_filetype_table[] = { - DT_UNKNOWN, DT_REG, DT_DIR, DT_CHR, DT_BLK, DT_FIFO, DT_SOCK, DT_LNK -Index: linux-3.10.0-229.1.2.fc21.x86_64/fs/ext4/namei.c -=================================================================== ---- linux-3.10.0-229.1.2.fc21.x86_64.orig/fs/ext4/namei.c -+++ linux-3.10.0-229.1.2.fc21.x86_64/fs/ext4/namei.c -@@ -53,6 +53,7 @@ struct buffer_head *ext4_append(handle_t - ext4_lblk_t *block) - { - struct buffer_head *bh; -+ struct ext4_inode_info *ei = EXT4_I(inode); - int err = 0; - - if (unlikely(EXT4_SB(inode->i_sb)->s_max_dir_size_kb && -@@ -60,15 +61,22 @@ struct buffer_head *ext4_append(handle_t - EXT4_SB(inode->i_sb)->s_max_dir_size_kb))) - return ERR_PTR(-ENOSPC); - -+ /* with parallel dir operations all appends -+ * have to be serialized -bzzz */ -+ down(&ei->i_append_sem); -+ - *block = inode->i_size >> inode->i_sb->s_blocksize_bits; - - bh = ext4_bread(handle, inode, *block, 1, &err); -- if (!bh) -+ if (!bh) { -+ up(&ei->i_append_sem); - return ERR_PTR(err); -+ } - inode->i_size += inode->i_sb->s_blocksize; - EXT4_I(inode)->i_disksize = inode->i_size; - BUFFER_TRACE(bh, "get_write_access"); - err = ext4_journal_get_write_access(handle, bh); -+ up(&ei->i_append_sem); - if (err) { - brelse(bh); - ext4_std_error(inode->i_sb, err); -@@ -246,7 +254,7 @@ static struct dx_frame *dx_probe(const s - struct inode *dir, - struct dx_hash_info *hinfo, - struct dx_frame *frame, -- int *err); -+ struct htree_lock *lck, int *err); - static void dx_release(struct dx_frame *frames); - static int dx_make_map(struct ext4_dir_entry_2 *de, unsigned blocksize, - struct dx_hash_info *hinfo, struct dx_map_entry map[]); -@@ -259,13 +267,13 @@ static void dx_insert_block(struct dx_fr - static int ext4_htree_next_block(struct inode *dir, __u32 hash, - struct dx_frame *frame, - struct dx_frame *frames, -- __u32 *start_hash); -+ __u32 *start_hash, struct htree_lock *lck); - static struct buffer_head * ext4_dx_find_entry(struct inode *dir, - const struct qstr *d_name, - struct ext4_dir_entry_2 **res_dir, -- int *err); -+ struct htree_lock *lck, int *err); - static int ext4_dx_add_entry(handle_t *handle, struct dentry *dentry, -- struct inode *inode); -+ struct inode *inode, struct htree_lock *lck); - - /* checksumming functions */ - void initialize_dirent_tail(struct ext4_dir_entry_tail *t, -@@ -668,6 +676,227 @@ struct stats dx_show_entries(struct dx_h - } - #endif /* DX_DEBUG */ - -+/* private data for htree_lock */ -+struct ext4_dir_lock_data { -+ unsigned ld_flags; /* bits-map for lock types */ -+ unsigned ld_count; /* # entries of the last DX block */ -+ struct dx_entry ld_at_entry; /* copy of leaf dx_entry */ -+ struct dx_entry *ld_at; /* position of leaf dx_entry */ -+}; -+ -+#define ext4_htree_lock_data(l) ((struct ext4_dir_lock_data *)(l)->lk_private) -+#define ext4_find_entry(dir, name, dirent, inline) \ -+ __ext4_find_entry(dir, name, dirent, inline, NULL) -+#define ext4_add_entry(handle, dentry, inode) \ -+ __ext4_add_entry(handle, dentry, inode, NULL) -+ -+/* NB: ext4_lblk_t is 32 bits so we use high bits to identify invalid blk */ -+#define EXT4_HTREE_NODE_CHANGED (0xcafeULL << 32) -+ -+static void ext4_htree_event_cb(void *target, void *event) -+{ -+ u64 *block = (u64 *)target; -+ -+ if (*block == dx_get_block((struct dx_entry *)event)) -+ *block = EXT4_HTREE_NODE_CHANGED; -+} -+ -+struct htree_lock_head *ext4_htree_lock_head_alloc(unsigned hbits) -+{ -+ struct htree_lock_head *lhead; -+ -+ lhead = htree_lock_head_alloc(EXT4_LK_MAX, hbits, 0); -+ if (lhead != NULL) { -+ htree_lock_event_attach(lhead, EXT4_LK_SPIN, HTREE_EVENT_WR, -+ ext4_htree_event_cb); -+ } -+ return lhead; -+} -+EXPORT_SYMBOL(ext4_htree_lock_head_alloc); -+ -+struct htree_lock *ext4_htree_lock_alloc(void) -+{ -+ return htree_lock_alloc(EXT4_LK_MAX, -+ sizeof(struct ext4_dir_lock_data)); -+} -+EXPORT_SYMBOL(ext4_htree_lock_alloc); -+ -+static htree_lock_mode_t ext4_htree_mode(unsigned flags) -+{ -+ switch (flags) { -+ default: /* 0 or unknown flags require EX lock */ -+ return HTREE_LOCK_EX; -+ case EXT4_HLOCK_READDIR: -+ return HTREE_LOCK_PR; -+ case EXT4_HLOCK_LOOKUP: -+ return HTREE_LOCK_CR; -+ case EXT4_HLOCK_DEL: -+ case EXT4_HLOCK_ADD: -+ return HTREE_LOCK_CW; -+ } -+} -+ -+/* return PR for read-only operations, otherwise return EX */ -+static inline htree_lock_mode_t ext4_htree_safe_mode(unsigned flags) -+{ -+ int writer = (flags & EXT4_LB_DE) == EXT4_LB_DE; -+ -+ /* 0 requires EX lock */ -+ return (flags == 0 || writer) ? HTREE_LOCK_EX : HTREE_LOCK_PR; -+} -+ -+static int ext4_htree_safe_locked(struct htree_lock *lck) -+{ -+ int writer; -+ -+ if (lck == NULL || lck->lk_mode == HTREE_LOCK_EX) -+ return 1; -+ -+ writer = (ext4_htree_lock_data(lck)->ld_flags & EXT4_LB_DE) == -+ EXT4_LB_DE; -+ if (writer) /* all readers & writers are excluded? */ -+ return lck->lk_mode == HTREE_LOCK_EX; -+ -+ /* all writers are excluded? */ -+ return lck->lk_mode == HTREE_LOCK_PR || -+ lck->lk_mode == HTREE_LOCK_PW || -+ lck->lk_mode == HTREE_LOCK_EX; -+} -+ -+/* relock htree_lock with EX mode if it's change operation, otherwise -+ * relock it with PR mode. It's noop if PDO is disabled. */ -+static void ext4_htree_safe_relock(struct htree_lock *lck) -+{ -+ if (!ext4_htree_safe_locked(lck)) { -+ unsigned flags = ext4_htree_lock_data(lck)->ld_flags; -+ -+ htree_change_lock(lck, ext4_htree_safe_mode(flags)); -+ } -+} -+ -+void ext4_htree_lock(struct htree_lock *lck, struct htree_lock_head *lhead, -+ struct inode *dir, unsigned flags) -+{ -+ htree_lock_mode_t mode = is_dx(dir) ? ext4_htree_mode(flags) : -+ ext4_htree_safe_mode(flags); -+ -+ ext4_htree_lock_data(lck)->ld_flags = flags; -+ htree_lock(lck, lhead, mode); -+ if (!is_dx(dir)) -+ ext4_htree_safe_relock(lck); /* make sure it's safe locked */ -+} -+EXPORT_SYMBOL(ext4_htree_lock); -+ -+static int ext4_htree_node_lock(struct htree_lock *lck, struct dx_entry *at, -+ unsigned lmask, int wait, void *ev) -+{ -+ u32 key = (at == NULL) ? 0 : dx_get_block(at); -+ u32 mode; -+ -+ /* NOOP if htree is well protected or caller doesn't require the lock */ -+ if (ext4_htree_safe_locked(lck) || -+ !(ext4_htree_lock_data(lck)->ld_flags & lmask)) -+ return 1; -+ -+ mode = (ext4_htree_lock_data(lck)->ld_flags & lmask) == lmask ? -+ HTREE_LOCK_PW : HTREE_LOCK_PR; -+ while (1) { -+ if (htree_node_lock_try(lck, mode, key, ffz(~lmask), wait, ev)) -+ return 1; -+ if (!(lmask & EXT4_LB_SPIN)) /* not a spinlock */ -+ return 0; -+ cpu_relax(); /* spin until granted */ -+ } -+} -+ -+static int ext4_htree_node_locked(struct htree_lock *lck, unsigned lmask) -+{ -+ return ext4_htree_safe_locked(lck) || -+ htree_node_is_granted(lck, ffz(~lmask)); -+} -+ -+static void ext4_htree_node_unlock(struct htree_lock *lck, -+ unsigned lmask, void *buf) -+{ -+ /* NB: it's safe to call mutiple times or even it's not locked */ -+ if (!ext4_htree_safe_locked(lck) && -+ htree_node_is_granted(lck, ffz(~lmask))) -+ htree_node_unlock(lck, ffz(~lmask), buf); -+} -+ -+#define ext4_htree_dx_lock(lck, key) \ -+ ext4_htree_node_lock(lck, key, EXT4_LB_DX, 1, NULL) -+#define ext4_htree_dx_lock_try(lck, key) \ -+ ext4_htree_node_lock(lck, key, EXT4_LB_DX, 0, NULL) -+#define ext4_htree_dx_unlock(lck) \ -+ ext4_htree_node_unlock(lck, EXT4_LB_DX, NULL) -+#define ext4_htree_dx_locked(lck) \ -+ ext4_htree_node_locked(lck, EXT4_LB_DX) -+ -+static void ext4_htree_dx_need_lock(struct htree_lock *lck) -+{ -+ struct ext4_dir_lock_data *ld; -+ -+ if (ext4_htree_safe_locked(lck)) -+ return; -+ -+ ld = ext4_htree_lock_data(lck); -+ switch (ld->ld_flags) { -+ default: -+ return; -+ case EXT4_HLOCK_LOOKUP: -+ ld->ld_flags = EXT4_HLOCK_LOOKUP_SAFE; -+ return; -+ case EXT4_HLOCK_DEL: -+ ld->ld_flags = EXT4_HLOCK_DEL_SAFE; -+ return; -+ case EXT4_HLOCK_ADD: -+ ld->ld_flags = EXT4_HLOCK_SPLIT; -+ return; -+ } -+} -+ -+#define ext4_htree_de_lock(lck, key) \ -+ ext4_htree_node_lock(lck, key, EXT4_LB_DE, 1, NULL) -+#define ext4_htree_de_unlock(lck) \ -+ ext4_htree_node_unlock(lck, EXT4_LB_DE, NULL) -+ -+#define ext4_htree_spin_lock(lck, key, event) \ -+ ext4_htree_node_lock(lck, key, EXT4_LB_SPIN, 0, event) -+#define ext4_htree_spin_unlock(lck) \ -+ ext4_htree_node_unlock(lck, EXT4_LB_SPIN, NULL) -+#define ext4_htree_spin_unlock_listen(lck, p) \ -+ ext4_htree_node_unlock(lck, EXT4_LB_SPIN, p) -+ -+static void ext4_htree_spin_stop_listen(struct htree_lock *lck) -+{ -+ if (!ext4_htree_safe_locked(lck) && -+ htree_node_is_listening(lck, ffz(~EXT4_LB_SPIN))) -+ htree_node_stop_listen(lck, ffz(~EXT4_LB_SPIN)); -+} -+ -+enum { -+ DX_HASH_COL_IGNORE, /* ignore collision while probing frames */ -+ DX_HASH_COL_YES, /* there is collision and it does matter */ -+ DX_HASH_COL_NO, /* there is no collision */ -+}; -+ -+static int dx_probe_hash_collision(struct htree_lock *lck, -+ struct dx_entry *entries, -+ struct dx_entry *at, u32 hash) -+{ -+ if (!(ext4_htree_lock_data(lck)->ld_flags & EXT4_LB_EXACT)) { -+ return DX_HASH_COL_IGNORE; /* don't care about collision */ -+ -+ } else if (at == entries + dx_get_count(entries) - 1) { -+ return DX_HASH_COL_IGNORE; /* not in any leaf of this DX */ -+ -+ } else { /* hash collision? */ -+ return ((dx_get_hash(at + 1) & ~1) == hash) ? -+ DX_HASH_COL_YES : DX_HASH_COL_NO; -+ } -+} -+ - /* - * Probe for a directory leaf block to search. - * -@@ -679,10 +908,11 @@ struct stats dx_show_entries(struct dx_h - */ - static struct dx_frame * - dx_probe(const struct qstr *d_name, struct inode *dir, -- struct dx_hash_info *hinfo, struct dx_frame *frame_in, int *err) -+ struct dx_hash_info *hinfo, struct dx_frame *frame_in, -+ struct htree_lock *lck, int *err) - { - unsigned count, indirect; -- struct dx_entry *at, *entries, *p, *q, *m; -+ struct dx_entry *at, *entries, *p, *q, *m, *dx = NULL; - struct dx_root_info *info; - struct buffer_head *bh; - struct dx_frame *frame = frame_in; -@@ -750,8 +980,15 @@ dx_probe(const struct qstr *d_name, stru - dxtrace(printk("Look up %x", hash)); - while (1) - { -+ if (indirect == 0) { /* the last index level */ -+ /* NB: ext4_htree_dx_lock() could be noop if -+ * DX-lock flag is not set for current operation */ -+ ext4_htree_dx_lock(lck, dx); -+ ext4_htree_spin_lock(lck, dx, NULL); -+ } - count = dx_get_count(entries); -- if (!count || count > dx_get_limit(entries)) { -+ if (count == 0 || count > dx_get_limit(entries)) { -+ ext4_htree_spin_unlock(lck); /* release spin */ - ext4_warning(dir->i_sb, - "dx entry: no count or count > limit"); - brelse(bh); -@@ -792,7 +1029,70 @@ dx_probe(const struct qstr *d_name, stru - frame->bh = bh; - frame->entries = entries; - frame->at = at; -- if (!indirect--) return frame; -+ -+ if (indirect == 0) { /* the last index level */ -+ struct ext4_dir_lock_data *ld; -+ u64 myblock; -+ -+ /* By default we only lock DE-block, however, we will -+ * also lock the last level DX-block if: -+ * a) there is hash collision -+ * we will set DX-lock flag (a few lines below) -+ * and redo to lock DX-block -+ * see detail in dx_probe_hash_collision() -+ * b) it's a retry from splitting -+ * we need to lock the last level DX-block so nobody -+ * else can split any leaf blocks under the same -+ * DX-block, see detail in ext4_dx_add_entry() -+ */ -+ if (ext4_htree_dx_locked(lck)) { -+ /* DX-block is locked, just lock DE-block -+ * and return */ -+ ext4_htree_spin_unlock(lck); -+ if (!ext4_htree_safe_locked(lck)) -+ ext4_htree_de_lock(lck, frame->at); -+ return frame; -+ } -+ /* it's pdirop and no DX lock */ -+ if (dx_probe_hash_collision(lck, entries, at, hash) == -+ DX_HASH_COL_YES) { -+ /* found hash collision, set DX-lock flag -+ * and retry to abtain DX-lock */ -+ ext4_htree_spin_unlock(lck); -+ ext4_htree_dx_need_lock(lck); -+ continue; -+ } -+ ld = ext4_htree_lock_data(lck); -+ /* because I don't lock DX, so @at can't be trusted -+ * after I release spinlock so I have to save it */ -+ ld->ld_at = at; -+ ld->ld_at_entry = *at; -+ ld->ld_count = dx_get_count(entries); -+ -+ frame->at = &ld->ld_at_entry; -+ myblock = dx_get_block(at); -+ -+ /* NB: ordering locking */ -+ ext4_htree_spin_unlock_listen(lck, &myblock); -+ /* other thread can split this DE-block because: -+ * a) I don't have lock for the DE-block yet -+ * b) I released spinlock on DX-block -+ * if it happened I can detect it by listening -+ * splitting event on this DE-block */ -+ ext4_htree_de_lock(lck, frame->at); -+ ext4_htree_spin_stop_listen(lck); -+ -+ if (myblock == EXT4_HTREE_NODE_CHANGED) { -+ /* someone split this DE-block before -+ * I locked it, I need to retry and lock -+ * valid DE-block */ -+ ext4_htree_de_unlock(lck); -+ continue; -+ } -+ return frame; -+ } -+ dx = at; -+ indirect--; - bh = ext4_read_dirblock(dir, dx_get_block(at), INDEX); - if (IS_ERR(bh)) { - *err = PTR_ERR(bh); -@@ -860,7 +1160,7 @@ static void dx_release (struct dx_frame - static int ext4_htree_next_block(struct inode *dir, __u32 hash, - struct dx_frame *frame, - struct dx_frame *frames, -- __u32 *start_hash) -+ __u32 *start_hash, struct htree_lock *lck) - { - struct dx_frame *p; - struct buffer_head *bh; -@@ -875,12 +1175,22 @@ static int ext4_htree_next_block(struct - * this loop, num_frames indicates the number of interior - * nodes need to be read. - */ -+ ext4_htree_de_unlock(lck); - while (1) { -- if (++(p->at) < p->entries + dx_get_count(p->entries)) -- break; -+ if (num_frames > 0 || ext4_htree_dx_locked(lck)) { -+ /* num_frames > 0 : -+ * DX block -+ * ext4_htree_dx_locked: -+ * frame->at is reliable pointer returned by dx_probe, -+ * otherwise dx_probe already knew no collision */ -+ if (++(p->at) < p->entries + dx_get_count(p->entries)) -+ break; -+ } - if (p == frames) - return 0; - num_frames++; -+ if (num_frames == 1) -+ ext4_htree_dx_unlock(lck); - p--; - } - -@@ -903,6 +1213,13 @@ static int ext4_htree_next_block(struct - * block so no check is necessary - */ - while (num_frames--) { -+ if (num_frames == 0) { -+ /* it's not always necessary, we just don't want to -+ * detect hash collision again */ -+ ext4_htree_dx_need_lock(lck); -+ ext4_htree_dx_lock(lck, p->at); -+ } -+ - bh = ext4_read_dirblock(dir, dx_get_block(p->at), INDEX); - if (IS_ERR(bh)) - return PTR_ERR(bh); -@@ -911,6 +1228,7 @@ static int ext4_htree_next_block(struct - p->bh = bh; - p->at = p->entries = ((struct dx_node *) bh->b_data)->entries; - } -+ ext4_htree_de_lock(lck, p->at); - return 1; - } - -@@ -1013,10 +1331,10 @@ int ext4_htree_fill_tree(struct file *di - } - hinfo.hash = start_hash; - hinfo.minor_hash = 0; -- frame = dx_probe(NULL, dir, &hinfo, frames, &err); -+ /* assume it's PR locked */ -+ frame = dx_probe(NULL, dir, &hinfo, frames, NULL, &err); - if (!frame) - return err; -- - /* Add '.' and '..' from the htree header */ - if (!start_hash && !start_minor_hash) { - de = (struct ext4_dir_entry_2 *) frames[0].bh->b_data; -@@ -1043,7 +1361,7 @@ int ext4_htree_fill_tree(struct file *di - count += ret; - hashval = ~0; - ret = ext4_htree_next_block(dir, HASH_NB_ALWAYS, -- frame, frames, &hashval); -+ frame, frames, &hashval, NULL); - *next_hash = hashval; - if (ret < 0) { - err = ret; -@@ -1236,10 +1554,10 @@ static int is_dx_internal_node(struct in - * The returned buffer_head has ->b_count elevated. The caller is expected - * to brelse() it when appropriate. - */ --static struct buffer_head * ext4_find_entry (struct inode *dir, -+struct buffer_head *__ext4_find_entry(struct inode *dir, - const struct qstr *d_name, - struct ext4_dir_entry_2 **res_dir, -- int *inlined) -+ int *inlined, struct htree_lock *lck) - { - struct super_block *sb; - struct buffer_head *bh_use[NAMEI_RA_SIZE]; -@@ -1283,7 +1601,7 @@ static struct buffer_head * ext4_find_en - goto restart; - } - if (is_dx(dir)) { -- bh = ext4_dx_find_entry(dir, d_name, res_dir, &err); -+ bh = ext4_dx_find_entry(dir, d_name, res_dir, lck, &err); - /* - * On success, or if the error was file not found, - * return. Otherwise, fall back to doing a search the -@@ -1297,6 +1615,7 @@ static struct buffer_head * ext4_find_en - return bh; - dxtrace(printk(KERN_DEBUG "ext4_find_entry: dx failed, " - "falling back\n")); -+ ext4_htree_safe_relock(lck); - } - nblocks = dir->i_size >> EXT4_BLOCK_SIZE_BITS(sb); - start = EXT4_I(dir)->i_dir_start_lookup; -@@ -1389,9 +1708,12 @@ cleanup_and_exit: - brelse(bh_use[ra_ptr]); - return ret; - } -+EXPORT_SYMBOL(__ext4_find_entry); - --static struct buffer_head * ext4_dx_find_entry(struct inode *dir, const struct qstr *d_name, -- struct ext4_dir_entry_2 **res_dir, int *err) -+static struct buffer_head *ext4_dx_find_entry(struct inode *dir, -+ const struct qstr *d_name, -+ struct ext4_dir_entry_2 **res_dir, -+ struct htree_lock *lck, int *err) - { - struct super_block * sb = dir->i_sb; - struct dx_hash_info hinfo; -@@ -1400,7 +1722,7 @@ static struct buffer_head * ext4_dx_find - ext4_lblk_t block; - int retval; - -- if (!(frame = dx_probe(d_name, dir, &hinfo, frames, err))) -+ if (!(frame = dx_probe(d_name, dir, &hinfo, frames, lck, err))) - return NULL; - do { - block = dx_get_block(frame->at); -@@ -1424,7 +1746,7 @@ static struct buffer_head * ext4_dx_find - - /* Check to see if we should continue to search */ - retval = ext4_htree_next_block(dir, hinfo.hash, frame, -- frames, NULL); -+ frames, NULL, lck); - if (retval < 0) { - ext4_warning(sb, - "error reading index page in directory #%lu", -@@ -1583,8 +1905,9 @@ static struct ext4_dir_entry_2* dx_pack_ - * Returns pointer to de in block into which the new entry will be inserted. - */ - static struct ext4_dir_entry_2 *do_split(handle_t *handle, struct inode *dir, -- struct buffer_head **bh,struct dx_frame *frame, -- struct dx_hash_info *hinfo, int *error) -+ struct buffer_head **bh, struct dx_frame *frames, -+ struct dx_frame *frame, struct dx_hash_info *hinfo, -+ struct htree_lock *lck, int *error) - { - unsigned blocksize = dir->i_sb->s_blocksize; - unsigned count, continued; -@@ -1647,7 +1970,14 @@ static struct ext4_dir_entry_2 *do_split - hash2, split, count-split)); - - /* Fancy dance to stay within two buffers */ -- de2 = dx_move_dirents(data1, data2, map + split, count - split, blocksize); -+ if (hinfo->hash < hash2) { -+ de2 = dx_move_dirents(data1, data2, map + split, -+ count - split, blocksize); -+ } else { -+ /* make sure we will add entry to the same block which -+ * we have already locked */ -+ de2 = dx_move_dirents(data1, data2, map, split, blocksize); -+ } - de = dx_pack_dirents(data1, blocksize); - de->rec_len = ext4_rec_len_to_disk(data1 + (blocksize - csum_size) - - (char *) de, -@@ -1666,13 +1996,21 @@ static struct ext4_dir_entry_2 *do_split - dxtrace(dx_show_leaf (hinfo, (struct ext4_dir_entry_2 *) data1, blocksize, 1)); - dxtrace(dx_show_leaf (hinfo, (struct ext4_dir_entry_2 *) data2, blocksize, 1)); - -- /* Which block gets the new entry? */ -- if (hinfo->hash >= hash2) -- { -- swap(*bh, bh2); -- de = de2; -+ ext4_htree_spin_lock(lck, frame > frames ? (frame - 1)->at : NULL, -+ frame->at); /* notify block is being split */ -+ if (hinfo->hash < hash2) { -+ dx_insert_block(frame, hash2 + continued, newblock); -+ -+ } else { -+ /* switch block number */ -+ dx_insert_block(frame, hash2 + continued, -+ dx_get_block(frame->at)); -+ dx_set_block(frame->at, newblock); -+ (frame->at)++; - } -- dx_insert_block(frame, hash2 + continued, newblock); -+ ext4_htree_spin_unlock(lck); -+ ext4_htree_dx_unlock(lck); -+ - err = ext4_handle_dirty_dirent_node(handle, dir, bh2); - if (err) - goto journal_error; -@@ -1945,7 +2283,7 @@ static int make_indexed_dir(handle_t *ha - ext4_handle_dirty_dx_node(handle, dir, frame->bh); - ext4_handle_dirty_dirent_node(handle, dir, bh); - -- de = do_split(handle,dir, &bh, frame, &hinfo, &retval); -+ de = do_split(handle, dir, &bh, frames, frame, &hinfo, NULL, &retval); - if (!de) { - /* - * Even if the block split failed, we have to properly write -@@ -2051,8 +2389,8 @@ out: - * may not sleep between calling this and putting something into - * the entry, as someone else might have used it while you slept. - */ --static int ext4_add_entry(handle_t *handle, struct dentry *dentry, -- struct inode *inode) -+int __ext4_add_entry(handle_t *handle, struct dentry *dentry, -+ struct inode *inode, struct htree_lock *lck) - { - struct inode *dir = dentry->d_parent->d_inode; - struct buffer_head *bh = NULL; -@@ -2087,9 +2425,10 @@ static int ext4_add_entry(handle_t *hand - if (dentry->d_name.len == 2 && - memcmp(dentry->d_name.name, "..", 2) == 0) - return ext4_update_dotdot(handle, dentry, inode); -- retval = ext4_dx_add_entry(handle, dentry, inode); -+ retval = ext4_dx_add_entry(handle, dentry, inode, lck); - if (!retval || (retval != ERR_BAD_DX_DIR)) - goto out; -+ ext4_htree_safe_relock(lck); - ext4_clear_inode_flag(dir, EXT4_INODE_INDEX); - dx_fallback++; - ext4_mark_inode_dirty(handle, dir); -@@ -2129,12 +2468,13 @@ static int ext4_add_entry(handle_t *hand - ext4_set_inode_state(inode, EXT4_STATE_NEWENTRY); - return retval; - } -+EXPORT_SYMBOL(__ext4_add_entry); - - /* - * Returns 0 for success, or a negative error value - */ - static int ext4_dx_add_entry(handle_t *handle, struct dentry *dentry, -- struct inode *inode) -+ struct inode *inode, struct htree_lock *lck) - { - struct dx_frame frames[EXT4_HTREE_LEVEL], *frame; - struct dx_entry *entries, *at; -@@ -2148,7 +2488,7 @@ static int ext4_dx_add_entry(handle_t *h - - again: - restart = 0; -- frame = dx_probe(&dentry->d_name, dir, &hinfo, frames, &err); -+ frame = dx_probe(&dentry->d_name, dir, &hinfo, frames, lck, &err); - if (!frame) - return err; - entries = frame->entries; -@@ -2178,6 +2518,11 @@ again: - struct dx_node *node2; - struct buffer_head *bh2; - -+ if (!ext4_htree_safe_locked(lck)) { /* retry with EX lock */ -+ ext4_htree_safe_relock(lck); -+ restart = 1; -+ goto cleanup; -+ } - while (frame > frames) { - if (dx_get_count((frame - 1)->entries) < - dx_get_limit((frame - 1)->entries)) { -@@ -2277,16 +2622,43 @@ again: - restart = 1; - goto journal_error; - } -+ } else if (!ext4_htree_dx_locked(lck)) { -+ struct ext4_dir_lock_data *ld = ext4_htree_lock_data(lck); -+ -+ /* not well protected, require DX lock */ -+ ext4_htree_dx_need_lock(lck); -+ at = frame > frames ? (frame - 1)->at : NULL; -+ -+ /* NB: no risk of deadlock because it's just a try. -+ * -+ * NB: we check ld_count for twice, the first time before -+ * having DX lock, the second time after holding DX lock. -+ * -+ * NB: We never free blocks for directory so far, which -+ * means value returned by dx_get_count() should equal to -+ * ld->ld_count if nobody split any DE-block under @at, -+ * and ld->ld_at still points to valid dx_entry. */ -+ if ((ld->ld_count != dx_get_count(entries)) || -+ !ext4_htree_dx_lock_try(lck, at) || -+ (ld->ld_count != dx_get_count(entries))) { -+ restart = 1; -+ goto cleanup; -+ } -+ /* OK, I've got DX lock and nothing changed */ -+ frame->at = ld->ld_at; - } -- de = do_split(handle, dir, &bh, frame, &hinfo, &err); -+ de = do_split(handle, dir, &bh, frames, frame, &hinfo, lck, &err); - if (!de) - goto cleanup; -+ - err = add_dirent_to_buf(handle, dentry, inode, de, bh); - goto cleanup; - - journal_error: - ext4_std_error(dir->i_sb, err); /* this is a no-op if err == 0 */ - cleanup: -+ ext4_htree_dx_unlock(lck); -+ ext4_htree_de_unlock(lck); - brelse(bh); - dx_release(frames); - /* @restart is true means htree-path has been changed, we need to -Index: linux-3.10.0-229.1.2.fc21.x86_64/fs/ext4/super.c -=================================================================== ---- linux-3.10.0-229.1.2.fc21.x86_64.orig/fs/ext4/super.c -+++ linux-3.10.0-229.1.2.fc21.x86_64/fs/ext4/super.c -@@ -875,6 +875,7 @@ static struct inode *ext4_alloc_inode(st - - ei->vfs_inode.i_version = 1; - spin_lock_init(&ei->i_raw_lock); -+ sema_init(&ei->i_append_sem, 1); - INIT_LIST_HEAD(&ei->i_prealloc_list); - spin_lock_init(&ei->i_prealloc_lock); - ext4_es_init_tree(&ei->i_es_tree); diff --git a/ldiskfs/kernel_patches/patches/rhel7.2/ext4-release-bh-in-makeinxdir.patch b/ldiskfs/kernel_patches/patches/rhel7.2/ext4-release-bh-in-makeinxdir.patch deleted file mode 100644 index ef4d54a..0000000 --- a/ldiskfs/kernel_patches/patches/rhel7.2/ext4-release-bh-in-makeinxdir.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- linux-1/fs/ext4/namei.c 2016-09-27 02:16:31.020890438 +0800 -+++ linux-2/fs/ext4/namei.c 2016-09-27 02:17:14.246620470 +0800 -@@ -1874,6 +1874,7 @@ out_frames: - */ - ext4_mark_inode_dirty(handle, dir); - dx_release(frames); -+ brelse(bh); - return retval; - } - diff --git a/ldiskfs/kernel_patches/patches/rhel7.2/ext4-remove-i_data_sem-from-xattr.patch b/ldiskfs/kernel_patches/patches/rhel7.2/ext4-remove-i_data_sem-from-xattr.patch deleted file mode 100644 index fa5ace5..0000000 --- a/ldiskfs/kernel_patches/patches/rhel7.2/ext4-remove-i_data_sem-from-xattr.patch +++ /dev/null @@ -1,475 +0,0 @@ -From a521100231f816f8cdd9c8e77da14ff1e42c2b17 Mon Sep 17 00:00:00 2001 -From: Theodore Ts'o -Date: Thu, 4 Sep 2014 18:06:25 -0400 -Subject: [PATCH] ext4: pass allocation_request struct to - ext4_(alloc,splice)_branch - -Instead of initializing the allocation_request structure in -ext4_alloc_branch(), set it up in ext4_ind_map_blocks(), and then pass -it to ext4_alloc_branch() and ext4_splice_branch(). - -This allows ext4_ind_map_blocks to pass flags in the allocation -request structure without having to add Yet Another argument to -ext4_alloc_branch(). - -Signed-off-by: Theodore Ts'o -Reviewed-by: Jan Kara ---- - fs/ext4/indirect.c | 82 +++++++++++++++++++++++++----------------------------- - 1 file changed, 38 insertions(+), 44 deletions(-) - -diff --git a/fs/ext4/indirect.c b/fs/ext4/indirect.c -index e75f840..69af0cd 100644 ---- a/fs/ext4/indirect.c -+++ b/fs/ext4/indirect.c -@@ -318,34 +318,22 @@ static int ext4_blks_to_allocate(Indirect *branch, int k, unsigned int blks, - * ext4_alloc_block() (normally -ENOSPC). Otherwise we set the chain - * as described above and return 0. - */ --static int ext4_alloc_branch(handle_t *handle, struct inode *inode, -- ext4_lblk_t iblock, int indirect_blks, -- int *blks, ext4_fsblk_t goal, -- ext4_lblk_t *offsets, Indirect *branch) -+static int ext4_alloc_branch(handle_t *handle, -+ struct ext4_allocation_request *ar, -+ int indirect_blks, ext4_lblk_t *offsets, -+ Indirect *branch) - { -- struct ext4_allocation_request ar; - struct buffer_head * bh; - ext4_fsblk_t b, new_blocks[4]; - __le32 *p; - int i, j, err, len = 1; - -- /* -- * Set up for the direct block allocation -- */ -- memset(&ar, 0, sizeof(ar)); -- ar.inode = inode; -- ar.len = *blks; -- ar.logical = iblock; -- if (S_ISREG(inode->i_mode)) -- ar.flags = EXT4_MB_HINT_DATA; -- - for (i = 0; i <= indirect_blks; i++) { - if (i == indirect_blks) { -- ar.goal = goal; -- new_blocks[i] = ext4_mb_new_blocks(handle, &ar, &err); -+ new_blocks[i] = ext4_mb_new_blocks(handle, ar, &err); - } else -- goal = new_blocks[i] = ext4_new_meta_blocks(handle, inode, -- goal, 0, NULL, &err); -+ ar->goal = new_blocks[i] = ext4_new_meta_blocks(handle, -+ ar->inode, ar->goal, 0, NULL, &err); - if (err) { - i--; - goto failed; -@@ -354,7 +342,7 @@ static int ext4_alloc_branch(handle_t *handle, struct inode *inode, - if (i == 0) - continue; - -- bh = branch[i].bh = sb_getblk(inode->i_sb, new_blocks[i-1]); -+ bh = branch[i].bh = sb_getblk(ar->inode->i_sb, new_blocks[i-1]); - if (unlikely(!bh)) { - err = -ENOMEM; - goto failed; -@@ -372,7 +360,7 @@ static int ext4_alloc_branch(handle_t *handle, struct inode *inode, - b = new_blocks[i]; - - if (i == indirect_blks) -- len = ar.len; -+ len = ar->len; - for (j = 0; j < len; j++) - *p++ = cpu_to_le32(b++); - -@@ -381,11 +369,10 @@ static int ext4_alloc_branch(handle_t *handle, struct inode *inode, - unlock_buffer(bh); - - BUFFER_TRACE(bh, "call ext4_handle_dirty_metadata"); -- err = ext4_handle_dirty_metadata(handle, inode, bh); -+ err = ext4_handle_dirty_metadata(handle, ar->inode, bh); - if (err) - goto failed; - } -- *blks = ar.len; - return 0; - failed: - for (; i >= 0; i--) { -@@ -396,10 +383,10 @@ static int ext4_alloc_branch(handle_t *handle, struct inode *inode, - * existing before ext4_alloc_branch() was called. - */ - if (i > 0 && i != indirect_blks && branch[i].bh) -- ext4_forget(handle, 1, inode, branch[i].bh, -+ ext4_forget(handle, 1, ar->inode, branch[i].bh, - branch[i].bh->b_blocknr); -- ext4_free_blocks(handle, inode, NULL, new_blocks[i], -- (i == indirect_blks) ? ar.len : 1, 0); -+ ext4_free_blocks(handle, ar->inode, NULL, new_blocks[i], -+ (i == indirect_blks) ? ar->len : 1, 0); - } - return err; - } -@@ -419,9 +406,9 @@ static int ext4_alloc_branch(handle_t *handle, struct inode *inode, - * inode (->i_blocks, etc.). In case of success we end up with the full - * chain to new block and return 0. - */ --static int ext4_splice_branch(handle_t *handle, struct inode *inode, -- ext4_lblk_t block, Indirect *where, int num, -- int blks) -+static int ext4_splice_branch(handle_t *handle, -+ struct ext4_allocation_request *ar, -+ Indirect *where, int num) - { - int i; - int err = 0; -@@ -446,9 +433,9 @@ static int ext4_splice_branch(handle_t *handle, struct inode *inode, - * Update the host buffer_head or inode to point to more just allocated - * direct blocks blocks - */ -- if (num == 0 && blks > 1) { -+ if (num == 0 && ar->len > 1) { - current_block = le32_to_cpu(where->key) + 1; -- for (i = 1; i < blks; i++) -+ for (i = 1; i < ar->len; i++) - *(where->p + i) = cpu_to_le32(current_block++); - } - -@@ -465,14 +452,14 @@ static int ext4_splice_branch(handle_t *handle, struct inode *inode, - */ - jbd_debug(5, "splicing indirect only\n"); - BUFFER_TRACE(where->bh, "call ext4_handle_dirty_metadata"); -- err = ext4_handle_dirty_metadata(handle, inode, where->bh); -+ err = ext4_handle_dirty_metadata(handle, ar->inode, where->bh); - if (err) - goto err_out; - } else { - /* - * OK, we spliced it into the inode itself on a direct block. - */ -- ext4_mark_inode_dirty(handle, inode); -+ ext4_mark_inode_dirty(handle, ar->inode); - jbd_debug(5, "splicing direct\n"); - } - return err; -@@ -484,11 +471,11 @@ static int ext4_splice_branch(handle_t *handle, struct inode *inode, - * need to revoke the block, which is why we don't - * need to set EXT4_FREE_BLOCKS_METADATA. - */ -- ext4_free_blocks(handle, inode, where[i].bh, 0, 1, -+ ext4_free_blocks(handle, ar->inode, where[i].bh, 0, 1, - EXT4_FREE_BLOCKS_FORGET); - } -- ext4_free_blocks(handle, inode, NULL, le32_to_cpu(where[num].key), -- blks, 0); -+ ext4_free_blocks(handle, ar->inode, NULL, le32_to_cpu(where[num].key), -+ ar->len, 0); - - return err; - } -@@ -525,11 +512,11 @@ int ext4_ind_map_blocks(handle_t *handle, struct inode *inode, - struct ext4_map_blocks *map, - int flags) - { -+ struct ext4_allocation_request ar; - int err = -EIO; - ext4_lblk_t offsets[4]; - Indirect chain[4]; - Indirect *partial; -- ext4_fsblk_t goal; - int indirect_blks; - int blocks_to_boundary = 0; - int depth; -@@ -579,7 +566,14 @@ int ext4_ind_map_blocks(handle_t *handle, struct inode *inode, - return -ENOSPC; - } - -- goal = ext4_find_goal(inode, map->m_lblk, partial); -+ /* Set up for the direct block allocation */ -+ memset(&ar, 0, sizeof(ar)); -+ ar.inode = inode; -+ ar.logical = map->m_lblk; -+ if (S_ISREG(inode->i_mode)) -+ ar.flags = EXT4_MB_HINT_DATA; -+ -+ ar.goal = ext4_find_goal(inode, map->m_lblk, partial); - - /* the number of blocks need to allocate for [d,t]indirect blocks */ - indirect_blks = (chain + depth) - partial - 1; -@@ -588,13 +582,13 @@ int ext4_ind_map_blocks(handle_t *handle, struct inode *inode, - * Next look up the indirect map to count the totoal number of - * direct blocks to allocate for this branch. - */ -- count = ext4_blks_to_allocate(partial, indirect_blks, -- map->m_len, blocks_to_boundary); -+ ar.len = ext4_blks_to_allocate(partial, indirect_blks, -+ map->m_len, blocks_to_boundary); -+ - /* - * Block out ext4_truncate while we alter the tree - */ -- err = ext4_alloc_branch(handle, inode, map->m_lblk, indirect_blks, -- &count, goal, -+ err = ext4_alloc_branch(handle, &ar, indirect_blks, - offsets + (partial - chain), partial); - - /* -@@ -605,14 +599,14 @@ int ext4_ind_map_blocks(handle_t *handle, struct inode *inode, - * may need to return -EAGAIN upwards in the worst case. --sct - */ - if (!err) -- err = ext4_splice_branch(handle, inode, map->m_lblk, -- partial, indirect_blks, count); -+ err = ext4_splice_branch(handle, &ar, partial, indirect_blks); - if (err) - goto cleanup; - - map->m_flags |= EXT4_MAP_NEW; - - ext4_update_inode_fsync_trans(handle, inode, 1); -+ count = ar.len; - got_it: - map->m_flags |= EXT4_MAP_MAPPED; - map->m_pblk = le32_to_cpu(chain[depth-1].key); --- -2.7.4 - -From e3cf5d5d9a86df1c5e413bdd3725c25a16ff854c Mon Sep 17 00:00:00 2001 -From: Theodore Ts'o -Date: Thu, 4 Sep 2014 18:07:25 -0400 -Subject: [PATCH] ext4: prepare to drop EXT4_STATE_DELALLOC_RESERVED - -The EXT4_STATE_DELALLOC_RESERVED flag was originally implemented -because it was too hard to make sure the mballoc and get_block flags -could be reliably passed down through all of the codepaths that end up -calling ext4_mb_new_blocks(). - -Since then, we have mb_flags passed down through most of the code -paths, so getting rid of EXT4_STATE_DELALLOC_RESERVED isn't as tricky -as it used to. - -This commit plumbs in the last of what is required, and then adds a -WARN_ON check to make sure we haven't missed anything. If this passes -a full regression test run, we can then drop -EXT4_STATE_DELALLOC_RESERVED. - -Signed-off-by: Theodore Ts'o -Reviewed-by: Jan Kara ---- - fs/ext4/balloc.c | 3 +-- - fs/ext4/extents.c | 6 +++++- - fs/ext4/indirect.c | 6 +++++- - fs/ext4/mballoc.c | 10 ++++++---- - fs/ext4/xattr.c | 6 ------ - 5 files changed, 17 insertions(+), 14 deletions(-) - -diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c -index 581ef40..d70f154 100644 ---- a/fs/ext4/balloc.c -+++ b/fs/ext4/balloc.c -@@ -636,8 +636,7 @@ ext4_fsblk_t ext4_new_meta_blocks(handle_t *handle, struct inode *inode, - * Account for the allocated meta blocks. We will never - * fail EDQUOT for metdata, but we do account for it. - */ -- if (!(*errp) && -- ext4_test_inode_state(inode, EXT4_STATE_DELALLOC_RESERVED)) { -+ if (!(*errp) && (flags & EXT4_MB_DELALLOC_RESERVED)) { - dquot_alloc_block_nofail(inode, - EXT4_C2B(EXT4_SB(inode->i_sb), ar.len)); - } -diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c -index 3ac1686..8170b32 100644 ---- a/fs/ext4/extents.c -+++ b/fs/ext4/extents.c -@@ -1933,6 +1933,8 @@ int ext4_ext_insert_extent(handle_t *handle, struct inode *inode, - ext4_lblk_t next; - int mb_flags = 0, unwritten; - -+ if (gb_flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE) -+ mb_flags |= EXT4_MB_DELALLOC_RESERVED; - if (unlikely(ext4_ext_get_actual_len(newext) == 0)) { - EXT4_ERROR_INODE(inode, "ext4_ext_get_actual_len(newext) == 0"); - return -EIO; -@@ -2054,7 +2056,7 @@ int ext4_ext_insert_extent(handle_t *handle, struct inode *inode, - * We're gonna add a new leaf in the tree. - */ - if (gb_flags & EXT4_GET_BLOCKS_METADATA_NOFAIL) -- mb_flags = EXT4_MB_USE_RESERVED; -+ mb_flags |= EXT4_MB_USE_RESERVED; - err = ext4_ext_create_new_leaf(handle, inode, mb_flags, gb_flags, - ppath, newext); - if (err) -@@ -4438,6 +4440,8 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode, - ar.flags = 0; - if (flags & EXT4_GET_BLOCKS_NO_NORMALIZE) - ar.flags |= EXT4_MB_HINT_NOPREALLOC; -+ if (flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE) -+ ar.flags |= EXT4_MB_DELALLOC_RESERVED; - newblock = ext4_mb_new_blocks(handle, &ar, &err); - if (!newblock) - goto out2; -diff --git a/fs/ext4/indirect.c b/fs/ext4/indirect.c -index 69af0cd..36b3696 100644 ---- a/fs/ext4/indirect.c -+++ b/fs/ext4/indirect.c -@@ -333,7 +333,9 @@ static int ext4_alloc_branch(handle_t *handle, - new_blocks[i] = ext4_mb_new_blocks(handle, ar, &err); - } else - ar->goal = new_blocks[i] = ext4_new_meta_blocks(handle, -- ar->inode, ar->goal, 0, NULL, &err); -+ ar->inode, ar->goal, -+ ar->flags & EXT4_MB_DELALLOC_RESERVED, -+ NULL, &err); - if (err) { - i--; - goto failed; -@@ -572,6 +574,8 @@ int ext4_ind_map_blocks(handle_t *handle, struct inode *inode, - ar.logical = map->m_lblk; - if (S_ISREG(inode->i_mode)) - ar.flags = EXT4_MB_HINT_DATA; -+ if (flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE) -+ ar.flags |= EXT4_MB_DELALLOC_RESERVED; - - ar.goal = ext4_find_goal(inode, map->m_lblk, partial); - -diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c -index 8b0f9ef..15dffda 100644 ---- a/fs/ext4/mballoc.c -+++ b/fs/ext4/mballoc.c -@@ -4415,9 +4415,12 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle, - * EDQUOT check, as blocks and quotas have been already - * reserved when data being copied into pagecache. - */ -- if (ext4_test_inode_state(ar->inode, EXT4_STATE_DELALLOC_RESERVED)) -+ if (ext4_test_inode_state(ar->inode, EXT4_STATE_DELALLOC_RESERVED)) { -+ WARN_ON((ar->flags & EXT4_MB_DELALLOC_RESERVED) == 0); - ar->flags |= EXT4_MB_DELALLOC_RESERVED; -- else { -+ } -+ -+ if ((ar->flags & EXT4_MB_DELALLOC_RESERVED) == 0) { - /* Without delayed allocation we need to verify - * there is enough free blocks to do block allocation - * and verify allocation doesn't exceed the quota limits. -@@ -4528,8 +4531,7 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle, - if (inquota && ar->len < inquota) - dquot_free_block(ar->inode, EXT4_C2B(sbi, inquota - ar->len)); - if (!ar->len) { -- if (!ext4_test_inode_state(ar->inode, -- EXT4_STATE_DELALLOC_RESERVED)) -+ if ((ar->flags & EXT4_MB_DELALLOC_RESERVED) == 0) - /* release all the reserved blocks if non delalloc */ - percpu_counter_sub(&sbi->s_dirtyclusters_counter, - reserv_clstrs); -diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c -index e738733..da4df70 100644 ---- a/fs/ext4/xattr.c -+++ b/fs/ext4/xattr.c -@@ -899,14 +899,8 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode, - if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) - goal = goal & EXT4_MAX_BLOCK_FILE_PHYS; - -- /* -- * take i_data_sem because we will test -- * i_delalloc_reserved_flag in ext4_mb_new_blocks -- */ -- down_read(&EXT4_I(inode)->i_data_sem); - block = ext4_new_meta_blocks(handle, inode, goal, 0, - NULL, &error); -- up_read((&EXT4_I(inode)->i_data_sem)); - if (error) - goto cleanup; - --- -2.7.4 - -From 2e81a4eeedcaa66e35f58b81e0755b87057ce392 Mon Sep 17 00:00:00 2001 -From: Jan Kara -Date: Thu, 11 Aug 2016 12:38:55 -0400 -Subject: [PATCH] ext4: avoid deadlock when expanding inode size - -When we need to move xattrs into external xattr block, we call -ext4_xattr_block_set() from ext4_expand_extra_isize_ea(). That may end -up calling ext4_mark_inode_dirty() again which will recurse back into -the inode expansion code leading to deadlocks. - -Protect from recursion using EXT4_STATE_NO_EXPAND inode flag and move -its management into ext4_expand_extra_isize_ea() since its manipulation -is safe there (due to xattr_sem) from possible races with -ext4_xattr_set_handle() which plays with it as well. - -CC: stable@vger.kernel.org # 4.4.x -Signed-off-by: Jan Kara -Signed-off-by: Theodore Ts'o ---- - fs/ext4/inode.c | 2 -- - fs/ext4/xattr.c | 19 +++++++++++++------ - 2 files changed, 13 insertions(+), 8 deletions(-) - -diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c -index 5a6277d..13c95b2 100644 ---- a/fs/ext4/inode.c -+++ b/fs/ext4/inode.c -@@ -5466,8 +5466,6 @@ int ext4_mark_inode_dirty(handle_t *handle, struct inode *inode) - sbi->s_want_extra_isize, - iloc, handle); - if (ret) { -- ext4_set_inode_state(inode, -- EXT4_STATE_NO_EXPAND); - if (mnt_count != - le16_to_cpu(sbi->s_es->s_mnt_count)) { - ext4_warning(inode->i_sb, -diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c -index c893f00..2eb935c 100644 ---- a/fs/ext4/xattr.c -+++ b/fs/ext4/xattr.c -@@ -1358,11 +1358,13 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize, - int isize_diff; /* How much do we need to grow i_extra_isize */ - - down_write(&EXT4_I(inode)->xattr_sem); -+ /* -+ * Set EXT4_STATE_NO_EXPAND to avoid recursion when marking inode dirty -+ */ -+ ext4_set_inode_state(inode, EXT4_STATE_NO_EXPAND); - retry: -- if (EXT4_I(inode)->i_extra_isize >= new_extra_isize) { -- up_write(&EXT4_I(inode)->xattr_sem); -- return 0; -- } -+ if (EXT4_I(inode)->i_extra_isize >= new_extra_isize) -+ goto out; - - header = IHDR(inode, raw_inode); - entry = IFIRST(header); -@@ -1392,8 +1394,7 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize, - (void *)header, total_ino, - inode->i_sb->s_blocksize); - EXT4_I(inode)->i_extra_isize = new_extra_isize; -- error = 0; -- goto cleanup; -+ goto out; - } - - /* -@@ -1553,6 +1554,8 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize, - kfree(bs); - } - brelse(bh); -+out: -+ ext4_clear_inode_state(inode, EXT4_STATE_NO_EXPAND); - up_write(&EXT4_I(inode)->xattr_sem); - return 0; - -@@ -1564,6 +1567,10 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize, - kfree(is); - kfree(bs); - brelse(bh); -+ /* -+ * We deliberately leave EXT4_STATE_NO_EXPAND set here since inode -+ * size expansion failed. -+ */ - up_write(&EXT4_I(inode)->xattr_sem); - return error; - } --- -2.7.4 - diff --git a/ldiskfs/kernel_patches/patches/rhel7.3/ext4-corrupted-inode-block-bitmaps-handling-patches.patch b/ldiskfs/kernel_patches/patches/rhel7.3/ext4-corrupted-inode-block-bitmaps-handling-patches.patch deleted file mode 100644 index 60f63c5..0000000 --- a/ldiskfs/kernel_patches/patches/rhel7.3/ext4-corrupted-inode-block-bitmaps-handling-patches.patch +++ /dev/null @@ -1,464 +0,0 @@ -Since we could skip corrupt block groups, this patch -use ext4_warning() intead of ext4_error() to make FS not -emount RO in default, also fix a leftover from upstream -commit 163a203ddb36c36d4a1c942 ---- -Index: linux-stage/fs/ext4/balloc.c -=================================================================== ---- linux-stage.orig/fs/ext4/balloc.c -+++ linux-stage/fs/ext4/balloc.c -@@ -185,25 +185,17 @@ static int ext4_init_block_bitmap(struct - struct ext4_sb_info *sbi = EXT4_SB(sb); - ext4_fsblk_t start, tmp; - int flex_bg = 0; -- struct ext4_group_info *grp; - - J_ASSERT_BH(bh, buffer_locked(bh)); - - /* If checksum is bad mark all blocks used to prevent allocation - * essentially implementing a per-group read-only flag. */ - if (!ext4_group_desc_csum_verify(sb, block_group, gdp)) { -- grp = ext4_get_group_info(sb, block_group); -- if (!EXT4_MB_GRP_BBITMAP_CORRUPT(grp)) -- percpu_counter_sub(&sbi->s_freeclusters_counter, -- grp->bb_free); -- set_bit(EXT4_GROUP_INFO_BBITMAP_CORRUPT_BIT, &grp->bb_state); -- if (!EXT4_MB_GRP_IBITMAP_CORRUPT(grp)) { -- int count; -- count = ext4_free_inodes_count(sb, gdp); -- percpu_counter_sub(&sbi->s_freeinodes_counter, -- count); -- } -- set_bit(EXT4_GROUP_INFO_IBITMAP_CORRUPT_BIT, &grp->bb_state); -+ ext4_corrupted_block_group(sb, block_group, -+ EXT4_GROUP_INFO_BBITMAP_CORRUPT | -+ EXT4_GROUP_INFO_IBITMAP_CORRUPT, -+ "Checksum bad for group %u", -+ block_group); - return -EIO; - } - memset(bh->b_data, 0, sb->s_blocksize); -@@ -368,7 +360,6 @@ static void ext4_validate_block_bitmap(s - { - ext4_fsblk_t blk; - struct ext4_group_info *grp = ext4_get_group_info(sb, block_group); -- struct ext4_sb_info *sbi = EXT4_SB(sb); - - if (buffer_verified(bh) || EXT4_MB_GRP_BBITMAP_CORRUPT(grp)) - return; -@@ -377,22 +368,19 @@ static void ext4_validate_block_bitmap(s - blk = ext4_valid_block_bitmap(sb, desc, block_group, bh); - if (unlikely(blk != 0)) { - ext4_unlock_group(sb, block_group); -- ext4_error(sb, "bg %u: block %llu: invalid block bitmap", -- block_group, blk); -- if (!EXT4_MB_GRP_BBITMAP_CORRUPT(grp)) -- percpu_counter_sub(&sbi->s_freeclusters_counter, -- grp->bb_free); -- set_bit(EXT4_GROUP_INFO_BBITMAP_CORRUPT_BIT, &grp->bb_state); -+ ext4_corrupted_block_group(sb, block_group, -+ EXT4_GROUP_INFO_BBITMAP_CORRUPT, -+ "bg %u: block %llu: invalid block bitmap", -+ block_group, blk); - return; - } - if (unlikely(!ext4_block_bitmap_csum_verify(sb, block_group, - desc, bh))) { - ext4_unlock_group(sb, block_group); -- ext4_error(sb, "bg %u: bad block bitmap checksum", block_group); -- if (!EXT4_MB_GRP_BBITMAP_CORRUPT(grp)) -- percpu_counter_sub(&sbi->s_freeclusters_counter, -- grp->bb_free); -- set_bit(EXT4_GROUP_INFO_BBITMAP_CORRUPT_BIT, &grp->bb_state); -+ ext4_corrupted_block_group(sb, block_group, -+ EXT4_GROUP_INFO_BBITMAP_CORRUPT, -+ "bg %u: bad block bitmap checksum", -+ block_group); - return; - } - set_buffer_verified(bh); -@@ -445,8 +433,6 @@ ext4_read_block_bitmap_nowait(struct sup - set_buffer_uptodate(bh); - ext4_unlock_group(sb, block_group); - unlock_buffer(bh); -- if (err) -- ext4_error(sb, "Checksum bad for grp %u", block_group); - goto verify; - } - ext4_unlock_group(sb, block_group); -Index: linux-stage/fs/ext4/ext4.h -=================================================================== ---- linux-stage.orig/fs/ext4/ext4.h -+++ linux-stage/fs/ext4/ext4.h -@@ -91,6 +91,17 @@ typedef __u32 ext4_lblk_t; - /* data type for block group number */ - typedef unsigned int ext4_group_t; - -+void __ext4_corrupted_block_group(struct super_block *sb, -+ ext4_group_t group, unsigned int flags, -+ const char *function, unsigned int line); -+ -+#define ext4_corrupted_block_group(sb, group, flags, fmt, ...) \ -+ do { \ -+ __ext4_warning(sb, __func__, __LINE__, fmt, \ -+ ##__VA_ARGS__); \ -+ __ext4_corrupted_block_group(sb, group, flags, \ -+ __func__, __LINE__); \ -+ } while (0) - /* - * Flags used in mballoc's allocation_context flags field. - * -@@ -2676,7 +2687,11 @@ struct ext4_group_info { - #define EXT4_GROUP_INFO_NEED_INIT_BIT 0 - #define EXT4_GROUP_INFO_WAS_TRIMMED_BIT 1 - #define EXT4_GROUP_INFO_BBITMAP_CORRUPT_BIT 2 -+#define EXT4_GROUP_INFO_BBITMAP_CORRUPT \ -+ (1 << EXT4_GROUP_INFO_BBITMAP_CORRUPT_BIT) - #define EXT4_GROUP_INFO_IBITMAP_CORRUPT_BIT 3 -+#define EXT4_GROUP_INFO_IBITMAP_CORRUPT \ -+ (1 << EXT4_GROUP_INFO_IBITMAP_CORRUPT_BIT) - - #define EXT4_MB_GRP_NEED_INIT(grp) \ - (test_bit(EXT4_GROUP_INFO_NEED_INIT_BIT, &((grp)->bb_state))) -Index: linux-stage/fs/ext4/ialloc.c -=================================================================== ---- linux-stage.orig/fs/ext4/ialloc.c -+++ linux-stage/fs/ext4/ialloc.c -@@ -70,26 +70,15 @@ static unsigned ext4_init_inode_bitmap(s - ext4_group_t block_group, - struct ext4_group_desc *gdp) - { -- struct ext4_group_info *grp; -- struct ext4_sb_info *sbi = EXT4_SB(sb); - J_ASSERT_BH(bh, buffer_locked(bh)); - - /* If checksum is bad mark all blocks and inodes use to prevent - * allocation, essentially implementing a per-group read-only flag. */ - if (!ext4_group_desc_csum_verify(sb, block_group, gdp)) { -- ext4_error(sb, "Checksum bad for group %u", block_group); -- grp = ext4_get_group_info(sb, block_group); -- if (!EXT4_MB_GRP_BBITMAP_CORRUPT(grp)) -- percpu_counter_sub(&sbi->s_freeclusters_counter, -- grp->bb_free); -- set_bit(EXT4_GROUP_INFO_BBITMAP_CORRUPT_BIT, &grp->bb_state); -- if (!EXT4_MB_GRP_IBITMAP_CORRUPT(grp)) { -- int count; -- count = ext4_free_inodes_count(sb, gdp); -- percpu_counter_sub(&sbi->s_freeinodes_counter, -- count); -- } -- set_bit(EXT4_GROUP_INFO_IBITMAP_CORRUPT_BIT, &grp->bb_state); -+ ext4_corrupted_block_group(sb, block_group, -+ EXT4_GROUP_INFO_BBITMAP_CORRUPT | -+ EXT4_GROUP_INFO_IBITMAP_CORRUPT, -+ "Checksum bad for group %u", block_group); - return 0; - } - -@@ -125,8 +114,6 @@ ext4_read_inode_bitmap(struct super_bloc - struct ext4_group_desc *desc; - struct buffer_head *bh = NULL; - ext4_fsblk_t bitmap_blk; -- struct ext4_group_info *grp; -- struct ext4_sb_info *sbi = EXT4_SB(sb); - - desc = ext4_get_group_desc(sb, block_group, NULL); - if (!desc) -@@ -193,16 +180,10 @@ verify: - EXT4_INODES_PER_GROUP(sb) / 8)) { - ext4_unlock_group(sb, block_group); - put_bh(bh); -- ext4_error(sb, "Corrupt inode bitmap - block_group = %u, " -- "inode_bitmap = %llu", block_group, bitmap_blk); -- grp = ext4_get_group_info(sb, block_group); -- if (!EXT4_MB_GRP_IBITMAP_CORRUPT(grp)) { -- int count; -- count = ext4_free_inodes_count(sb, desc); -- percpu_counter_sub(&sbi->s_freeinodes_counter, -- count); -- } -- set_bit(EXT4_GROUP_INFO_IBITMAP_CORRUPT_BIT, &grp->bb_state); -+ ext4_corrupted_block_group(sb, block_group, -+ EXT4_GROUP_INFO_IBITMAP_CORRUPT, -+ "Corrupt inode bitmap - block_group = %u, inode_bitmap = %llu", -+ block_group, bitmap_blk); - return NULL; - } - ext4_unlock_group(sb, block_group); -@@ -337,14 +318,9 @@ out: - if (!fatal) - fatal = err; - } else { -- ext4_error(sb, "bit already cleared for inode %lu", ino); -- if (gdp && !EXT4_MB_GRP_IBITMAP_CORRUPT(grp)) { -- int count; -- count = ext4_free_inodes_count(sb, gdp); -- percpu_counter_sub(&sbi->s_freeinodes_counter, -- count); -- } -- set_bit(EXT4_GROUP_INFO_IBITMAP_CORRUPT_BIT, &grp->bb_state); -+ ext4_corrupted_block_group(sb, block_group, -+ EXT4_GROUP_INFO_IBITMAP_CORRUPT, -+ "bit already cleared for inode %lu", ino); - } - - error_return: -Index: linux-stage/fs/ext4/mballoc.c -=================================================================== ---- linux-stage.orig/fs/ext4/mballoc.c -+++ linux-stage/fs/ext4/mballoc.c -@@ -752,10 +752,18 @@ int ext4_mb_generate_buddy(struct super_ - if (free != grp->bb_free) { - struct ext4_group_desc *gdp; - gdp = ext4_get_group_desc(sb, group, NULL); -- ext4_error(sb, "group %lu: %u blocks in bitmap, %u in bb, " -- "%u in gd, %lu pa's\n", (long unsigned int)group, -- free, grp->bb_free, ext4_free_group_clusters(sb, gdp), -- grp->bb_prealloc_nr); -+ -+ ext4_corrupted_block_group(sb, group, -+ EXT4_GROUP_INFO_BBITMAP_CORRUPT, -+ "group %lu: %u blocks in bitmap, %u in bb, %u in gd, %lu pa's block bitmap corrupt", -+ (unsigned long int)group, free, grp->bb_free, -+ ext4_free_group_clusters(sb, gdp), -+ grp->bb_prealloc_nr); -+ /* -+ * If we intend to continue, we consider group descriptor -+ * corrupt and update bb_free using bitmap value -+ */ -+ grp->bb_free = free; - return -EIO; - } - mb_set_largest_free_order(sb, grp); -@@ -1101,7 +1109,7 @@ ext4_mb_load_buddy(struct super_block *s - int block; - int pnum; - int poff; -- struct page *page; -+ struct page *page = NULL; - int ret; - struct ext4_group_info *grp; - struct ext4_sb_info *sbi = EXT4_SB(sb); -@@ -1127,7 +1135,7 @@ ext4_mb_load_buddy(struct super_block *s - */ - ret = ext4_mb_init_group(sb, group); - if (ret) -- return ret; -+ goto err; - } - - /* -@@ -1227,6 +1235,7 @@ err: - page_cache_release(e4b->bd_buddy_page); - e4b->bd_buddy = NULL; - e4b->bd_bitmap = NULL; -+ ext4_warning(sb, "Error loading buddy information for %u", group); - return ret; - } - -@@ -3598,9 +3607,11 @@ int ext4_mb_check_ondisk_bitmap(struct s - } - - if (free != free_in_gdp) { -- ext4_error(sb, "on-disk bitmap for group %d" -- "corrupted: %u blocks free in bitmap, %u - in gd\n", -- group, free, free_in_gdp); -+ ext4_corrupted_block_group(sb, group, -+ EXT4_GROUP_INFO_BBITMAP_CORRUPT, -+ "on-disk bitmap for group %d corrupted: %u blocks free in bitmap, %u - in gd\n", -+ group, free, -+ free_in_gdp); - return -EIO; - } - return 0; -@@ -3961,16 +3972,8 @@ ext4_mb_release_inode_pa(struct ext4_bud - /* "free < pa->pa_free" means we maybe double alloc the same blocks, - * otherwise maybe leave some free blocks unavailable, no need to BUG.*/ - if ((free > pa->pa_free && !pa->pa_error) || (free < pa->pa_free)) { -- ext4_error(sb, "pa free mismatch: [pa %p] " -- "[phy %lu] [logic %lu] [len %u] [free %u] " -- "[error %u] [inode %lu] [freed %u]", pa, -- (unsigned long)pa->pa_pstart, -- (unsigned long)pa->pa_lstart, -- (unsigned)pa->pa_len, (unsigned)pa->pa_free, -- (unsigned)pa->pa_error, pa->pa_inode->i_ino, -- free); - ext4_grp_locked_error(sb, group, 0, 0, "free %u, pa_free %u", -- free, pa->pa_free); -+ free, pa->pa_free); - /* - * pa is already deleted so we use the value obtained - * from the bitmap and continue. -@@ -4030,14 +4033,11 @@ ext4_mb_discard_group_preallocations(str - return 0; - - bitmap_bh = ext4_read_block_bitmap(sb, group); -- if (bitmap_bh == NULL) { -- ext4_error(sb, "Error reading block bitmap for %u", group); -+ if (bitmap_bh == NULL) - return 0; -- } - - err = ext4_mb_load_buddy(sb, group, &e4b); - if (err) { -- ext4_error(sb, "Error loading buddy information for %u", group); - put_bh(bitmap_bh); - return 0; - } -@@ -4197,16 +4197,11 @@ repeat: - group = ext4_get_group_number(sb, pa->pa_pstart); - - err = ext4_mb_load_buddy(sb, group, &e4b); -- if (err) { -- ext4_error(sb, "Error loading buddy information for %u", -- group); -+ if (err) - return; -- } - - bitmap_bh = ext4_read_block_bitmap(sb, group); - if (bitmap_bh == NULL) { -- ext4_error(sb, "Error reading block bitmap for %u", -- group); - ext4_mb_unload_buddy(&e4b); - continue; - } -@@ -4466,11 +4461,8 @@ ext4_mb_discard_lg_preallocations(struct - list_for_each_entry_safe(pa, tmp, &discard_list, u.pa_tmp_list) { - - group = ext4_get_group_number(sb, pa->pa_pstart); -- if (ext4_mb_load_buddy(sb, group, &e4b)) { -- ext4_error(sb, "Error loading buddy information for %u", -- group); -+ if (ext4_mb_load_buddy(sb, group, &e4b)) - continue; -- } - ext4_lock_group(sb, group); - list_del(&pa->pa_group_list); - ext4_get_group_info(sb, group)->bb_prealloc_nr--; -@@ -4741,17 +4733,18 @@ errout: - * been updated or not when fail case. So can - * not revert pa_free back, just mark pa_error*/ - pa->pa_error++; -- ext4_error(sb, -- "Updating bitmap error: [err %d] " -- "[pa %p] [phy %lu] [logic %lu] " -- "[len %u] [free %u] [error %u] " -- "[inode %lu]", *errp, pa, -- (unsigned long)pa->pa_pstart, -- (unsigned long)pa->pa_lstart, -- (unsigned)pa->pa_len, -- (unsigned)pa->pa_free, -- (unsigned)pa->pa_error, -- pa->pa_inode ? pa->pa_inode->i_ino : 0); -+ ext4_corrupted_block_group(sb, 0, 0, -+ "Updating bitmap error: [err %d] " -+ "[pa %p] [phy %lu] [logic %lu] " -+ "[len %u] [free %u] [error %u] " -+ "[inode %lu]", *errp, pa, -+ (unsigned long)pa->pa_pstart, -+ (unsigned long)pa->pa_lstart, -+ (unsigned)pa->pa_len, -+ (unsigned)pa->pa_free, -+ (unsigned)pa->pa_error, -+ pa->pa_inode ? -+ pa->pa_inode->i_ino : 0); - } - } - ext4_mb_release_context(ac); -@@ -5036,7 +5029,7 @@ do_more: - - err = ext4_mb_load_buddy(sb, block_group, &e4b); - if (err) -- goto error_return; -+ goto error_brelse; - - if ((flags & EXT4_FREE_BLOCKS_METADATA) && ext4_handle_valid(handle)) { - struct ext4_free_data *new_entry; -@@ -5118,8 +5111,9 @@ do_more: - goto do_more; - } - error_return: -- brelse(bitmap_bh); - ext4_std_error(sb, err); -+error_brelse: -+ brelse(bitmap_bh); - return; - } - -@@ -5215,7 +5209,7 @@ int ext4_group_add_blocks(handle_t *hand - - err = ext4_mb_load_buddy(sb, block_group, &e4b); - if (err) -- goto error_return; -+ goto error_brelse; - - /* - * need to update group_info->bb_free and bitmap -@@ -5252,8 +5246,9 @@ int ext4_group_add_blocks(handle_t *hand - err = ret; - - error_return: -- brelse(bitmap_bh); - ext4_std_error(sb, err); -+error_brelse: -+ brelse(bitmap_bh); - return err; - } - -@@ -5328,11 +5323,9 @@ ext4_trim_all_free(struct super_block *s - trace_ext4_trim_all_free(sb, group, start, max); - - ret = ext4_mb_load_buddy(sb, group, &e4b); -- if (ret) { -- ext4_error(sb, "Error in loading buddy " -- "information for %u", group); -+ if (ret) - return ret; -- } -+ - bitmap = e4b.bd_bitmap; - - ext4_lock_group(sb, group); -Index: linux-stage/fs/ext4/super.c -=================================================================== ---- linux-stage.orig/fs/ext4/super.c -+++ linux-stage/fs/ext4/super.c -@@ -633,6 +633,37 @@ void __ext4_warning(struct super_block * - va_end(args); - } - -+void __ext4_corrupted_block_group(struct super_block *sb, ext4_group_t group, -+ unsigned int flags, const char *function, -+ unsigned int line) -+{ -+ struct ext4_sb_info *sbi = EXT4_SB(sb); -+ struct ext4_group_info *grp = ext4_get_group_info(sb, group); -+ struct ext4_group_desc *gdp = ext4_get_group_desc(sb, group, NULL); -+ -+ if (flags & EXT4_GROUP_INFO_BBITMAP_CORRUPT && -+ !EXT4_MB_GRP_BBITMAP_CORRUPT(grp)) { -+ percpu_counter_sub(&sbi->s_freeclusters_counter, -+ grp->bb_free); -+ set_bit(EXT4_GROUP_INFO_BBITMAP_CORRUPT_BIT, -+ &grp->bb_state); -+ } -+ -+ if (flags & EXT4_GROUP_INFO_IBITMAP_CORRUPT && -+ !EXT4_MB_GRP_IBITMAP_CORRUPT(grp)) { -+ if (gdp) { -+ int count; -+ -+ count = ext4_free_inodes_count(sb, gdp); -+ percpu_counter_sub(&sbi->s_freeinodes_counter, -+ count); -+ } -+ set_bit(EXT4_GROUP_INFO_IBITMAP_CORRUPT_BIT, -+ &grp->bb_state); -+ } -+ save_error_info(sb, function, line); -+} -+ - void __ext4_grp_locked_error(const char *function, unsigned int line, - struct super_block *sb, ext4_group_t grp, - unsigned long ino, ext4_fsblk_t block, diff --git a/ldiskfs/kernel_patches/patches/rhel7.4/ext4-dont-check-before-replay.patch b/ldiskfs/kernel_patches/patches/rhel7.4/ext4-dont-check-before-replay.patch deleted file mode 100644 index e1d41d7..0000000 --- a/ldiskfs/kernel_patches/patches/rhel7.4/ext4-dont-check-before-replay.patch +++ /dev/null @@ -1,33 +0,0 @@ -Index: linux-stage/fs/ext4/super.c -When ldiskfs run in failover mode whith read-only disk. -Part of allocation updates are lost and ldiskfs may fail -while mounting this is due to inconsistent state of -group-descriptor. Group-descriptor check is added after -journal replay. -=================================================================== ---- linux-stage/fs/ext4/super.c 2016-11-06 15:15:30.892386878 +0530 -+++ linux-stage.orig.1/fs/ext4/super.c 2016-11-08 10:56:45.579892189 +0530 -@@ -3980,10 +3980,6 @@ - goto failed_mount2; - } - } -- if (!ext4_check_descriptors(sb, logical_sb_block, &first_not_zeroed)) { -- ext4_msg(sb, KERN_ERR, "group descriptors corrupted!"); -- goto failed_mount2; -- } - - sbi->s_gdb_count = db_count; - get_random_bytes(&sbi->s_next_generation, sizeof(u32)); -@@ -4104,6 +4100,12 @@ - sbi->s_journal->j_commit_callback = ext4_journal_commit_callback; - - no_journal: -+ -+ if (!ext4_check_descriptors(sb, logical_sb_block, &first_not_zeroed)) { -+ ext4_msg(sb, KERN_ERR, "group descriptors corrupted!"); -+ goto failed_mount_wq; -+ } -+ - /* - * Get the # of file system overhead blocks from the - * superblock if present. diff --git a/ldiskfs/kernel_patches/patches/rhel7.4/ext4-remove-i_data_sem-from-xattr.patch b/ldiskfs/kernel_patches/patches/rhel7.4/ext4-remove-i_data_sem-from-xattr.patch deleted file mode 100644 index 0a84192..0000000 --- a/ldiskfs/kernel_patches/patches/rhel7.4/ext4-remove-i_data_sem-from-xattr.patch +++ /dev/null @@ -1,363 +0,0 @@ -From a521100231f816f8cdd9c8e77da14ff1e42c2b17 Mon Sep 17 00:00:00 2001 -From: Theodore Ts'o -Date: Thu, 4 Sep 2014 18:06:25 -0400 -Subject: [PATCH] ext4: pass allocation_request struct to - ext4_(alloc,splice)_branch - -Instead of initializing the allocation_request structure in -ext4_alloc_branch(), set it up in ext4_ind_map_blocks(), and then pass -it to ext4_alloc_branch() and ext4_splice_branch(). - -This allows ext4_ind_map_blocks to pass flags in the allocation -request structure without having to add Yet Another argument to -ext4_alloc_branch(). - -Signed-off-by: Theodore Ts'o -Reviewed-by: Jan Kara ---- - fs/ext4/indirect.c | 82 +++++++++++++++++++++++++----------------------------- - 1 file changed, 38 insertions(+), 44 deletions(-) - -diff --git a/fs/ext4/indirect.c b/fs/ext4/indirect.c -index e75f840..69af0cd 100644 ---- a/fs/ext4/indirect.c -+++ b/fs/ext4/indirect.c -@@ -318,34 +318,22 @@ static int ext4_blks_to_allocate(Indirect *branch, int k, unsigned int blks, - * ext4_alloc_block() (normally -ENOSPC). Otherwise we set the chain - * as described above and return 0. - */ --static int ext4_alloc_branch(handle_t *handle, struct inode *inode, -- ext4_lblk_t iblock, int indirect_blks, -- int *blks, ext4_fsblk_t goal, -- ext4_lblk_t *offsets, Indirect *branch) -+static int ext4_alloc_branch(handle_t *handle, -+ struct ext4_allocation_request *ar, -+ int indirect_blks, ext4_lblk_t *offsets, -+ Indirect *branch) - { -- struct ext4_allocation_request ar; - struct buffer_head * bh; - ext4_fsblk_t b, new_blocks[4]; - __le32 *p; - int i, j, err, len = 1; - -- /* -- * Set up for the direct block allocation -- */ -- memset(&ar, 0, sizeof(ar)); -- ar.inode = inode; -- ar.len = *blks; -- ar.logical = iblock; -- if (S_ISREG(inode->i_mode)) -- ar.flags = EXT4_MB_HINT_DATA; -- - for (i = 0; i <= indirect_blks; i++) { - if (i == indirect_blks) { -- ar.goal = goal; -- new_blocks[i] = ext4_mb_new_blocks(handle, &ar, &err); -+ new_blocks[i] = ext4_mb_new_blocks(handle, ar, &err); - } else -- goal = new_blocks[i] = ext4_new_meta_blocks(handle, inode, -- goal, 0, NULL, &err); -+ ar->goal = new_blocks[i] = ext4_new_meta_blocks(handle, -+ ar->inode, ar->goal, 0, NULL, &err); - if (err) { - i--; - goto failed; -@@ -354,7 +342,7 @@ static int ext4_alloc_branch(handle_t *handle, struct inode *inode, - if (i == 0) - continue; - -- bh = branch[i].bh = sb_getblk(inode->i_sb, new_blocks[i-1]); -+ bh = branch[i].bh = sb_getblk(ar->inode->i_sb, new_blocks[i-1]); - if (unlikely(!bh)) { - err = -ENOMEM; - goto failed; -@@ -372,7 +360,7 @@ static int ext4_alloc_branch(handle_t *handle, struct inode *inode, - b = new_blocks[i]; - - if (i == indirect_blks) -- len = ar.len; -+ len = ar->len; - for (j = 0; j < len; j++) - *p++ = cpu_to_le32(b++); - -@@ -381,11 +369,10 @@ static int ext4_alloc_branch(handle_t *handle, struct inode *inode, - unlock_buffer(bh); - - BUFFER_TRACE(bh, "call ext4_handle_dirty_metadata"); -- err = ext4_handle_dirty_metadata(handle, inode, bh); -+ err = ext4_handle_dirty_metadata(handle, ar->inode, bh); - if (err) - goto failed; - } -- *blks = ar.len; - return 0; - failed: - for (; i >= 0; i--) { -@@ -396,10 +383,10 @@ static int ext4_alloc_branch(handle_t *handle, struct inode *inode, - * existing before ext4_alloc_branch() was called. - */ - if (i > 0 && i != indirect_blks && branch[i].bh) -- ext4_forget(handle, 1, inode, branch[i].bh, -+ ext4_forget(handle, 1, ar->inode, branch[i].bh, - branch[i].bh->b_blocknr); -- ext4_free_blocks(handle, inode, NULL, new_blocks[i], -- (i == indirect_blks) ? ar.len : 1, 0); -+ ext4_free_blocks(handle, ar->inode, NULL, new_blocks[i], -+ (i == indirect_blks) ? ar->len : 1, 0); - } - return err; - } -@@ -419,9 +406,9 @@ static int ext4_alloc_branch(handle_t *handle, struct inode *inode, - * inode (->i_blocks, etc.). In case of success we end up with the full - * chain to new block and return 0. - */ --static int ext4_splice_branch(handle_t *handle, struct inode *inode, -- ext4_lblk_t block, Indirect *where, int num, -- int blks) -+static int ext4_splice_branch(handle_t *handle, -+ struct ext4_allocation_request *ar, -+ Indirect *where, int num) - { - int i; - int err = 0; -@@ -446,9 +433,9 @@ static int ext4_splice_branch(handle_t *handle, struct inode *inode, - * Update the host buffer_head or inode to point to more just allocated - * direct blocks blocks - */ -- if (num == 0 && blks > 1) { -+ if (num == 0 && ar->len > 1) { - current_block = le32_to_cpu(where->key) + 1; -- for (i = 1; i < blks; i++) -+ for (i = 1; i < ar->len; i++) - *(where->p + i) = cpu_to_le32(current_block++); - } - -@@ -465,14 +452,14 @@ static int ext4_splice_branch(handle_t *handle, struct inode *inode, - */ - jbd_debug(5, "splicing indirect only\n"); - BUFFER_TRACE(where->bh, "call ext4_handle_dirty_metadata"); -- err = ext4_handle_dirty_metadata(handle, inode, where->bh); -+ err = ext4_handle_dirty_metadata(handle, ar->inode, where->bh); - if (err) - goto err_out; - } else { - /* - * OK, we spliced it into the inode itself on a direct block. - */ -- ext4_mark_inode_dirty(handle, inode); -+ ext4_mark_inode_dirty(handle, ar->inode); - jbd_debug(5, "splicing direct\n"); - } - return err; -@@ -484,11 +471,11 @@ static int ext4_splice_branch(handle_t *handle, struct inode *inode, - * need to revoke the block, which is why we don't - * need to set EXT4_FREE_BLOCKS_METADATA. - */ -- ext4_free_blocks(handle, inode, where[i].bh, 0, 1, -+ ext4_free_blocks(handle, ar->inode, where[i].bh, 0, 1, - EXT4_FREE_BLOCKS_FORGET); - } -- ext4_free_blocks(handle, inode, NULL, le32_to_cpu(where[num].key), -- blks, 0); -+ ext4_free_blocks(handle, ar->inode, NULL, le32_to_cpu(where[num].key), -+ ar->len, 0); - - return err; - } -@@ -525,11 +512,11 @@ int ext4_ind_map_blocks(handle_t *handle, struct inode *inode, - struct ext4_map_blocks *map, - int flags) - { -+ struct ext4_allocation_request ar; - int err = -EIO; - ext4_lblk_t offsets[4]; - Indirect chain[4]; - Indirect *partial; -- ext4_fsblk_t goal; - int indirect_blks; - int blocks_to_boundary = 0; - int depth; -@@ -579,7 +566,14 @@ int ext4_ind_map_blocks(handle_t *handle, struct inode *inode, - return -ENOSPC; - } - -- goal = ext4_find_goal(inode, map->m_lblk, partial); -+ /* Set up for the direct block allocation */ -+ memset(&ar, 0, sizeof(ar)); -+ ar.inode = inode; -+ ar.logical = map->m_lblk; -+ if (S_ISREG(inode->i_mode)) -+ ar.flags = EXT4_MB_HINT_DATA; -+ -+ ar.goal = ext4_find_goal(inode, map->m_lblk, partial); - - /* the number of blocks need to allocate for [d,t]indirect blocks */ - indirect_blks = (chain + depth) - partial - 1; -@@ -588,13 +582,13 @@ int ext4_ind_map_blocks(handle_t *handle, struct inode *inode, - * Next look up the indirect map to count the totoal number of - * direct blocks to allocate for this branch. - */ -- count = ext4_blks_to_allocate(partial, indirect_blks, -- map->m_len, blocks_to_boundary); -+ ar.len = ext4_blks_to_allocate(partial, indirect_blks, -+ map->m_len, blocks_to_boundary); -+ - /* - * Block out ext4_truncate while we alter the tree - */ -- err = ext4_alloc_branch(handle, inode, map->m_lblk, indirect_blks, -- &count, goal, -+ err = ext4_alloc_branch(handle, &ar, indirect_blks, - offsets + (partial - chain), partial); - - /* -@@ -605,14 +599,14 @@ int ext4_ind_map_blocks(handle_t *handle, struct inode *inode, - * may need to return -EAGAIN upwards in the worst case. --sct - */ - if (!err) -- err = ext4_splice_branch(handle, inode, map->m_lblk, -- partial, indirect_blks, count); -+ err = ext4_splice_branch(handle, &ar, partial, indirect_blks); - if (err) - goto cleanup; - - map->m_flags |= EXT4_MAP_NEW; - - ext4_update_inode_fsync_trans(handle, inode, 1); -+ count = ar.len; - got_it: - map->m_flags |= EXT4_MAP_MAPPED; - map->m_pblk = le32_to_cpu(chain[depth-1].key); --- -2.7.4 - -From e3cf5d5d9a86df1c5e413bdd3725c25a16ff854c Mon Sep 17 00:00:00 2001 -From: Theodore Ts'o -Date: Thu, 4 Sep 2014 18:07:25 -0400 -Subject: [PATCH] ext4: prepare to drop EXT4_STATE_DELALLOC_RESERVED - -The EXT4_STATE_DELALLOC_RESERVED flag was originally implemented -because it was too hard to make sure the mballoc and get_block flags -could be reliably passed down through all of the codepaths that end up -calling ext4_mb_new_blocks(). - -Since then, we have mb_flags passed down through most of the code -paths, so getting rid of EXT4_STATE_DELALLOC_RESERVED isn't as tricky -as it used to. - -This commit plumbs in the last of what is required, and then adds a -WARN_ON check to make sure we haven't missed anything. If this passes -a full regression test run, we can then drop -EXT4_STATE_DELALLOC_RESERVED. - -Signed-off-by: Theodore Ts'o -Reviewed-by: Jan Kara ---- - fs/ext4/balloc.c | 3 +-- - fs/ext4/extents.c | 6 +++++- - fs/ext4/indirect.c | 6 +++++- - fs/ext4/mballoc.c | 10 ++++++---- - 5 files changed, 17 insertions(+), 14 deletions(-) - -diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c -index 581ef40..d70f154 100644 ---- a/fs/ext4/balloc.c -+++ b/fs/ext4/balloc.c -@@ -636,8 +636,7 @@ ext4_fsblk_t ext4_new_meta_blocks(handle_t *handle, struct inode *inode, - * Account for the allocated meta blocks. We will never - * fail EDQUOT for metdata, but we do account for it. - */ -- if (!(*errp) && -- ext4_test_inode_state(inode, EXT4_STATE_DELALLOC_RESERVED)) { -+ if (!(*errp) && (flags & EXT4_MB_DELALLOC_RESERVED)) { - dquot_alloc_block_nofail(inode, - EXT4_C2B(EXT4_SB(inode->i_sb), ar.len)); - } -diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c -index 3ac1686..8170b32 100644 ---- a/fs/ext4/extents.c -+++ b/fs/ext4/extents.c -@@ -1933,6 +1933,8 @@ int ext4_ext_insert_extent(handle_t *handle, struct inode *inode, - ext4_lblk_t next; - int mb_flags = 0, unwritten; - -+ if (gb_flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE) -+ mb_flags |= EXT4_MB_DELALLOC_RESERVED; - if (unlikely(ext4_ext_get_actual_len(newext) == 0)) { - EXT4_ERROR_INODE(inode, "ext4_ext_get_actual_len(newext) == 0"); - return -EIO; -@@ -2054,7 +2056,7 @@ int ext4_ext_insert_extent(handle_t *handle, struct inode *inode, - * We're gonna add a new leaf in the tree. - */ - if (gb_flags & EXT4_GET_BLOCKS_METADATA_NOFAIL) -- mb_flags = EXT4_MB_USE_RESERVED; -+ mb_flags |= EXT4_MB_USE_RESERVED; - err = ext4_ext_create_new_leaf(handle, inode, mb_flags, gb_flags, - ppath, newext); - if (err) -@@ -4438,6 +4440,8 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode, - ar.flags = 0; - if (flags & EXT4_GET_BLOCKS_NO_NORMALIZE) - ar.flags |= EXT4_MB_HINT_NOPREALLOC; -+ if (flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE) -+ ar.flags |= EXT4_MB_DELALLOC_RESERVED; - newblock = ext4_mb_new_blocks(handle, &ar, &err); - if (!newblock) - goto out2; -diff --git a/fs/ext4/indirect.c b/fs/ext4/indirect.c -index 69af0cd..36b3696 100644 ---- a/fs/ext4/indirect.c -+++ b/fs/ext4/indirect.c -@@ -333,7 +333,9 @@ static int ext4_alloc_branch(handle_t *handle, - new_blocks[i] = ext4_mb_new_blocks(handle, ar, &err); - } else - ar->goal = new_blocks[i] = ext4_new_meta_blocks(handle, -- ar->inode, ar->goal, 0, NULL, &err); -+ ar->inode, ar->goal, -+ ar->flags & EXT4_MB_DELALLOC_RESERVED, -+ NULL, &err); - if (err) { - i--; - goto failed; -@@ -572,6 +574,8 @@ int ext4_ind_map_blocks(handle_t *handle, struct inode *inode, - ar.logical = map->m_lblk; - if (S_ISREG(inode->i_mode)) - ar.flags = EXT4_MB_HINT_DATA; -+ if (flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE) -+ ar.flags |= EXT4_MB_DELALLOC_RESERVED; - - ar.goal = ext4_find_goal(inode, map->m_lblk, partial); - -diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c -index 8b0f9ef..15dffda 100644 ---- a/fs/ext4/mballoc.c -+++ b/fs/ext4/mballoc.c -@@ -4415,9 +4415,12 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle, - * EDQUOT check, as blocks and quotas have been already - * reserved when data being copied into pagecache. - */ -- if (ext4_test_inode_state(ar->inode, EXT4_STATE_DELALLOC_RESERVED)) -+ if (ext4_test_inode_state(ar->inode, EXT4_STATE_DELALLOC_RESERVED)) { -+ WARN_ON((ar->flags & EXT4_MB_DELALLOC_RESERVED) == 0); - ar->flags |= EXT4_MB_DELALLOC_RESERVED; -- else { -+ } -+ -+ if ((ar->flags & EXT4_MB_DELALLOC_RESERVED) == 0) { - /* Without delayed allocation we need to verify - * there is enough free blocks to do block allocation - * and verify allocation doesn't exceed the quota limits. -@@ -4528,8 +4531,7 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle, - if (inquota && ar->len < inquota) - dquot_free_block(ar->inode, EXT4_C2B(sbi, inquota - ar->len)); - if (!ar->len) { -- if (!ext4_test_inode_state(ar->inode, -- EXT4_STATE_DELALLOC_RESERVED)) -+ if ((ar->flags & EXT4_MB_DELALLOC_RESERVED) == 0) - /* release all the reserved blocks if non delalloc */ - percpu_counter_sub(&sbi->s_dirtyclusters_counter, - reserv_clstrs); --- -2.7.4 diff --git a/ldiskfs/kernel_patches/patches/rhel7.4/ext4-attach-jinode-in-writepages.patch b/ldiskfs/kernel_patches/patches/rhel7.6/ext4-attach-jinode-in-writepages.patch similarity index 100% rename from ldiskfs/kernel_patches/patches/rhel7.4/ext4-attach-jinode-in-writepages.patch rename to ldiskfs/kernel_patches/patches/rhel7.6/ext4-attach-jinode-in-writepages.patch diff --git a/ldiskfs/kernel_patches/patches/rhel7/ext4-cleanup-goto-next-group.patch b/ldiskfs/kernel_patches/patches/rhel7.6/ext4-cleanup-goto-next-group.patch similarity index 100% rename from ldiskfs/kernel_patches/patches/rhel7/ext4-cleanup-goto-next-group.patch rename to ldiskfs/kernel_patches/patches/rhel7.6/ext4-cleanup-goto-next-group.patch diff --git a/ldiskfs/kernel_patches/patches/rhel7.3/ext4-data-in-dirent.patch b/ldiskfs/kernel_patches/patches/rhel7.6/ext4-data-in-dirent.patch similarity index 100% rename from ldiskfs/kernel_patches/patches/rhel7.3/ext4-data-in-dirent.patch rename to ldiskfs/kernel_patches/patches/rhel7.6/ext4-data-in-dirent.patch diff --git a/ldiskfs/kernel_patches/patches/rhel7.3/ext4-disable-mb-cache.patch b/ldiskfs/kernel_patches/patches/rhel7.6/ext4-disable-mb-cache.patch similarity index 100% rename from ldiskfs/kernel_patches/patches/rhel7.3/ext4-disable-mb-cache.patch rename to ldiskfs/kernel_patches/patches/rhel7.6/ext4-disable-mb-cache.patch diff --git a/ldiskfs/kernel_patches/patches/rhel6.3/ext4-dont-check-in-ro.patch b/ldiskfs/kernel_patches/patches/rhel7.6/ext4-dont-check-in-ro.patch similarity index 100% rename from ldiskfs/kernel_patches/patches/rhel6.3/ext4-dont-check-in-ro.patch rename to ldiskfs/kernel_patches/patches/rhel7.6/ext4-dont-check-in-ro.patch diff --git a/ldiskfs/kernel_patches/patches/rhel7.2/ext4-export-mb-stream-allocator-variables.patch b/ldiskfs/kernel_patches/patches/rhel7.6/ext4-export-mb-stream-allocator-variables.patch similarity index 100% rename from ldiskfs/kernel_patches/patches/rhel7.2/ext4-export-mb-stream-allocator-variables.patch rename to ldiskfs/kernel_patches/patches/rhel7.6/ext4-export-mb-stream-allocator-variables.patch diff --git a/ldiskfs/kernel_patches/patches/rhel7/ext4-export-orphan-add.patch b/ldiskfs/kernel_patches/patches/rhel7.6/ext4-export-orphan-add.patch similarity index 100% rename from ldiskfs/kernel_patches/patches/rhel7/ext4-export-orphan-add.patch rename to ldiskfs/kernel_patches/patches/rhel7.6/ext4-export-orphan-add.patch diff --git a/ldiskfs/kernel_patches/patches/rhel7.4/ext4-fix-xattr-shifting-when-expanding-inodes.patch b/ldiskfs/kernel_patches/patches/rhel7.6/ext4-fix-xattr-shifting-when-expanding-inodes.patch similarity index 100% rename from ldiskfs/kernel_patches/patches/rhel7.4/ext4-fix-xattr-shifting-when-expanding-inodes.patch rename to ldiskfs/kernel_patches/patches/rhel7.6/ext4-fix-xattr-shifting-when-expanding-inodes.patch diff --git a/ldiskfs/kernel_patches/patches/rhel7/ext4-give-warning-with-dir-htree-growing.patch b/ldiskfs/kernel_patches/patches/rhel7.6/ext4-give-warning-with-dir-htree-growing.patch similarity index 100% rename from ldiskfs/kernel_patches/patches/rhel7/ext4-give-warning-with-dir-htree-growing.patch rename to ldiskfs/kernel_patches/patches/rhel7.6/ext4-give-warning-with-dir-htree-growing.patch diff --git a/ldiskfs/kernel_patches/patches/rhel7/ext4-hash-indexed-dir-dotdot-update.patch b/ldiskfs/kernel_patches/patches/rhel7.6/ext4-hash-indexed-dir-dotdot-update.patch similarity index 100% rename from ldiskfs/kernel_patches/patches/rhel7/ext4-hash-indexed-dir-dotdot-update.patch rename to ldiskfs/kernel_patches/patches/rhel7.6/ext4-hash-indexed-dir-dotdot-update.patch diff --git a/ldiskfs/kernel_patches/patches/rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch b/ldiskfs/kernel_patches/patches/rhel7.6/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch similarity index 100% rename from ldiskfs/kernel_patches/patches/rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch rename to ldiskfs/kernel_patches/patches/rhel7.6/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch diff --git a/ldiskfs/kernel_patches/patches/rhel7/ext4-inode-version.patch b/ldiskfs/kernel_patches/patches/rhel7.6/ext4-inode-version.patch similarity index 100% rename from ldiskfs/kernel_patches/patches/rhel7/ext4-inode-version.patch rename to ldiskfs/kernel_patches/patches/rhel7.6/ext4-inode-version.patch diff --git a/ldiskfs/kernel_patches/patches/rhel7/ext4-jcb-optimization.patch b/ldiskfs/kernel_patches/patches/rhel7.6/ext4-jcb-optimization.patch similarity index 100% rename from ldiskfs/kernel_patches/patches/rhel7/ext4-jcb-optimization.patch rename to ldiskfs/kernel_patches/patches/rhel7.6/ext4-jcb-optimization.patch diff --git a/ldiskfs/kernel_patches/patches/rhel7/ext4-kill-dx-root.patch b/ldiskfs/kernel_patches/patches/rhel7.6/ext4-kill-dx-root.patch similarity index 100% rename from ldiskfs/kernel_patches/patches/rhel7/ext4-kill-dx-root.patch rename to ldiskfs/kernel_patches/patches/rhel7.6/ext4-kill-dx-root.patch diff --git a/ldiskfs/kernel_patches/patches/rhel7.4/ext4-large-dir.patch b/ldiskfs/kernel_patches/patches/rhel7.6/ext4-large-dir.patch similarity index 100% rename from ldiskfs/kernel_patches/patches/rhel7.4/ext4-large-dir.patch rename to ldiskfs/kernel_patches/patches/rhel7.6/ext4-large-dir.patch diff --git a/ldiskfs/kernel_patches/patches/rhel7/ext4-lookup-dotdot.patch b/ldiskfs/kernel_patches/patches/rhel7.6/ext4-lookup-dotdot.patch similarity index 100% rename from ldiskfs/kernel_patches/patches/rhel7/ext4-lookup-dotdot.patch rename to ldiskfs/kernel_patches/patches/rhel7.6/ext4-lookup-dotdot.patch diff --git a/ldiskfs/kernel_patches/patches/rhel7/ext4-max-dir-size.patch b/ldiskfs/kernel_patches/patches/rhel7.6/ext4-max-dir-size.patch similarity index 100% rename from ldiskfs/kernel_patches/patches/rhel7/ext4-max-dir-size.patch rename to ldiskfs/kernel_patches/patches/rhel7.6/ext4-max-dir-size.patch diff --git a/ldiskfs/kernel_patches/patches/rhel7/ext4-mballoc-extra-checks.patch b/ldiskfs/kernel_patches/patches/rhel7.6/ext4-mballoc-extra-checks.patch similarity index 100% rename from ldiskfs/kernel_patches/patches/rhel7/ext4-mballoc-extra-checks.patch rename to ldiskfs/kernel_patches/patches/rhel7.6/ext4-mballoc-extra-checks.patch diff --git a/ldiskfs/kernel_patches/patches/rhel7/ext4-mballoc-pa-free-mismatch.patch b/ldiskfs/kernel_patches/patches/rhel7.6/ext4-mballoc-pa-free-mismatch.patch similarity index 100% rename from ldiskfs/kernel_patches/patches/rhel7/ext4-mballoc-pa-free-mismatch.patch rename to ldiskfs/kernel_patches/patches/rhel7.6/ext4-mballoc-pa-free-mismatch.patch diff --git a/ldiskfs/kernel_patches/patches/rhel7.6/ext4-mballoc-prefetch.patch b/ldiskfs/kernel_patches/patches/rhel7.6/ext4-mballoc-prefetch.patch new file mode 100644 index 0000000..b68880c --- /dev/null +++ b/ldiskfs/kernel_patches/patches/rhel7.6/ext4-mballoc-prefetch.patch @@ -0,0 +1,235 @@ +--- linux-4.18/fs/ext4/balloc.c 2019-11-28 14:55:26.506546036 +0300 ++++ linux-4.18/fs/ext4/balloc.c 2019-12-02 11:21:50.565975537 +0300 +@@ -404,7 +404,8 @@ verified: + * Return buffer_head on success or NULL in case of failure. + */ + struct buffer_head * +-ext4_read_block_bitmap_nowait(struct super_block *sb, ext4_group_t block_group) ++ext4_read_block_bitmap_nowait(struct super_block *sb, ext4_group_t block_group, ++ int ignore_locked) + { + struct ext4_group_desc *desc; + struct ext4_sb_info *sbi = EXT4_SB(sb); +@@ -435,6 +436,13 @@ ext4_read_block_bitmap_nowait(struct + if (bitmap_uptodate(bh)) + goto verify; + ++ if (ignore_locked && buffer_locked(bh)) { ++ /* buffer under IO already, do not wait ++ * if called for prefetching */ ++ put_bh(bh); ++ return NULL; ++ } ++ + lock_buffer(bh); + if (bitmap_uptodate(bh)) { + unlock_buffer(bh); +@@ -524,7 +532,7 @@ ext4_read_block_bitmap(struct super_b + struct buffer_head *bh; + int err; + +- bh = ext4_read_block_bitmap_nowait(sb, block_group); ++ bh = ext4_read_block_bitmap_nowait(sb, block_group, 1); + if (!bh) + return NULL; + err = ext4_wait_block_bitmap(sb, block_group, bh); +--- linux-4.18/fs/ext4/ext4.h 2019-11-28 14:55:26.470545343 +0300 ++++ linux-4.18/fs/ext4/ext4.h 2019-12-02 11:21:40.795779972 +0300 +@@ -1446,6 +1446,8 @@ struct ext4_sb_info { + /* where last allocation was done - for stream allocation */ + unsigned long s_mb_last_group; + unsigned long s_mb_last_start; ++ unsigned int s_mb_prefetch; ++ unsigned int s_mb_prefetch_limit; + + /* stats for buddy allocator */ + atomic_t s_bal_reqs; /* number of reqs with len > 1 */ +@@ -2401,7 +2403,8 @@ extern struct ext4_group_desc * ldisk + extern int ext4_should_retry_alloc(struct super_block *sb, int *retries); + + extern struct buffer_head *ext4_read_block_bitmap_nowait(struct super_block *sb, +- ext4_group_t block_group); ++ ext4_group_t block_group, ++ int ignore_locked); + extern int ext4_wait_block_bitmap(struct super_block *sb, + ext4_group_t block_group, + struct buffer_head *bh); +--- linux-4.18/fs/ext4/mballoc.c 2019-11-28 14:55:26.500545920 +0300 ++++ linux-4.18/fs/ext4/mballoc.c 2019-12-02 11:21:46.656897291 +0300 +@@ -868,7 +868,7 @@ static int ext4_mb_init_cache(struct + bh[i] = NULL; + continue; + } +- if (!(bh[i] = ext4_read_block_bitmap_nowait(sb, group))) { ++ if (!(bh[i] = ext4_read_block_bitmap_nowait(sb, group, 0))) { + err = -ENOMEM; + goto out; + } +@@ -2104,6 +2112,87 @@ static int ext4_mb_good_group(struct + return 0; + } + ++/* ++ * each allocation context (i.e. a thread doing allocation) has own ++ * sliding prefetch window of @s_mb_prefetch size which starts at the ++ * very first goal and moves ahead of scaning. ++ * a side effect is that subsequent allocations will likely find ++ * the bitmaps in cache or at least in-flight. ++ */ ++static void ++ext4_mb_prefetch(struct ext4_allocation_context *ac, ++ ext4_group_t start) ++{ ++ struct super_block *sb = ac->ac_sb; ++ ext4_group_t ngroups = ext4_get_groups_count(sb); ++ struct ext4_sb_info *sbi = EXT4_SB(sb); ++ struct ext4_group_info *grp; ++ ext4_group_t group = start; ++ struct buffer_head *bh; ++ int nr; ++ ++ /* limit prefetching at cr=0, otherwise mballoc can ++ * spend a lot of time loading imperfect groups */ ++ if (ac->ac_criteria < 2 && ac->ac_prefetch_ios >= sbi->s_mb_prefetch_limit) ++ return; ++ ++ /* batch prefetching to get few READs in flight */ ++ nr = ac->ac_prefetch - group; ++ if (ac->ac_prefetch < group) ++ /* wrapped to the first groups */ ++ nr += ngroups; ++ if (nr > 0) ++ return; ++ BUG_ON(nr < 0); ++ ++ nr = sbi->s_mb_prefetch; ++ if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_FLEX_BG)) { ++ /* align to flex_bg to get more bitmas with a single IO */ ++ nr = (group / sbi->s_mb_prefetch) * sbi->s_mb_prefetch; ++ nr = nr + sbi->s_mb_prefetch - group; ++ } ++ while (nr-- > 0) { ++ grp = ext4_get_group_info(sb, group); ++ /* ignore empty groups - those will be skipped ++ * during the scanning as well */ ++ if (grp->bb_free > 0 && EXT4_MB_GRP_NEED_INIT(grp)) { ++ bh = ext4_read_block_bitmap_nowait(sb, group, 1); ++ if (bh && !IS_ERR(bh)) { ++ if (!buffer_uptodate(bh)) ++ ac->ac_prefetch_ios++; ++ brelse(bh); ++ } ++ } ++ if (++group >= ngroups) ++ group = 0; ++ } ++ ac->ac_prefetch = group; ++} ++ ++static void ++ext4_mb_prefetch_fini(struct ext4_allocation_context *ac) ++{ ++ struct ext4_group_info *grp; ++ ext4_group_t group; ++ int nr, rc; ++ ++ /* initialize last window of prefetched groups */ ++ nr = ac->ac_prefetch_ios; ++ if (nr > EXT4_SB(ac->ac_sb)->s_mb_prefetch) ++ nr = EXT4_SB(ac->ac_sb)->s_mb_prefetch; ++ group = ac->ac_prefetch; ++ while (nr-- > 0) { ++ grp = ext4_get_group_info(ac->ac_sb, group); ++ if (grp->bb_free > 0 && EXT4_MB_GRP_NEED_INIT(grp)) { ++ rc = ext4_mb_init_group(ac->ac_sb, group); ++ if (rc) ++ break; ++ } ++ if (group-- == 0) ++ group = ext4_get_groups_count(ac->ac_sb) - 1; ++ } ++} ++ + static noinline_for_stack int + ext4_mb_regular_allocator(struct ext4_allocation_context *ac) + { +@@ -2176,6 +2264,7 @@ repeat: + * from the goal value specified + */ + group = ac->ac_g_ex.fe_group; ++ ac->ac_prefetch = group; + + for (i = 0; i < ngroups; group++, i++) { + int ret = 0; +@@ -2188,6 +2277,8 @@ repeat: + if (group >= ngroups) + group = 0; + ++ ext4_mb_prefetch(ac, group); ++ + /* This now checks without needing the buddy page */ + ret = ext4_mb_good_group(ac, group, cr); + if (ret <= 0) { +@@ -2260,6 +2351,8 @@ repeat: + } + } + out: ++ /* use prefetched bitmaps to init buddy so that read info is not lost */ ++ ext4_mb_prefetch_fini(ac); + return err; + } + +@@ -2832,6 +2925,22 @@ int ext4_mb_init(struct super_block * + sbi->s_mb_large_req = sbi->s_stripe * 8; + sbi->s_mb_group_prealloc = sbi->s_stripe * 4; + } ++ if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_FLEX_BG)) { ++ /* a single flex group is supposed to be read by a single IO */ ++ sbi->s_mb_prefetch = 1 << sbi->s_es->s_log_groups_per_flex; ++ sbi->s_mb_prefetch *= 8; /* 8 prefetch IOs in flight at most */ ++ } else { ++ sbi->s_mb_prefetch = 32; ++ } ++ if (sbi->s_mb_prefetch >= ext4_get_groups_count(sb)) ++ sbi->s_mb_prefetch = ext4_get_groups_count(sb); ++ /* now many real IOs to prefetch within a single allocation at cr=0 ++ * given cr=0 is an CPU-related optimization we shouldn't try to ++ * load too many groups, at some point we should start to use what ++ * we've got in memory. ++ * with an average random access time 5ms, it'd take a second to get ++ * 200 groups (* N with flex_bg), so let's make this limit 32 */ ++ sbi->s_mb_prefetch_limit = sbi->s_mb_prefetch * 32; + + sbi->s_locality_groups = alloc_percpu(struct ext4_locality_group); + if (sbi->s_locality_groups == NULL) { +--- linux-4.18/fs/ext4/mballoc.h 2019-11-28 14:55:26.471545362 +0300 ++++ linux-4.18/fs/ext4/mballoc.h 2019-12-02 11:21:57.028104886 +0300 +@@ -177,6 +177,8 @@ struct ext4_allocation_context { + struct page *ac_buddy_page; + struct ext4_prealloc_space *ac_pa; + struct ext4_locality_group *ac_lg; ++ ext4_group_t ac_prefetch; ++ int ac_prefetch_ios; /* number of initialied prefetch IO */ + }; + + #define AC_STATUS_CONTINUE 1 +--- linux-4.18/fs/ext4/super.c 2019-11-28 14:55:26.502545959 +0300 ++++ linux-4.18/fs/ext4/super.c 2019-11-28 20:07:48.104558177 +0300 +@@ -190,6 +190,8 @@ EXT4_RW_ATTR_SBI_UI(msg_ratelimit_bur + EXT4_RW_ATTR_SBI_UI(mb_small_req, s_mb_small_req); + EXT4_RW_ATTR_SBI_UI(mb_large_req, s_mb_large_req); + EXT4_RW_ATTR_SBI_UI(mb_group_prealloc, s_mb_group_prealloc); ++EXT4_RW_ATTR_SBI_UI(mb_prefetch, s_mb_prefetch); ++EXT4_RW_ATTR_SBI_UI(mb_prefetch_limit, s_mb_prefetch_limit); + EXT4_DEPRECATED_ATTR(max_writeback_mb_bump, 128); + EXT4_RW_ATTR_SBI_UI(extent_max_zeroout_kb, s_extent_max_zeroout_kb); + EXT4_ATTR(trigger_fs_error, 0200, NULL, trigger_test_error); +@@ -223,6 +224,8 @@ static struct attribute *ext4_attrs[] + ATTR_LIST(errors_count), + ATTR_LIST(first_error_time), + ATTR_LIST(last_error_time), ++ ATTR_LIST(mb_prefetch), ++ ATTR_LIST(mb_prefetch_limit), + NULL, + }; + diff --git a/ldiskfs/kernel_patches/patches/rhel7/ext4-mballoc-skip-uninit-groups-cr0.patch b/ldiskfs/kernel_patches/patches/rhel7.6/ext4-mballoc-skip-uninit-groups-cr0.patch similarity index 100% rename from ldiskfs/kernel_patches/patches/rhel7/ext4-mballoc-skip-uninit-groups-cr0.patch rename to ldiskfs/kernel_patches/patches/rhel7.6/ext4-mballoc-skip-uninit-groups-cr0.patch diff --git a/ldiskfs/kernel_patches/patches/rhel7/ext4-misc.patch b/ldiskfs/kernel_patches/patches/rhel7.6/ext4-misc.patch similarity index 100% rename from ldiskfs/kernel_patches/patches/rhel7/ext4-misc.patch rename to ldiskfs/kernel_patches/patches/rhel7.6/ext4-misc.patch diff --git a/ldiskfs/kernel_patches/patches/rhel7/ext4-mmp-brelse.patch b/ldiskfs/kernel_patches/patches/rhel7.6/ext4-mmp-brelse.patch similarity index 100% rename from ldiskfs/kernel_patches/patches/rhel7/ext4-mmp-brelse.patch rename to ldiskfs/kernel_patches/patches/rhel7.6/ext4-mmp-brelse.patch diff --git a/ldiskfs/kernel_patches/patches/rhel7/ext4-mmp-dont-mark-bh-dirty.patch b/ldiskfs/kernel_patches/patches/rhel7.6/ext4-mmp-dont-mark-bh-dirty.patch similarity index 100% rename from ldiskfs/kernel_patches/patches/rhel7/ext4-mmp-dont-mark-bh-dirty.patch rename to ldiskfs/kernel_patches/patches/rhel7.6/ext4-mmp-dont-mark-bh-dirty.patch diff --git a/ldiskfs/kernel_patches/patches/rhel7/ext4-nocmtime.patch b/ldiskfs/kernel_patches/patches/rhel7.6/ext4-nocmtime.patch similarity index 100% rename from ldiskfs/kernel_patches/patches/rhel7/ext4-nocmtime.patch rename to ldiskfs/kernel_patches/patches/rhel7.6/ext4-nocmtime.patch diff --git a/ldiskfs/kernel_patches/patches/rhel7/ext4-optimize-ext4_find_delalloc_range-in-nodelalloc.patch b/ldiskfs/kernel_patches/patches/rhel7.6/ext4-optimize-ext4_find_delalloc_range-in-nodelalloc.patch similarity index 100% rename from ldiskfs/kernel_patches/patches/rhel7/ext4-optimize-ext4_find_delalloc_range-in-nodelalloc.patch rename to ldiskfs/kernel_patches/patches/rhel7.6/ext4-optimize-ext4_find_delalloc_range-in-nodelalloc.patch diff --git a/ldiskfs/kernel_patches/patches/rhel7.4/ext4-pdirop.patch b/ldiskfs/kernel_patches/patches/rhel7.6/ext4-pdirop.patch similarity index 100% rename from ldiskfs/kernel_patches/patches/rhel7.4/ext4-pdirop.patch rename to ldiskfs/kernel_patches/patches/rhel7.6/ext4-pdirop.patch diff --git a/ldiskfs/kernel_patches/patches/rhel7.4/ext4-prealloc.patch b/ldiskfs/kernel_patches/patches/rhel7.6/ext4-prealloc.patch similarity index 100% rename from ldiskfs/kernel_patches/patches/rhel7.4/ext4-prealloc.patch rename to ldiskfs/kernel_patches/patches/rhel7.6/ext4-prealloc.patch diff --git a/ldiskfs/kernel_patches/patches/rhel7.2/ext4-preread-gd.patch b/ldiskfs/kernel_patches/patches/rhel7.6/ext4-preread-gd.patch similarity index 100% rename from ldiskfs/kernel_patches/patches/rhel7.2/ext4-preread-gd.patch rename to ldiskfs/kernel_patches/patches/rhel7.6/ext4-preread-gd.patch diff --git a/ldiskfs/kernel_patches/patches/rhel6.3/ext4-print-inum-in-htree-warning.patch b/ldiskfs/kernel_patches/patches/rhel7.6/ext4-print-inum-in-htree-warning.patch similarity index 100% rename from ldiskfs/kernel_patches/patches/rhel6.3/ext4-print-inum-in-htree-warning.patch rename to ldiskfs/kernel_patches/patches/rhel7.6/ext4-print-inum-in-htree-warning.patch diff --git a/ldiskfs/kernel_patches/patches/rhel7/ext4-projid-feature-support.patch b/ldiskfs/kernel_patches/patches/rhel7.6/ext4-projid-feature-support.patch similarity index 100% rename from ldiskfs/kernel_patches/patches/rhel7/ext4-projid-feature-support.patch rename to ldiskfs/kernel_patches/patches/rhel7.6/ext4-projid-feature-support.patch diff --git a/ldiskfs/kernel_patches/patches/rhel7/ext4-projid-ignore-maxquotas.patch b/ldiskfs/kernel_patches/patches/rhel7.6/ext4-projid-ignore-maxquotas.patch similarity index 100% rename from ldiskfs/kernel_patches/patches/rhel7/ext4-projid-ignore-maxquotas.patch rename to ldiskfs/kernel_patches/patches/rhel7.6/ext4-projid-ignore-maxquotas.patch diff --git a/ldiskfs/kernel_patches/patches/rhel7/ext4-projid-quotas.patch b/ldiskfs/kernel_patches/patches/rhel7.6/ext4-projid-quotas.patch similarity index 100% rename from ldiskfs/kernel_patches/patches/rhel7/ext4-projid-quotas.patch rename to ldiskfs/kernel_patches/patches/rhel7.6/ext4-projid-quotas.patch diff --git a/ldiskfs/kernel_patches/patches/rhel7.5/ext4-projid-xfs-ioctls.patch b/ldiskfs/kernel_patches/patches/rhel7.6/ext4-projid-xfs-ioctls.patch similarity index 100% rename from ldiskfs/kernel_patches/patches/rhel7.5/ext4-projid-xfs-ioctls.patch rename to ldiskfs/kernel_patches/patches/rhel7.6/ext4-projid-xfs-ioctls.patch diff --git a/ldiskfs/kernel_patches/patches/rhel7/ext4-reduce-lock-contention-in-__ext4_new_inode.patch b/ldiskfs/kernel_patches/patches/rhel7.6/ext4-reduce-lock-contention-in-__ext4_new_inode.patch similarity index 100% rename from ldiskfs/kernel_patches/patches/rhel7/ext4-reduce-lock-contention-in-__ext4_new_inode.patch rename to ldiskfs/kernel_patches/patches/rhel7.6/ext4-reduce-lock-contention-in-__ext4_new_inode.patch diff --git a/ldiskfs/kernel_patches/patches/rhel7.2/ext4-simple-blockalloc.patch b/ldiskfs/kernel_patches/patches/rhel7.6/ext4-simple-blockalloc.patch similarity index 100% rename from ldiskfs/kernel_patches/patches/rhel7.2/ext4-simple-blockalloc.patch rename to ldiskfs/kernel_patches/patches/rhel7.6/ext4-simple-blockalloc.patch diff --git a/ldiskfs/kernel_patches/patches/rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch b/ldiskfs/kernel_patches/patches/rhel7.6/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch similarity index 100% rename from ldiskfs/kernel_patches/patches/rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch rename to ldiskfs/kernel_patches/patches/rhel7.6/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch diff --git a/ldiskfs/kernel_patches/patches/rhel7/ext4_s_max_ext_tree_depth.patch b/ldiskfs/kernel_patches/patches/rhel7.6/ext4_s_max_ext_tree_depth.patch similarity index 100% rename from ldiskfs/kernel_patches/patches/rhel7/ext4_s_max_ext_tree_depth.patch rename to ldiskfs/kernel_patches/patches/rhel7.6/ext4_s_max_ext_tree_depth.patch diff --git a/ldiskfs/kernel_patches/patches/rhel7/ext4-corrupted-inode-block-bitmaps-handling-patches.patch b/ldiskfs/kernel_patches/patches/rhel7/ext4-corrupted-inode-block-bitmaps-handling-patches.patch deleted file mode 100644 index 0544193..0000000 --- a/ldiskfs/kernel_patches/patches/rhel7/ext4-corrupted-inode-block-bitmaps-handling-patches.patch +++ /dev/null @@ -1,465 +0,0 @@ -Since we could skip corrupt block groups, this patch -use ext4_warning() intead of ext4_error() to make FS not -emount RO in default, also fix a leftover from upstream -commit 163a203ddb36c36d4a1c942 ---- -diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c -index e069155..692b5e4 100644 ---- a/fs/ext4/balloc.c -+++ b/fs/ext4/balloc.c -@@ -185,25 +185,17 @@ static int ext4_init_block_bitmap(struct super_block *sb, - struct ext4_sb_info *sbi = EXT4_SB(sb); - ext4_fsblk_t start, tmp; - int flex_bg = 0; -- struct ext4_group_info *grp; - - J_ASSERT_BH(bh, buffer_locked(bh)); - - /* If checksum is bad mark all blocks used to prevent allocation - * essentially implementing a per-group read-only flag. */ - if (!ext4_group_desc_csum_verify(sb, block_group, gdp)) { -- grp = ext4_get_group_info(sb, block_group); -- if (!EXT4_MB_GRP_BBITMAP_CORRUPT(grp)) -- percpu_counter_sub(&sbi->s_freeclusters_counter, -- grp->bb_free); -- set_bit(EXT4_GROUP_INFO_BBITMAP_CORRUPT_BIT, &grp->bb_state); -- if (!EXT4_MB_GRP_IBITMAP_CORRUPT(grp)) { -- int count; -- count = ext4_free_inodes_count(sb, gdp); -- percpu_counter_sub(&sbi->s_freeinodes_counter, -- count); -- } -- set_bit(EXT4_GROUP_INFO_IBITMAP_CORRUPT_BIT, &grp->bb_state); -+ ext4_corrupted_block_group(sb, block_group, -+ EXT4_GROUP_INFO_BBITMAP_CORRUPT | -+ EXT4_GROUP_INFO_IBITMAP_CORRUPT, -+ "Checksum bad for group %u", -+ block_group); - return -EIO; - } - memset(bh->b_data, 0, sb->s_blocksize); -@@ -367,8 +359,6 @@ static void ext4_validate_block_bitmap(struct super_block *sb, - struct buffer_head *bh) - { - ext4_fsblk_t blk; -- struct ext4_group_info *grp = ext4_get_group_info(sb, block_group); -- struct ext4_sb_info *sbi = EXT4_SB(sb); - - if (buffer_verified(bh)) - return; -@@ -377,22 +367,19 @@ static void ext4_validate_block_bitmap(struct super_block *sb, - blk = ext4_valid_block_bitmap(sb, desc, block_group, bh); - if (unlikely(blk != 0)) { - ext4_unlock_group(sb, block_group); -- ext4_error(sb, "bg %u: block %llu: invalid block bitmap", -- block_group, blk); -- if (!EXT4_MB_GRP_BBITMAP_CORRUPT(grp)) -- percpu_counter_sub(&sbi->s_freeclusters_counter, -- grp->bb_free); -- set_bit(EXT4_GROUP_INFO_BBITMAP_CORRUPT_BIT, &grp->bb_state); -+ ext4_corrupted_block_group(sb, block_group, -+ EXT4_GROUP_INFO_BBITMAP_CORRUPT, -+ "bg %u: block %llu: invalid block bitmap", -+ block_group, blk); - return; - } - if (unlikely(!ext4_block_bitmap_csum_verify(sb, block_group, - desc, bh))) { - ext4_unlock_group(sb, block_group); -- ext4_error(sb, "bg %u: bad block bitmap checksum", block_group); -- if (!EXT4_MB_GRP_BBITMAP_CORRUPT(grp)) -- percpu_counter_sub(&sbi->s_freeclusters_counter, -- grp->bb_free); -- set_bit(EXT4_GROUP_INFO_BBITMAP_CORRUPT_BIT, &grp->bb_state); -+ ext4_corrupted_block_group(sb, block_group, -+ EXT4_GROUP_INFO_BBITMAP_CORRUPT, -+ "bg %u: bad block bitmap checksum", -+ block_group); - return; - } - set_buffer_verified(bh); -@@ -445,8 +432,6 @@ ext4_read_block_bitmap_nowait(struct super_block *sb, ext4_group_t block_group) - set_buffer_uptodate(bh); - ext4_unlock_group(sb, block_group); - unlock_buffer(bh); -- if (err) -- ext4_error(sb, "Checksum bad for grp %u", block_group); - return bh; - } - ext4_unlock_group(sb, block_group); -diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h -index 3c41773..63a63b6 100644 ---- a/fs/ext4/ext4.h -+++ b/fs/ext4/ext4.h -@@ -91,6 +91,17 @@ typedef __u32 ext4_lblk_t; - /* data type for block group number */ - typedef unsigned int ext4_group_t; - -+void __ext4_corrupted_block_group(struct super_block *sb, -+ ext4_group_t group, unsigned int flags, -+ const char *function, unsigned int line); -+ -+#define ext4_corrupted_block_group(sb, group, flags, fmt, ...) \ -+ do { \ -+ __ext4_warning(sb, __func__, __LINE__, fmt, \ -+ ##__VA_ARGS__); \ -+ __ext4_corrupted_block_group(sb, group, flags, \ -+ __func__, __LINE__); \ -+ } while (0) - /* - * Flags used in mballoc's allocation_context flags field. - * -@@ -2673,7 +2684,11 @@ struct ext4_group_info { - #define EXT4_GROUP_INFO_NEED_INIT_BIT 0 - #define EXT4_GROUP_INFO_WAS_TRIMMED_BIT 1 - #define EXT4_GROUP_INFO_BBITMAP_CORRUPT_BIT 2 -+#define EXT4_GROUP_INFO_BBITMAP_CORRUPT \ -+ (1 << EXT4_GROUP_INFO_BBITMAP_CORRUPT_BIT) - #define EXT4_GROUP_INFO_IBITMAP_CORRUPT_BIT 3 -+#define EXT4_GROUP_INFO_IBITMAP_CORRUPT \ -+ (1 << EXT4_GROUP_INFO_IBITMAP_CORRUPT_BIT) - - #define EXT4_MB_GRP_NEED_INIT(grp) \ - (test_bit(EXT4_GROUP_INFO_NEED_INIT_BIT, &((grp)->bb_state))) -diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c -index fc65310..92bcc8d 100644 ---- a/fs/ext4/ialloc.c -+++ b/fs/ext4/ialloc.c -@@ -70,26 +70,15 @@ static unsigned ext4_init_inode_bitmap(struct super_block *sb, - ext4_group_t block_group, - struct ext4_group_desc *gdp) - { -- struct ext4_group_info *grp; -- struct ext4_sb_info *sbi = EXT4_SB(sb); - J_ASSERT_BH(bh, buffer_locked(bh)); - - /* If checksum is bad mark all blocks and inodes use to prevent - * allocation, essentially implementing a per-group read-only flag. */ - if (!ext4_group_desc_csum_verify(sb, block_group, gdp)) { -- ext4_error(sb, "Checksum bad for group %u", block_group); -- grp = ext4_get_group_info(sb, block_group); -- if (!EXT4_MB_GRP_BBITMAP_CORRUPT(grp)) -- percpu_counter_sub(&sbi->s_freeclusters_counter, -- grp->bb_free); -- set_bit(EXT4_GROUP_INFO_BBITMAP_CORRUPT_BIT, &grp->bb_state); -- if (!EXT4_MB_GRP_IBITMAP_CORRUPT(grp)) { -- int count; -- count = ext4_free_inodes_count(sb, gdp); -- percpu_counter_sub(&sbi->s_freeinodes_counter, -- count); -- } -- set_bit(EXT4_GROUP_INFO_IBITMAP_CORRUPT_BIT, &grp->bb_state); -+ ext4_corrupted_block_group(sb, block_group, -+ EXT4_GROUP_INFO_BBITMAP_CORRUPT | -+ EXT4_GROUP_INFO_IBITMAP_CORRUPT, -+ "Checksum bad for group %u", block_group); - return 0; - } - -@@ -125,8 +114,6 @@ ext4_read_inode_bitmap(struct super_block *sb, ext4_group_t block_group) - struct ext4_group_desc *desc; - struct buffer_head *bh = NULL; - ext4_fsblk_t bitmap_blk; -- struct ext4_group_info *grp; -- struct ext4_sb_info *sbi = EXT4_SB(sb); - - desc = ext4_get_group_desc(sb, block_group, NULL); - if (!desc) -@@ -193,16 +180,10 @@ verify: - EXT4_INODES_PER_GROUP(sb) / 8)) { - ext4_unlock_group(sb, block_group); - put_bh(bh); -- ext4_error(sb, "Corrupt inode bitmap - block_group = %u, " -- "inode_bitmap = %llu", block_group, bitmap_blk); -- grp = ext4_get_group_info(sb, block_group); -- if (!EXT4_MB_GRP_IBITMAP_CORRUPT(grp)) { -- int count; -- count = ext4_free_inodes_count(sb, desc); -- percpu_counter_sub(&sbi->s_freeinodes_counter, -- count); -- } -- set_bit(EXT4_GROUP_INFO_IBITMAP_CORRUPT_BIT, &grp->bb_state); -+ ext4_corrupted_block_group(sb, block_group, -+ EXT4_GROUP_INFO_IBITMAP_CORRUPT, -+ "Corrupt inode bitmap - block_group = %u, inode_bitmap = %llu", -+ block_group, bitmap_blk); - return NULL; - } - ext4_unlock_group(sb, block_group); -@@ -337,14 +318,9 @@ out: - if (!fatal) - fatal = err; - } else { -- ext4_error(sb, "bit already cleared for inode %lu", ino); -- if (gdp && !EXT4_MB_GRP_IBITMAP_CORRUPT(grp)) { -- int count; -- count = ext4_free_inodes_count(sb, gdp); -- percpu_counter_sub(&sbi->s_freeinodes_counter, -- count); -- } -- set_bit(EXT4_GROUP_INFO_IBITMAP_CORRUPT_BIT, &grp->bb_state); -+ ext4_corrupted_block_group(sb, block_group, -+ EXT4_GROUP_INFO_IBITMAP_CORRUPT, -+ "bit already cleared for inode %lu", ino); - } - - error_return: -diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c -index 7282d07..e6805e6 100644 ---- a/fs/ext4/mballoc.c -+++ b/fs/ext4/mballoc.c -@@ -752,10 +752,18 @@ int ext4_mb_generate_buddy(struct super_block *sb, - if (free != grp->bb_free) { - struct ext4_group_desc *gdp; - gdp = ext4_get_group_desc(sb, group, NULL); -- ext4_error(sb, "group %lu: %u blocks in bitmap, %u in bb, " -- "%u in gd, %lu pa's\n", (long unsigned int)group, -- free, grp->bb_free, ext4_free_group_clusters(sb, gdp), -- grp->bb_prealloc_nr); -+ -+ ext4_corrupted_block_group(sb, group, -+ EXT4_GROUP_INFO_BBITMAP_CORRUPT, -+ "group %lu: %u blocks in bitmap, %u in bb, %u in gd, %lu pa's block bitmap corrupt", -+ (unsigned long int)group, free, grp->bb_free, -+ ext4_free_group_clusters(sb, gdp), -+ grp->bb_prealloc_nr); -+ /* -+ * If we intend to continue, we consider group descriptor -+ * corrupt and update bb_free using bitmap value -+ */ -+ grp->bb_free = free; - return -EIO; - } - mb_set_largest_free_order(sb, grp); -@@ -1101,7 +1109,7 @@ ext4_mb_load_buddy(struct super_block *sb, ext4_group_t group, - int block; - int pnum; - int poff; -- struct page *page; -+ struct page *page = NULL; - int ret; - struct ext4_group_info *grp; - struct ext4_sb_info *sbi = EXT4_SB(sb); -@@ -1127,7 +1135,7 @@ ext4_mb_load_buddy(struct super_block *sb, ext4_group_t group, - */ - ret = ext4_mb_init_group(sb, group); - if (ret) -- return ret; -+ goto err; - } - - /* -@@ -1227,6 +1235,7 @@ err: - page_cache_release(e4b->bd_buddy_page); - e4b->bd_buddy = NULL; - e4b->bd_bitmap = NULL; -+ ext4_warning(sb, "Error loading buddy information for %u", group); - return ret; - } - -@@ -3599,9 +3608,11 @@ int ext4_mb_check_ondisk_bitmap(struct super_block *sb, void *bitmap, - } - - if (free != free_in_gdp) { -- ext4_error(sb, "on-disk bitmap for group %d" -- "corrupted: %u blocks free in bitmap, %u - in gd\n", -- group, free, free_in_gdp); -+ ext4_corrupted_block_group(sb, group, -+ EXT4_GROUP_INFO_BBITMAP_CORRUPT, -+ "on-disk bitmap for group %d corrupted: %u blocks free in bitmap, %u - in gd\n", -+ group, free, -+ free_in_gdp); - return -EIO; - } - return 0; -@@ -3962,16 +3973,8 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh, - /* "free < pa->pa_free" means we maybe double alloc the same blocks, - * otherwise maybe leave some free blocks unavailable, no need to BUG.*/ - if ((free > pa->pa_free && !pa->pa_error) || (free < pa->pa_free)) { -- ext4_error(sb, "pa free mismatch: [pa %p] " -- "[phy %lu] [logic %lu] [len %u] [free %u] " -- "[error %u] [inode %lu] [freed %u]", pa, -- (unsigned long)pa->pa_pstart, -- (unsigned long)pa->pa_lstart, -- (unsigned)pa->pa_len, (unsigned)pa->pa_free, -- (unsigned)pa->pa_error, pa->pa_inode->i_ino, -- free); - ext4_grp_locked_error(sb, group, 0, 0, "free %u, pa_free %u", -- free, pa->pa_free); -+ free, pa->pa_free); - /* - * pa is already deleted so we use the value obtained - * from the bitmap and continue. -@@ -4031,14 +4034,11 @@ ext4_mb_discard_group_preallocations(struct super_block *sb, - return 0; - - bitmap_bh = ext4_read_block_bitmap(sb, group); -- if (bitmap_bh == NULL) { -- ext4_error(sb, "Error reading block bitmap for %u", group); -+ if (bitmap_bh == NULL) - return 0; -- } - - err = ext4_mb_load_buddy(sb, group, &e4b); - if (err) { -- ext4_error(sb, "Error loading buddy information for %u", group); - put_bh(bitmap_bh); - return 0; - } -@@ -4198,16 +4198,11 @@ repeat: - group = ext4_get_group_number(sb, pa->pa_pstart); - - err = ext4_mb_load_buddy(sb, group, &e4b); -- if (err) { -- ext4_error(sb, "Error loading buddy information for %u", -- group); -+ if (err) - return; -- } - - bitmap_bh = ext4_read_block_bitmap(sb, group); - if (bitmap_bh == NULL) { -- ext4_error(sb, "Error reading block bitmap for %u", -- group); - ext4_mb_unload_buddy(&e4b); - continue; - } -@@ -4467,11 +4462,8 @@ ext4_mb_discard_lg_preallocations(struct super_block *sb, - list_for_each_entry_safe(pa, tmp, &discard_list, u.pa_tmp_list) { - - group = ext4_get_group_number(sb, pa->pa_pstart); -- if (ext4_mb_load_buddy(sb, group, &e4b)) { -- ext4_error(sb, "Error loading buddy information for %u", -- group); -+ if (ext4_mb_load_buddy(sb, group, &e4b)) - continue; -- } - ext4_lock_group(sb, group); - list_del(&pa->pa_group_list); - ext4_get_group_info(sb, group)->bb_prealloc_nr--; -@@ -4742,17 +4734,18 @@ errout: - * been updated or not when fail case. So can - * not revert pa_free back, just mark pa_error*/ - pa->pa_error++; -- ext4_error(sb, -- "Updating bitmap error: [err %d] " -- "[pa %p] [phy %lu] [logic %lu] " -- "[len %u] [free %u] [error %u] " -- "[inode %lu]", *errp, pa, -- (unsigned long)pa->pa_pstart, -- (unsigned long)pa->pa_lstart, -- (unsigned)pa->pa_len, -- (unsigned)pa->pa_free, -- (unsigned)pa->pa_error, -- pa->pa_inode ? pa->pa_inode->i_ino : 0); -+ ext4_corrupted_block_group(sb, 0, 0, -+ "Updating bitmap error: [err %d] " -+ "[pa %p] [phy %lu] [logic %lu] " -+ "[len %u] [free %u] [error %u] " -+ "[inode %lu]", *errp, pa, -+ (unsigned long)pa->pa_pstart, -+ (unsigned long)pa->pa_lstart, -+ (unsigned)pa->pa_len, -+ (unsigned)pa->pa_free, -+ (unsigned)pa->pa_error, -+ pa->pa_inode ? -+ pa->pa_inode->i_ino : 0); - } - } - ext4_mb_release_context(ac); -@@ -5037,7 +5030,7 @@ do_more: - - err = ext4_mb_load_buddy(sb, block_group, &e4b); - if (err) -- goto error_return; -+ goto error_brelse; - - if ((flags & EXT4_FREE_BLOCKS_METADATA) && ext4_handle_valid(handle)) { - struct ext4_free_data *new_entry; -@@ -5119,8 +5112,9 @@ do_more: - goto do_more; - } - error_return: -- brelse(bitmap_bh); - ext4_std_error(sb, err); -+error_brelse: -+ brelse(bitmap_bh); - return; - } - -@@ -5216,7 +5210,7 @@ int ext4_group_add_blocks(handle_t *handle, struct super_block *sb, - - err = ext4_mb_load_buddy(sb, block_group, &e4b); - if (err) -- goto error_return; -+ goto error_brelse; - - /* - * need to update group_info->bb_free and bitmap -@@ -5253,8 +5247,9 @@ int ext4_group_add_blocks(handle_t *handle, struct super_block *sb, - err = ret; - - error_return: -- brelse(bitmap_bh); - ext4_std_error(sb, err); -+error_brelse: -+ brelse(bitmap_bh); - return err; - } - -@@ -5329,11 +5324,9 @@ ext4_trim_all_free(struct super_block *sb, ext4_group_t group, - trace_ext4_trim_all_free(sb, group, start, max); - - ret = ext4_mb_load_buddy(sb, group, &e4b); -- if (ret) { -- ext4_error(sb, "Error in loading buddy " -- "information for %u", group); -+ if (ret) - return ret; -- } -+ - bitmap = e4b.bd_bitmap; - - ext4_lock_group(sb, group); -diff --git a/fs/ext4/super.c b/fs/ext4/super.c -index c625960..0de22f2 100644 ---- a/fs/ext4/super.c -+++ b/fs/ext4/super.c -@@ -633,6 +633,37 @@ void __ext4_warning(struct super_block *sb, const char *function, - va_end(args); - } - -+void __ext4_corrupted_block_group(struct super_block *sb, ext4_group_t group, -+ unsigned int flags, const char *function, -+ unsigned int line) -+{ -+ struct ext4_sb_info *sbi = EXT4_SB(sb); -+ struct ext4_group_info *grp = ext4_get_group_info(sb, group); -+ struct ext4_group_desc *gdp = ext4_get_group_desc(sb, group, NULL); -+ -+ if (flags & EXT4_GROUP_INFO_BBITMAP_CORRUPT && -+ !EXT4_MB_GRP_BBITMAP_CORRUPT(grp)) { -+ percpu_counter_sub(&sbi->s_freeclusters_counter, -+ grp->bb_free); -+ set_bit(EXT4_GROUP_INFO_BBITMAP_CORRUPT_BIT, -+ &grp->bb_state); -+ } -+ -+ if (flags & EXT4_GROUP_INFO_IBITMAP_CORRUPT && -+ !EXT4_MB_GRP_IBITMAP_CORRUPT(grp)) { -+ if (gdp) { -+ int count; -+ -+ count = ext4_free_inodes_count(sb, gdp); -+ percpu_counter_sub(&sbi->s_freeinodes_counter, -+ count); -+ } -+ set_bit(EXT4_GROUP_INFO_IBITMAP_CORRUPT_BIT, -+ &grp->bb_state); -+ } -+ save_error_info(sb, function, line); -+} -+ - void __ext4_grp_locked_error(const char *function, unsigned int line, - struct super_block *sb, ext4_group_t grp, - unsigned long ino, ext4_fsblk_t block, diff --git a/ldiskfs/kernel_patches/patches/rhel7/ext4-data-in-dirent.patch b/ldiskfs/kernel_patches/patches/rhel7/ext4-data-in-dirent.patch deleted file mode 100644 index 3bd77ff..0000000 --- a/ldiskfs/kernel_patches/patches/rhel7/ext4-data-in-dirent.patch +++ /dev/null @@ -1,793 +0,0 @@ -this patch implements feature which allows ext4 fs users (e.g. Lustre) -to store data in ext4 dirent. -data is stored in ext4 dirent after file-name, this space is accounted -in de->rec_len. flag EXT4_DIRENT_LUFID added to d_type if extra data -is present. - -make use of dentry->d_fsdata to pass fid to ext4. so no -changes in ext4_add_entry() interface required. - -Index: linux-3.10.0-123.13.2.el7.x86_64/fs/ext4/dir.c -=================================================================== ---- linux-3.10.0-123.13.2.el7.x86_64.orig/fs/ext4/dir.c -+++ linux-3.10.0-123.13.2.el7.x86_64/fs/ext4/dir.c -@@ -71,11 +71,11 @@ int __ext4_check_dir_entry(const char *f - const int rlen = ext4_rec_len_from_disk(de->rec_len, - dir->i_sb->s_blocksize); - -- if (unlikely(rlen < EXT4_DIR_REC_LEN(1))) -+ if (unlikely(rlen < __EXT4_DIR_REC_LEN(1))) - error_msg = "rec_len is smaller than minimal"; - else if (unlikely(rlen % 4 != 0)) - error_msg = "rec_len % 4 != 0"; -- else if (unlikely(rlen < EXT4_DIR_REC_LEN(de->name_len))) -+ else if (unlikely(rlen < EXT4_DIR_REC_LEN(de))) - error_msg = "rec_len is too small for name_len"; - else if (unlikely(((char *) de - buf) + rlen > size)) - error_msg = "directory entry across range"; -@@ -208,7 +208,7 @@ revalidate: - * failure will be detected in the - * dirent test below. */ - if (ext4_rec_len_from_disk(de->rec_len, -- sb->s_blocksize) < EXT4_DIR_REC_LEN(1)) -+ sb->s_blocksize) < __EXT4_DIR_REC_LEN(1)) - break; - i += ext4_rec_len_from_disk(de->rec_len, - sb->s_blocksize); -@@ -438,12 +438,17 @@ int ext4_htree_store_dirent(struct file - struct fname *fname, *new_fn; - struct dir_private_info *info; - int len; -+ int extra_data = 0; - - info = dir_file->private_data; - p = &info->root.rb_node; - - /* Create and allocate the fname structure */ -- len = sizeof(struct fname) + dirent->name_len + 1; -+ if (dirent->file_type & EXT4_DIRENT_LUFID) -+ extra_data = ext4_get_dirent_data_len(dirent); -+ -+ len = sizeof(struct fname) + dirent->name_len + extra_data + 1; -+ - new_fn = kzalloc(len, GFP_KERNEL); - if (!new_fn) - return -ENOMEM; -@@ -452,7 +457,7 @@ int ext4_htree_store_dirent(struct file - new_fn->inode = le32_to_cpu(dirent->inode); - new_fn->name_len = dirent->name_len; - new_fn->file_type = dirent->file_type; -- memcpy(new_fn->name, dirent->name, dirent->name_len); -+ memcpy(new_fn->name, dirent->name, dirent->name_len + extra_data); - new_fn->name[dirent->name_len] = 0; - - while (*p) { -@@ -452,7 +457,7 @@ int ext4_htree_store_dirent(struct file - if (ext4_check_dir_entry(dir, NULL, de, bh, - buf, buf_size, offset)) - return -EIO; -- nlen = EXT4_DIR_REC_LEN(de->name_len); -+ nlen = EXT4_DIR_REC_LEN(de); - rlen = ext4_rec_len_from_disk(de->rec_len, buf_size); - de = (struct ext4_dir_entry_2 *)((char *)de + rlen); - offset += rlen; -Index: linux-3.10.0-123.13.2.el7.x86_64/fs/ext4/ext4.h -=================================================================== ---- linux-3.10.0-123.13.2.el7.x86_64.orig/fs/ext4/ext4.h -+++ linux-3.10.0-123.13.2.el7.x86_64/fs/ext4/ext4.h -@@ -952,6 +952,7 @@ struct ext4_inode_info { - #define EXT4_MOUNT_ERRORS_MASK 0x00070 - #define EXT4_MOUNT_MINIX_DF 0x00080 /* Mimics the Minix statfs */ - #define EXT4_MOUNT_NOLOAD 0x00100 /* Don't use existing journal*/ -+#define EXT4_MOUNT_DIRDATA 0x00200 /* Data in directory entries*/ - #define EXT4_MOUNT_DATA_FLAGS 0x00C00 /* Mode for data writes: */ - #define EXT4_MOUNT_JOURNAL_DATA 0x00400 /* Write data to journal */ - #define EXT4_MOUNT_ORDERED_DATA 0x00800 /* Flush data before commit */ -@@ -1534,6 +1535,7 @@ static inline void ext4_clear_state_flag - EXT4_FEATURE_INCOMPAT_64BIT| \ - EXT4_FEATURE_INCOMPAT_FLEX_BG| \ - EXT4_FEATURE_INCOMPAT_MMP | \ -+ EXT4_FEATURE_INCOMPAT_DIRDATA| \ - EXT4_FEATURE_INCOMPAT_INLINE_DATA) - #define EXT4_FEATURE_RO_COMPAT_SUPP (EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER| \ - EXT4_FEATURE_RO_COMPAT_LARGE_FILE| \ -@@ -1640,6 +1642,43 @@ struct ext4_dir_entry_tail { - #define EXT4_FT_SYMLINK 7 - - #define EXT4_FT_MAX 8 -+#define EXT4_FT_MASK 0xf -+ -+#if EXT4_FT_MAX > EXT4_FT_MASK -+#error "conflicting EXT4_FT_MAX and EXT4_FT_MASK" -+#endif -+ -+/* -+ * d_type has 4 unused bits, so it can hold four types data. these different -+ * type of data (e.g. lustre data, high 32 bits of 64-bit inode number) can be -+ * stored, in flag order, after file-name in ext4 dirent. -+*/ -+/* -+ * this flag is added to d_type if ext4 dirent has extra data after -+ * filename. this data length is variable and length is stored in first byte -+ * of data. data start after filename NUL byte. -+ * This is used by Lustre FS. -+ */ -+#define EXT4_DIRENT_LUFID 0x10 -+ -+#define EXT4_LUFID_MAGIC 0xAD200907UL -+struct ext4_dentry_param { -+ __u32 edp_magic; /* EXT4_LUFID_MAGIC */ -+ char edp_len; /* size of edp_data in bytes */ -+ char edp_data[0]; /* packed array of data */ -+} __packed; -+ -+static inline unsigned char *ext4_dentry_get_data(struct super_block *sb, -+ struct ext4_dentry_param *p) -+ -+{ -+ if (!EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_DIRDATA)) -+ return NULL; -+ if (p && p->edp_magic == EXT4_LUFID_MAGIC) -+ return &p->edp_len; -+ else -+ return NULL; -+} - - #define EXT4_FT_DIR_CSUM 0xDE - -@@ -1650,8 +1689,11 @@ struct ext4_dir_entry_tail { - */ - #define EXT4_DIR_PAD 4 - #define EXT4_DIR_ROUND (EXT4_DIR_PAD - 1) --#define EXT4_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT4_DIR_ROUND) & \ -+#define __EXT4_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT4_DIR_ROUND) & \ - ~EXT4_DIR_ROUND) -+#define EXT4_DIR_REC_LEN(de) (__EXT4_DIR_REC_LEN((de)->name_len +\ -+ ext4_get_dirent_data_len(de))) -+ - #define EXT4_MAX_REC_LEN ((1<<16)-1) - - /* -@@ -1987,11 +2029,11 @@ extern int ext4_find_dest_de(struct inod - struct buffer_head *bh, - void *buf, int buf_size, - const char *name, int namelen, -- struct ext4_dir_entry_2 **dest_de); -+ struct ext4_dir_entry_2 **dest_de, int *dlen); - void ext4_insert_dentry(struct inode *inode, - struct ext4_dir_entry_2 *de, - int buf_size, -- const char *name, int namelen); -+ const char *name, int namelen, void *data); - static inline void ext4_update_dx_flag(struct inode *inode) - { - if (!EXT4_HAS_COMPAT_FEATURE(inode->i_sb, -@@ -2004,11 +2046,18 @@ static unsigned char ext4_filetype_table - - static inline unsigned char get_dtype(struct super_block *sb, int filetype) - { -+ int fl_index = filetype & EXT4_FT_MASK; -+ - if (!EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_FILETYPE) || -- (filetype >= EXT4_FT_MAX)) -+ (fl_index >= EXT4_FT_MAX)) - return DT_UNKNOWN; - -- return ext4_filetype_table[filetype]; -+ if (!test_opt(sb, DIRDATA)) -+ return ext4_filetype_table[fl_index]; -+ -+ return (ext4_filetype_table[fl_index]) | -+ (filetype & EXT4_DIRENT_LUFID); -+ - } - - /* fsync.c */ -@@ -2157,6 +2206,8 @@ extern struct buffer_head * ext4_find_en - extern int ext4_delete_entry(handle_t *handle, struct inode * dir, - struct ext4_dir_entry_2 *de_del, - struct buffer_head *bh); -+extern int ext4_add_dot_dotdot(handle_t *handle, struct inode *dir, -+ struct inode *inode, const void *, const void *); - extern int search_dir(struct buffer_head *bh, - char *search_buf, - int buf_size, -@@ -2761,6 +2810,36 @@ extern struct mutex ext4__aio_mutex[EXT4 - extern int ext4_resize_begin(struct super_block *sb); - extern void ext4_resize_end(struct super_block *sb); - -+/* -+ * Compute the total directory entry data length. -+ * This includes the filename and an implicit NUL terminator (always present), -+ * and optional extensions. Each extension has a bit set in the high 4 bits of -+ * de->file_type, and the extension length is the first byte in each entry. -+ */ -+static inline int ext4_get_dirent_data_len(struct ext4_dir_entry_2 *de) -+{ -+ char *len = de->name + de->name_len + 1 /* NUL terminator */; -+ int dlen = 0; -+ __u8 extra_data_flags = (de->file_type & ~EXT4_FT_MASK) >> 4; -+ struct ext4_dir_entry_tail *t = (struct ext4_dir_entry_tail *)de; -+ -+ if (!t->det_reserved_zero1 && -+ le16_to_cpu(t->det_rec_len) == -+ sizeof(struct ext4_dir_entry_tail) && -+ !t->det_reserved_zero2 && -+ t->det_reserved_ft == EXT4_FT_DIR_CSUM) -+ return 0; -+ -+ while (extra_data_flags) { -+ if (extra_data_flags & 1) { -+ dlen += *len + (dlen == 0); -+ len += *len; -+ } -+ extra_data_flags >>= 1; -+ } -+ return dlen; -+} -+ - #endif /* __KERNEL__ */ - - #endif /* _EXT4_H */ -Index: linux-3.10.0-123.13.2.el7.x86_64/fs/ext4/namei.c -=================================================================== ---- linux-3.10.0-123.13.2.el7.x86_64.orig/fs/ext4/namei.c -+++ linux-3.10.0-123.13.2.el7.x86_64/fs/ext4/namei.c -@@ -239,7 +239,8 @@ static unsigned dx_get_count(struct dx_e - static unsigned dx_get_limit(struct dx_entry *entries); - static void dx_set_count(struct dx_entry *entries, unsigned value); - static void dx_set_limit(struct dx_entry *entries, unsigned value); --static unsigned dx_root_limit(struct inode *dir, unsigned infosize); -+static inline unsigned dx_root_limit(struct inode *dir, -+ struct ext4_dir_entry_2 *dot_de, unsigned infosize); - static unsigned dx_node_limit(struct inode *dir); - static struct dx_frame *dx_probe(const struct qstr *d_name, - struct inode *dir, -@@ -379,22 +380,23 @@ static struct dx_countlimit *get_dx_coun - { - struct ext4_dir_entry *dp; - struct dx_root_info *root; -- int count_offset; -+ int count_offset, dot_rec_len, dotdot_rec_len; - - if (le16_to_cpu(dirent->rec_len) == EXT4_BLOCK_SIZE(inode->i_sb)) - count_offset = 8; -- else if (le16_to_cpu(dirent->rec_len) == 12) { -- dp = (struct ext4_dir_entry *)(((void *)dirent) + 12); -+ else { -+ dot_rec_len = le16_to_cpu(dirent->rec_len); -+ dp = (struct ext4_dir_entry *)(((void *)dirent) + dot_rec_len); - if (le16_to_cpu(dp->rec_len) != -- EXT4_BLOCK_SIZE(inode->i_sb) - 12) -+ EXT4_BLOCK_SIZE(inode->i_sb) - dot_rec_len) - return NULL; -- root = (struct dx_root_info *)(((void *)dp + 12)); -+ dotdot_rec_len = EXT4_DIR_REC_LEN((struct ext4_dir_entry_2 *)dp); -+ root = (struct dx_root_info *)(((void *)dp + dotdot_rec_len)); - if (root->reserved_zero || - root->info_length != sizeof(struct dx_root_info)) - return NULL; -- count_offset = 32; -- } else -- return NULL; -+ count_offset = 8 + dot_rec_len + dotdot_rec_len; -+ } - - if (offset) - *offset = count_offset; -@@ -504,11 +505,12 @@ ext4_next_entry(struct ext4_dir_entry_2 - */ - struct dx_root_info *dx_get_dx_info(struct ext4_dir_entry_2 *de) - { -- /* get dotdot first */ -- de = (struct ext4_dir_entry_2 *)((char *)de + EXT4_DIR_REC_LEN(1)); -+ BUG_ON(de->name_len != 1); -+ /* get dotdot first */ -+ de = (struct ext4_dir_entry_2 *)((char *)de + EXT4_DIR_REC_LEN(de)); - -- /* dx root info is after dotdot entry */ -- de = (struct ext4_dir_entry_2 *)((char *)de + EXT4_DIR_REC_LEN(2)); -+ /* dx root info is after dotdot entry */ -+ de = (struct ext4_dir_entry_2 *)((char *)de + EXT4_DIR_REC_LEN(de)); - - return (struct dx_root_info *)de; - } -@@ -553,10 +555,16 @@ static inline void dx_set_limit(struct d - ((struct dx_countlimit *) entries)->limit = cpu_to_le16(value); - } - --static inline unsigned dx_root_limit(struct inode *dir, unsigned infosize) -+static inline unsigned dx_root_limit(struct inode *dir, -+ struct ext4_dir_entry_2 *dot_de, unsigned infosize) - { -- unsigned entry_space = dir->i_sb->s_blocksize - EXT4_DIR_REC_LEN(1) - -- EXT4_DIR_REC_LEN(2) - infosize; -+ struct ext4_dir_entry_2 *dotdot_de; -+ unsigned entry_space; -+ -+ BUG_ON(dot_de->name_len != 1); -+ dotdot_de = ext4_next_entry(dot_de, dir->i_sb->s_blocksize); -+ entry_space = dir->i_sb->s_blocksize - EXT4_DIR_REC_LEN(dot_de) - -+ EXT4_DIR_REC_LEN(dotdot_de) - infosize; - - if (EXT4_HAS_RO_COMPAT_FEATURE(dir->i_sb, - EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)) -@@ -566,7 +574,7 @@ static inline unsigned dx_root_limit(str - - static inline unsigned dx_node_limit(struct inode *dir) - { -- unsigned entry_space = dir->i_sb->s_blocksize - EXT4_DIR_REC_LEN(0); -+ unsigned entry_space = dir->i_sb->s_blocksize - __EXT4_DIR_REC_LEN(0); - - if (EXT4_HAS_RO_COMPAT_FEATURE(dir->i_sb, - EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)) -@@ -617,7 +625,7 @@ static struct stats dx_show_leaf(struct - printk(":%x.%u ", h.hash, - (unsigned) ((char *) de - base)); - } -- space += EXT4_DIR_REC_LEN(de->name_len); -+ space += EXT4_DIR_REC_LEN(de); - names++; - } - de = ext4_next_entry(de, size); -@@ -723,12 +731,15 @@ dx_probe(const struct qstr *d_name, stru - - entries = (struct dx_entry *) (((char *)info) + info->info_length); - -- if (dx_get_limit(entries) != dx_root_limit(dir, -- info->info_length)) { -+ if (dx_get_limit(entries) != -+ dx_root_limit(dir, (struct ext4_dir_entry_2 *)bh->b_data, -+ info->info_length)) { - ext4_warning(dir->i_sb, "dx entry: limit != root limit " - "inode #%lu: dx entry: limit %u != root limit %u", - dir->i_ino, dx_get_limit(entries), -- dx_root_limit(dir, info->info_length)); -+ dx_root_limit(dir, -+ (struct ext4_dir_entry_2 *)bh->b_data, -+ info->info_length)); - brelse(bh); - *err = ERR_BAD_DX_DIR; - goto fail; -@@ -916,7 +925,7 @@ static int htree_dirblock_to_tree(struct - de = (struct ext4_dir_entry_2 *) bh->b_data; - top = (struct ext4_dir_entry_2 *) ((char *) de + - dir->i_sb->s_blocksize - -- EXT4_DIR_REC_LEN(0)); -+ __EXT4_DIR_REC_LEN(0)); - for (; de < top; de = ext4_next_entry(de, dir->i_sb->s_blocksize)) { - if (ext4_check_dir_entry(dir, NULL, de, bh, - bh->b_data, bh->b_size, -@@ -1508,7 +1517,7 @@ dx_move_dirents(char *from, char *to, st - while (count--) { - struct ext4_dir_entry_2 *de = (struct ext4_dir_entry_2 *) - (from + (map->offs<<2)); -- rec_len = EXT4_DIR_REC_LEN(de->name_len); -+ rec_len = EXT4_DIR_REC_LEN(de); - memcpy (to, de, rec_len); - ((struct ext4_dir_entry_2 *) to)->rec_len = - ext4_rec_len_to_disk(rec_len, blocksize); -@@ -1532,7 +1541,7 @@ static struct ext4_dir_entry_2* dx_pack_ - while ((char*)de < base + blocksize) { - next = ext4_next_entry(de, blocksize); - if (de->inode && de->name_len) { -- rec_len = EXT4_DIR_REC_LEN(de->name_len); -+ rec_len = EXT4_DIR_REC_LEN(de); - if (de > to) - memmove(to, de, rec_len); - to->rec_len = ext4_rec_len_to_disk(rec_len, blocksize); -@@ -1664,14 +1673,16 @@ int ext4_find_dest_de(struct inode *dir, - struct buffer_head *bh, - void *buf, int buf_size, - const char *name, int namelen, -- struct ext4_dir_entry_2 **dest_de) -+ struct ext4_dir_entry_2 **dest_de, int *dlen) - { - struct ext4_dir_entry_2 *de; -- unsigned short reclen = EXT4_DIR_REC_LEN(namelen); -+ unsigned short reclen = __EXT4_DIR_REC_LEN(namelen) + -+ (dlen ? *dlen : 0); - int nlen, rlen; - unsigned int offset = 0; - char *top; - -+ dlen ? *dlen = 0 : 0; /* default set to 0 */ - de = (struct ext4_dir_entry_2 *)buf; - top = buf + buf_size - reclen; - while ((char *) de <= top) { -@@ -1680,10 +1690,26 @@ int ext4_find_dest_de(struct inode *dir, - return -EIO; - if (ext4_match(namelen, name, de)) - return -EEXIST; -- nlen = EXT4_DIR_REC_LEN(de->name_len); -+ nlen = EXT4_DIR_REC_LEN(de); - rlen = ext4_rec_len_from_disk(de->rec_len, buf_size); - if ((de->inode ? rlen - nlen : rlen) >= reclen) - break; -+ /* Then for dotdot entries, check for the smaller space -+ * required for just the entry, no FID */ -+ if (namelen == 2 && memcmp(name, "..", 2) == 0) { -+ if ((de->inode ? rlen - nlen : rlen) >= -+ __EXT4_DIR_REC_LEN(namelen)) { -+ /* set dlen=1 to indicate not -+ * enough space store fid */ -+ dlen ? *dlen = 1 : 0; -+ break; -+ } -+ /* The new ".." entry must be written over the -+ * previous ".." entry, which is the first -+ * entry traversed by this scan. If it doesn't -+ * fit, something is badly wrong, so -EIO. */ -+ return -EIO; -+ } - de = (struct ext4_dir_entry_2 *)((char *)de + rlen); - offset += rlen; - } -@@ -1697,12 +1723,12 @@ int ext4_find_dest_de(struct inode *dir, - void ext4_insert_dentry(struct inode *inode, - struct ext4_dir_entry_2 *de, - int buf_size, -- const char *name, int namelen) -+ const char *name, int namelen, void *data) - { - - int nlen, rlen; - -- nlen = EXT4_DIR_REC_LEN(de->name_len); -+ nlen = EXT4_DIR_REC_LEN(de); - rlen = ext4_rec_len_from_disk(de->rec_len, buf_size); - if (de->inode) { - struct ext4_dir_entry_2 *de1 = -@@ -1716,6 +1742,11 @@ void ext4_insert_dentry(struct inode *in - ext4_set_de_type(inode->i_sb, de, inode->i_mode); - de->name_len = namelen; - memcpy(de->name, name, namelen); -+ if (data) { -+ de->name[namelen] = 0; -+ memcpy(&de->name[namelen + 1], data, *(char *)data); -+ de->file_type |= EXT4_DIRENT_LUFID; -+ } - } - /* - * Add a new entry into a directory (leaf) block. If de is non-NULL, -@@ -1734,15 +1765,20 @@ static int add_dirent_to_buf(handle_t *h - int namelen = dentry->d_name.len; - unsigned int blocksize = dir->i_sb->s_blocksize; - int csum_size = 0; -- int err; -+ int err, dlen = 0; -+ unsigned char *data; - -+ data = ext4_dentry_get_data(inode->i_sb, (struct ext4_dentry_param *) -+ dentry->d_fsdata); - if (ext4_has_metadata_csum(inode->i_sb)) - csum_size = sizeof(struct ext4_dir_entry_tail); - - if (!de) { -+ if (data) -+ dlen = (*data) + 1; - err = ext4_find_dest_de(dir, inode, - bh, bh->b_data, blocksize - csum_size, -- name, namelen, &de); -+ name, namelen, &de, &dlen); - if (err) - return err; - } -@@ -1755,7 +1791,10 @@ static int add_dirent_to_buf(handle_t *h - } - - /* By now the buffer is marked for journaling */ -- ext4_insert_dentry(inode, de, blocksize, name, namelen); -+ /* If writing the short form of "dotdot", don't add the data section */ -+ if (dlen == 1) -+ data = NULL; -+ ext4_insert_dentry(inode, de, blocksize, name, namelen, data); - - /* - * XXX shouldn't update any times until successful -@@ -1866,7 +1905,8 @@ static int make_indexed_dir(handle_t *ha - - dx_set_block(entries, 1); - dx_set_count(entries, 1); -- dx_set_limit(entries, dx_root_limit(dir, sizeof(*dx_info))); -+ dx_set_limit(entries, dx_root_limit(dir, -+ dot_de, sizeof(*dx_info))); - - /* Initialize as for dx_probe */ - hinfo.hash_version = dx_info->hash_version; -@@ -1909,6 +1949,8 @@ static int ext4_update_dotdot(handle_t * - struct buffer_head * dir_block; - struct ext4_dir_entry_2 * de; - int len, journal = 0, err = 0; -+ int dlen = 0; -+ char *data; - - if (IS_ERR(handle)) - return PTR_ERR(handle); -@@ -1924,19 +1966,24 @@ static int ext4_update_dotdot(handle_t * - /* the first item must be "." */ - assert(de->name_len == 1 && de->name[0] == '.'); - len = le16_to_cpu(de->rec_len); -- assert(len >= EXT4_DIR_REC_LEN(1)); -- if (len > EXT4_DIR_REC_LEN(1)) { -+ assert(len >= __EXT4_DIR_REC_LEN(1)); -+ if (len > __EXT4_DIR_REC_LEN(1)) { - BUFFER_TRACE(dir_block, "get_write_access"); - err = ext4_journal_get_write_access(handle, dir_block); - if (err) - goto out_journal; - - journal = 1; -- de->rec_len = cpu_to_le16(EXT4_DIR_REC_LEN(1)); -+ de->rec_len = cpu_to_le16(EXT4_DIR_REC_LEN(de)); - } - -- len -= EXT4_DIR_REC_LEN(1); -- assert(len == 0 || len >= EXT4_DIR_REC_LEN(2)); -+ len -= EXT4_DIR_REC_LEN(de); -+ data = ext4_dentry_get_data(dir->i_sb, -+ (struct ext4_dentry_param *)dentry->d_fsdata); -+ if (data) -+ dlen = *data + 1; -+ assert(len == 0 || len >= __EXT4_DIR_REC_LEN(2 + dlen)); -+ - de = (struct ext4_dir_entry_2 *) - ((char *) de + le16_to_cpu(de->rec_len)); - if (!journal) { -@@ -1950,10 +1997,15 @@ static int ext4_update_dotdot(handle_t * - if (len > 0) - de->rec_len = cpu_to_le16(len); - else -- assert(le16_to_cpu(de->rec_len) >= EXT4_DIR_REC_LEN(2)); -+ assert(le16_to_cpu(de->rec_len) >= __EXT4_DIR_REC_LEN(2)); - de->name_len = 2; - strcpy(de->name, ".."); -- ext4_set_de_type(dir->i_sb, de, S_IFDIR); -+ if (data != NULL && ext4_get_dirent_data_len(de) >= dlen) { -+ de->name[2] = 0; -+ memcpy(&de->name[2 + 1], data, *data); -+ ext4_set_de_type(dir->i_sb, de, S_IFDIR); -+ de->file_type |= EXT4_DIRENT_LUFID; -+ } - - out_journal: - if (journal) { -@@ -2428,30 +2480,61 @@ retry: - return err; - } - -+struct tp_block { -+ struct inode *inode; -+ void *data1; -+ void *data2; -+}; -+ - struct ext4_dir_entry_2 *ext4_init_dot_dotdot(struct inode *inode, - struct ext4_dir_entry_2 *de, - int blocksize, int csum_size, - unsigned int parent_ino, int dotdot_real_len) - { -+ void *data1 = NULL, *data2 = NULL; -+ int dot_reclen = 0; -+ -+ if (dotdot_real_len == 10) { -+ struct tp_block *tpb = (struct tp_block *)inode; -+ data1 = tpb->data1; -+ data2 = tpb->data2; -+ inode = tpb->inode; -+ dotdot_real_len = 0; -+ } - de->inode = cpu_to_le32(inode->i_ino); - de->name_len = 1; -- de->rec_len = ext4_rec_len_to_disk(EXT4_DIR_REC_LEN(de->name_len), -- blocksize); - strcpy(de->name, "."); - ext4_set_de_type(inode->i_sb, de, S_IFDIR); - -+ /* get packed fid data*/ -+ data1 = ext4_dentry_get_data(inode->i_sb, -+ (struct ext4_dentry_param *) data1); -+ if (data1) { -+ de->name[1] = 0; -+ memcpy(&de->name[2], data1, *(char *) data1); -+ de->file_type |= EXT4_DIRENT_LUFID; -+ } -+ de->rec_len = cpu_to_le16(EXT4_DIR_REC_LEN(de)); -+ dot_reclen = cpu_to_le16(de->rec_len); - de = ext4_next_entry(de, blocksize); - de->inode = cpu_to_le32(parent_ino); - de->name_len = 2; -+ strcpy(de->name, ".."); -+ ext4_set_de_type(inode->i_sb, de, S_IFDIR); -+ data2 = ext4_dentry_get_data(inode->i_sb, -+ (struct ext4_dentry_param *) data2); -+ if (data2) { -+ de->name[2] = 0; -+ memcpy(&de->name[3], data2, *(char *) data2); -+ de->file_type |= EXT4_DIRENT_LUFID; -+ } - if (!dotdot_real_len) - de->rec_len = ext4_rec_len_to_disk(blocksize - -- (csum_size + EXT4_DIR_REC_LEN(1)), -+ (csum_size + dot_reclen), - blocksize); - else - de->rec_len = ext4_rec_len_to_disk( -- EXT4_DIR_REC_LEN(de->name_len), blocksize); -+ EXT4_DIR_REC_LEN(de), blocksize); -- strcpy(de->name, ".."); -- ext4_set_de_type(inode->i_sb, de, S_IFDIR); - - return ext4_next_entry(de, blocksize); - } -@@ -2457,8 +2540,10 @@ struct ext4_dir_entry_2 *ext4_init_dot_d - } - - static int ext4_init_new_dir(handle_t *handle, struct inode *dir, -- struct inode *inode) -+ struct inode *inode, -+ const void *data1, const void *data2) - { -+ struct tp_block param; - struct buffer_head *dir_block = NULL; - struct ext4_dir_entry_2 *de; - struct ext4_dir_entry_tail *t; -@@ -2488,7 +2573,11 @@ static int ext4_init_new_dir(handle_t *h - if (err) - goto out; - de = (struct ext4_dir_entry_2 *)dir_block->b_data; -- ext4_init_dot_dotdot(inode, de, blocksize, csum_size, dir->i_ino, 0); -+ param.inode = inode; -+ param.data1 = (void *)data1; -+ param.data2 = (void *)data2; -+ ext4_init_dot_dotdot((struct inode *)(¶m), de, blocksize, -+ csum_size, dir->i_ino, 10); - set_nlink(inode, 2); - if (csum_size) { - t = EXT4_DIRENT_TAIL(dir_block->b_data, blocksize); -@@ -2402,6 +2426,29 @@ out: - return err; - } - -+/* Initialize @inode as a subdirectory of @dir, and add the -+ * "." and ".." entries into the first directory block. */ -+int ext4_add_dot_dotdot(handle_t *handle, struct inode *dir, -+ struct inode *inode, -+ const void *data1, const void *data2) -+{ -+ int rc; -+ -+ if (IS_ERR(handle)) -+ return PTR_ERR(handle); -+ -+ if (IS_DIRSYNC(dir)) -+ ext4_handle_sync(handle); -+ -+ inode->i_op = &ext4_dir_inode_operations.ops; -+ inode->i_fop = &ext4_dir_operations; -+ rc = ext4_init_new_dir(handle, dir, inode, data1, data2); -+ if (!rc) -+ rc = ext4_mark_inode_dirty(handle, inode); -+ return rc; -+} -+EXPORT_SYMBOL(ext4_add_dot_dotdot); -+ - static int ext4_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) - { - handle_t *handle; -@@ -2546,7 +2636,7 @@ retry: - - inode->i_op = &ext4_dir_inode_operations; - inode->i_fop = &ext4_dir_operations; -- err = ext4_init_new_dir(handle, dir, inode); -+ err = ext4_init_new_dir(handle, dir, inode, NULL, NULL); - if (err) - goto out_clear_inode; - err = ext4_mark_inode_dirty(handle, inode); -@@ -2598,7 +2688,7 @@ static int empty_dir(struct inode *inode - } - - sb = inode->i_sb; -- if (inode->i_size < EXT4_DIR_REC_LEN(1) + EXT4_DIR_REC_LEN(2)) { -+ if (inode->i_size < __EXT4_DIR_REC_LEN(1) + __EXT4_DIR_REC_LEN(2)) { - EXT4_ERROR_INODE(inode, "invalid size"); - return 1; - } -Index: linux-3.10.0-123.13.2.el7.x86_64/fs/ext4/inline.c -=================================================================== ---- linux-3.10.0-123.13.2.el7.x86_64.orig/fs/ext4/inline.c -+++ linux-3.10.0-123.13.2.el7.x86_64/fs/ext4/inline.c -@@ -988,7 +998,7 @@ static int ext4_add_dirent_to_inline(han - - err = ext4_find_dest_de(dir, inode, iloc->bh, - inline_start, inline_size, -- name, namelen, &de); -+ name, namelen, &de, NULL); - if (err) - return err; - -@@ -998,7 +998,7 @@ static int ext4_add_dirent_to_inline(han - err = ext4_journal_get_write_access(handle, iloc->bh); - if (err) - return err; -- ext4_insert_dentry(inode, de, inline_size, name, namelen); -+ ext4_insert_dentry(inode, de, inline_size, name, namelen, NULL); - - ext4_show_inline_dir(dir, iloc->bh, inline_start, inline_size); - -@@ -1078,7 +1078,7 @@ static int ext4_update_inline_dir(handle - int old_size = EXT4_I(dir)->i_inline_size - EXT4_MIN_INLINE_DATA_SIZE; - int new_size = get_max_inline_xattr_value_size(dir, iloc); - -- if (new_size - old_size <= EXT4_DIR_REC_LEN(1)) -+ if (new_size - old_size <= __EXT4_DIR_REC_LEN(1)) - return -ENOSPC; - - ret = ext4_update_inline_data(handle, dir, -@@ -1348,7 +1348,7 @@ int htree_inlinedir_to_tree(struct file - fake.name_len = 1; - strcpy(fake.name, "."); - fake.rec_len = ext4_rec_len_to_disk( -- EXT4_DIR_REC_LEN(fake.name_len), -+ EXT4_DIR_REC_LEN(&fake), - inline_size); - ext4_set_de_type(inode->i_sb, &fake, S_IFDIR); - de = &fake; -@@ -1358,7 +1358,7 @@ int htree_inlinedir_to_tree(struct file - fake.name_len = 2; - strcpy(fake.name, ".."); - fake.rec_len = ext4_rec_len_to_disk( -- EXT4_DIR_REC_LEN(fake.name_len), -+ EXT4_DIR_REC_LEN(&fake), - inline_size); - ext4_set_de_type(inode->i_sb, &fake, S_IFDIR); - de = &fake; -@@ -1455,8 +1455,8 @@ int ext4_read_inline_dir(struct file *fi - * So we will use extra_offset and extra_size to indicate them - * during the inline dir iteration. - */ -- dotdot_offset = EXT4_DIR_REC_LEN(1); -- dotdot_size = dotdot_offset + EXT4_DIR_REC_LEN(2); -+ dotdot_offset = __EXT4_DIR_REC_LEN(1); -+ dotdot_size = dotdot_offset + __EXT4_DIR_REC_LEN(2); - extra_offset = dotdot_size - EXT4_INLINE_DOTDOT_SIZE; - extra_size = extra_offset + inline_size; - -@@ -1493,7 +1493,7 @@ revalidate: - * failure will be detected in the - * dirent test below. */ - if (ext4_rec_len_from_disk(de->rec_len, -- extra_size) < EXT4_DIR_REC_LEN(1)) -+ extra_size) < __EXT4_DIR_REC_LEN(1)) - break; - i += ext4_rec_len_from_disk(de->rec_len, - extra_size); -Index: linux-3.10.0-123.13.2.el7.x86_64/fs/ext4/super.c -=================================================================== ---- linux-3.10.0-123.13.2.el7.x86_64.orig/fs/ext4/super.c -+++ linux-3.10.0-123.13.2.el7.x86_64/fs/ext4/super.c -@@ -1151,7 +1151,7 @@ enum { - Opt_data_err_abort, Opt_data_err_ignore, - Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota, - Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota, -- Opt_noquota, Opt_barrier, Opt_nobarrier, Opt_err, -+ Opt_noquota, Opt_barrier, Opt_nobarrier, Opt_err, Opt_dirdata, - Opt_usrquota, Opt_grpquota, Opt_i_version, - Opt_stripe, Opt_delalloc, Opt_nodelalloc, Opt_mblk_io_submit, - Opt_nomblk_io_submit, Opt_block_validity, Opt_noblock_validity, -@@ -1216,6 +1216,7 @@ static const match_table_t tokens = { - {Opt_stripe, "stripe=%u"}, - {Opt_delalloc, "delalloc"}, - {Opt_nodelalloc, "nodelalloc"}, -+ {Opt_dirdata, "dirdata"}, - {Opt_removed, "mblk_io_submit"}, - {Opt_removed, "nomblk_io_submit"}, - {Opt_block_validity, "block_validity"}, -@@ -1424,6 +1425,7 @@ static const struct mount_opts { - {Opt_usrjquota, 0, MOPT_Q}, - {Opt_grpjquota, 0, MOPT_Q}, - {Opt_offusrjquota, 0, MOPT_Q}, -+ {Opt_dirdata, EXT4_MOUNT_DIRDATA, MOPT_SET}, - {Opt_offgrpjquota, 0, MOPT_Q}, - {Opt_jqfmt_vfsold, QFMT_VFS_OLD, MOPT_QFMT}, - {Opt_jqfmt_vfsv0, QFMT_VFS_V0, MOPT_QFMT}, diff --git a/ldiskfs/kernel_patches/patches/rhel7/ext4-disable-mb-cache.patch b/ldiskfs/kernel_patches/patches/rhel7/ext4-disable-mb-cache.patch deleted file mode 100644 index c8f5dca4..0000000 --- a/ldiskfs/kernel_patches/patches/rhel7/ext4-disable-mb-cache.patch +++ /dev/null @@ -1,157 +0,0 @@ -mbcache provides absolutely no value for Lustre xattrs (because -they are unique and cannot be shared between files) and as we can -see it has a noticable overhead in some cases. In the past there -was a CONFIG_MBCACHE option that would allow it to be disabled, -but this was removed in newer kernels, so we will need to patch -ldiskfs to fix this. - -Index: linux-3.10.0-123.13.2.el7.x86_64/fs/ext4/ext4.h -=================================================================== ---- linux-3.10.0-123.13.2.el7.x86_64.orig/fs/ext4/ext4.h -+++ linux-3.10.0-123.13.2.el7.x86_64/fs/ext4/ext4.h -@@ -944,6 +944,7 @@ struct ext4_inode_info { - /* - * Mount flags set via mount options or defaults - */ -+#define EXT4_MOUNT_NO_MBCACHE 0x00001 /* Disable mbcache */ - #define EXT4_MOUNT_GRPID 0x00004 /* Create files with directory's group */ - #define EXT4_MOUNT_DEBUG 0x00008 /* Some debugging messages */ - #define EXT4_MOUNT_ERRORS_CONT 0x00010 /* Continue on errors */ -Index: linux-3.10.0-123.13.2.el7.x86_64/fs/ext4/super.c -=================================================================== ---- linux-3.10.0-123.13.2.el7.x86_64.orig/fs/ext4/super.c -+++ linux-3.10.0-123.13.2.el7.x86_64/fs/ext4/super.c -@@ -1157,6 +1157,7 @@ enum { - Opt_nomblk_io_submit, Opt_block_validity, Opt_noblock_validity, - Opt_inode_readahead_blks, Opt_journal_ioprio, - Opt_dioread_nolock, Opt_dioread_lock, -+ Opt_no_mbcache, - Opt_discard, Opt_nodiscard, Opt_init_itable, Opt_noinit_itable, - Opt_max_dir_size_kb, - }; -@@ -1231,6 +1232,7 @@ static const match_table_t tokens = { - {Opt_discard, "discard"}, - {Opt_nodiscard, "nodiscard"}, - {Opt_init_itable, "init_itable=%u"}, -+ {Opt_no_mbcache, "no_mbcache"}, - {Opt_init_itable, "init_itable"}, - {Opt_noinit_itable, "noinit_itable"}, - {Opt_max_dir_size_kb, "max_dir_size_kb=%u"}, -@@ -1390,6 +1392,7 @@ static const struct mount_opts { - {Opt_noauto_da_alloc, EXT4_MOUNT_NO_AUTO_DA_ALLOC, MOPT_SET}, - {Opt_auto_da_alloc, EXT4_MOUNT_NO_AUTO_DA_ALLOC, MOPT_CLEAR}, - {Opt_noinit_itable, EXT4_MOUNT_INIT_INODE_TABLE, MOPT_CLEAR}, -+ {Opt_no_mbcache, EXT4_MOUNT_NO_MBCACHE, MOPT_SET}, - {Opt_commit, 0, MOPT_GTE0}, - {Opt_max_batch_time, 0, MOPT_GTE0}, - {Opt_min_batch_time, 0, MOPT_GTE0}, -Index: linux-3.10.0-123.13.2.el7.x86_64/fs/ext4/xattr.c -=================================================================== ---- linux-3.10.0-123.13.2.el7.x86_64.orig/fs/ext4/xattr.c -+++ linux-3.10.0-123.13.2.el7.x86_64/fs/ext4/xattr.c -@@ -81,7 +81,8 @@ - # define ea_bdebug(bh, fmt, ...) no_printk(fmt, ##__VA_ARGS__) - #endif - --static void ext4_xattr_cache_insert(struct buffer_head *); -+static void ext4_xattr_cache_insert(struct super_block *, -+ struct buffer_head *); - static struct buffer_head *ext4_xattr_cache_find(struct inode *, - struct ext4_xattr_header *, - struct mb_cache_entry **); -@@ -385,7 +386,7 @@ bad_block: - error = -EIO; - goto cleanup; - } -- ext4_xattr_cache_insert(bh); -+ ext4_xattr_cache_insert(inode->i_sb, bh); - entry = BFIRST(bh); - error = ext4_xattr_find_entry(&entry, name_index, name, bh->b_size, 1, - inode); -@@ -546,7 +547,7 @@ ext4_xattr_block_list(struct dentry *den - error = -EIO; - goto cleanup; - } -- ext4_xattr_cache_insert(bh); -+ ext4_xattr_cache_insert(inode->i_sb, bh); - error = ext4_xattr_list_entries(dentry, BFIRST(bh), buffer, buffer_size); - - cleanup: -@@ -643,7 +644,9 @@ ext4_xattr_release_block(handle_t *handl - struct mb_cache_entry *ce = NULL; - int error = 0; - -- ce = mb_cache_entry_get(ext4_xattr_cache, bh->b_bdev, bh->b_blocknr); -+ if (!test_opt(inode->i_sb, NO_MBCACHE)) -+ ce = mb_cache_entry_get(ext4_xattr_cache, bh->b_bdev, -+ bh->b_blocknr); - BUFFER_TRACE(bh, "get_write_access"); - error = ext4_journal_get_write_access(handle, bh); - if (error) -@@ -1037,8 +1040,10 @@ ext4_xattr_block_set(handle_t *handle, s - #define header(x) ((struct ext4_xattr_header *)(x)) - - if (s->base) { -- ce = mb_cache_entry_get(ext4_xattr_cache, bs->bh->b_bdev, -- bs->bh->b_blocknr); -+ if (!test_opt(inode->i_sb, NO_MBCACHE)) -+ ce = mb_cache_entry_get(ext4_xattr_cache, -+ bs->bh->b_bdev, -+ bs->bh->b_blocknr); - BUFFER_TRACE(bs->bh, "get_write_access"); - error = ext4_journal_get_write_access(handle, bs->bh); - if (error) -@@ -1055,7 +1060,7 @@ ext4_xattr_block_set(handle_t *handle, s - if (!IS_LAST_ENTRY(s->first)) - ext4_xattr_rehash(header(s->base), - s->here); -- ext4_xattr_cache_insert(bs->bh); -+ ext4_xattr_cache_insert(sb, bs->bh); - } - unlock_buffer(bs->bh); - if (error == -EIO) -@@ -1138,7 +1143,8 @@ inserted: - if (error) - goto cleanup_dquot; - } -- mb_cache_entry_release(ce); -+ if (ce) -+ mb_cache_entry_release(ce); - ce = NULL; - } else if (bs->bh && s->base == bs->bh->b_data) { - /* We were modifying this block in-place. */ -@@ -1191,7 +1197,7 @@ getblk_failed: - memcpy(new_bh->b_data, s->base, new_bh->b_size); - set_buffer_uptodate(new_bh); - unlock_buffer(new_bh); -- ext4_xattr_cache_insert(new_bh); -+ ext4_xattr_cache_insert(sb, new_bh); - error = ext4_handle_dirty_xattr_block(handle, - inode, new_bh); - if (error) -@@ -1938,12 +1944,15 @@ ext4_xattr_put_super(struct super_block - * Returns 0, or a negative error number on failure. - */ - static void --ext4_xattr_cache_insert(struct buffer_head *bh) -+ext4_xattr_cache_insert(struct super_block *sb, struct buffer_head *bh) - { - __u32 hash = le32_to_cpu(BHDR(bh)->h_hash); - struct mb_cache_entry *ce; - int error; - -+ if (test_opt(sb, NO_MBCACHE)) -+ return; -+ - ce = mb_cache_entry_alloc(ext4_xattr_cache, GFP_NOFS); - if (!ce) { - ea_bdebug(bh, "out of memory"); -@@ -2016,6 +2025,8 @@ ext4_xattr_cache_find(struct inode *inod - __u32 hash = le32_to_cpu(header->h_hash); - struct mb_cache_entry *ce; - -+ if (test_opt(inode->i_sb, NO_MBCACHE)) -+ return NULL; - if (!header->h_hash) - return NULL; /* never share */ - ea_idebug(inode, "looking for cached blocks [%x]", (int)hash); diff --git a/ldiskfs/kernel_patches/patches/rhel7/ext4-fix-xattr-shifting-when-expanding-inodes.patch b/ldiskfs/kernel_patches/patches/rhel7/ext4-fix-xattr-shifting-when-expanding-inodes.patch deleted file mode 100644 index 6f36e90..0000000 --- a/ldiskfs/kernel_patches/patches/rhel7/ext4-fix-xattr-shifting-when-expanding-inodes.patch +++ /dev/null @@ -1,444 +0,0 @@ -From d0141191a20289f8955c1e03dad08e42e6f71ca9 Mon Sep 17 00:00:00 2001 -From: Jan Kara -Date: Thu, 11 Aug 2016 11:50:30 -0400 -Subject: [PATCH] ext4: fix xattr shifting when expanding inodes - -The code in ext4_expand_extra_isize_ea() treated new_extra_isize -argument sometimes as the desired target i_extra_isize and sometimes as -the amount by which we need to grow current i_extra_isize. These happen -to coincide when i_extra_isize is 0 which used to be the common case and -so nobody noticed this until recently when we added i_projid to the -inode and so i_extra_isize now needs to grow from 28 to 32 bytes. - -The result of these bugs was that we sometimes unnecessarily decided to -move xattrs out of inode even if there was enough space and we often -ended up corrupting in-inode xattrs because arguments to -ext4_xattr_shift_entries() were just wrong. This could demonstrate -itself as BUG_ON in ext4_xattr_shift_entries() triggering. - -Fix the problem by introducing new isize_diff variable and use it where -appropriate. - -CC: stable@vger.kernel.org # 4.4.x -Reported-by: Dave Chinner -Signed-off-by: Jan Kara -Signed-off-by: Theodore Ts'o ---- - fs/ext4/xattr.c | 27 ++++++++++++++------------- - 1 file changed, 14 insertions(+), 13 deletions(-) - -diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c -index 39e9cfb..cb1d7b4 100644 ---- a/fs/ext4/xattr.c -+++ b/fs/ext4/xattr.c -@@ -1353,15 +1353,17 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize, - size_t min_offs, free; - int total_ino; - void *base, *start, *end; -- int extra_isize = 0, error = 0, tried_min_extra_isize = 0; -+ int error = 0, tried_min_extra_isize = 0; - int s_min_extra_isize = le16_to_cpu(EXT4_SB(inode->i_sb)->s_es->s_min_extra_isize); -+ int isize_diff; /* How much do we need to grow i_extra_isize */ - - down_write(&EXT4_I(inode)->xattr_sem); - /* - * Set EXT4_STATE_NO_EXPAND to avoid recursion when marking inode dirty - */ - ext4_set_inode_state(inode, EXT4_STATE_NO_EXPAND); - retry: -+ isize_diff = new_extra_isize - EXT4_I(inode)->i_extra_isize; - if (EXT4_I(inode)->i_extra_isize >= new_extra_isize) - goto out; - -@@ -1382,7 +1384,7 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize, - goto cleanup; - - free = ext4_xattr_free_space(last, &min_offs, base, &total_ino); -- if (free >= new_extra_isize) { -+ if (free >= isize_diff) { - entry = IFIRST(header); - ext4_xattr_shift_entries(entry, EXT4_I(inode)->i_extra_isize - - new_extra_isize, (void *)raw_inode + -@@ -1414,7 +1416,7 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize, - end = bh->b_data + bh->b_size; - min_offs = end - base; - free = ext4_xattr_free_space(first, &min_offs, base, NULL); -- if (free < new_extra_isize) { -+ if (free < isize_diff) { - if (!tried_min_extra_isize && s_min_extra_isize) { - tried_min_extra_isize++; - new_extra_isize = s_min_extra_isize; -@@ -1428,7 +1430,7 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize, - free = inode->i_sb->s_blocksize; - } - -- while (new_extra_isize > 0) { -+ while (isize_diff > 0) { - size_t offs, size, entry_size; - struct ext4_xattr_entry *small_entry = NULL; - struct ext4_xattr_info i = { -@@ -1459,7 +1461,7 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize, - EXT4_XATTR_SIZE(le32_to_cpu(last->e_value_size)) + - EXT4_XATTR_LEN(last->e_name_len); - if (total_size <= free && total_size < min_total_size) { -- if (total_size < new_extra_isize) { -+ if (total_size < isize_diff) { - small_entry = last; - } else { - entry = last; -@@ -1516,20 +1518,19 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize, - goto cleanup; - - entry = IFIRST(header); -- if (entry_size + EXT4_XATTR_SIZE(size) >= new_extra_isize) -- shift_bytes = new_extra_isize; -+ if (entry_size + EXT4_XATTR_SIZE(size) >= isize_diff) -+ shift_bytes = isize_diff; - else - shift_bytes = entry_size + size; - /* Adjust the offsets and shift the remaining entries ahead */ -- ext4_xattr_shift_entries(entry, EXT4_I(inode)->i_extra_isize - -- shift_bytes, (void *)raw_inode + -- EXT4_GOOD_OLD_INODE_SIZE + extra_isize + shift_bytes, -+ ext4_xattr_shift_entries(entry, -shift_bytes, -+ (void *)raw_inode + EXT4_GOOD_OLD_INODE_SIZE + -+ EXT4_I(inode)->i_extra_isize + shift_bytes, - (void *)header, total_ino - entry_size, - inode->i_sb->s_blocksize); - -- extra_isize += shift_bytes; -- new_extra_isize -= shift_bytes; -- EXT4_I(inode)->i_extra_isize = extra_isize; -+ isize_diff -= shift_bytes; -+ EXT4_I(inode)->i_extra_isize += shift_bytes; - - i.name = b_entry_name; - i.value = buffer; --- -2.9.3 - -From 418c12d08dc64a45107c467ec1ba29b5e69b0715 Mon Sep 17 00:00:00 2001 -From: Jan Kara -Date: Thu, 11 Aug 2016 11:58:32 -0400 -Subject: [PATCH] ext4: fix xattr shifting when expanding inodes part 2 - -When multiple xattrs need to be moved out of inode, we did not properly -recompute total size of xattr headers in the inode and the new header -position. Thus when moving the second and further xattr we asked -ext4_xattr_shift_entries() to move too much and from the wrong place, -resulting in possible xattr value corruption or general memory -corruption. - -CC: stable@vger.kernel.org # 4.4.x -Signed-off-by: Jan Kara -Signed-off-by: Theodore Ts'o ---- - fs/ext4/xattr.c | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c -index cb1d7b4..b18b1ff 100644 ---- a/fs/ext4/xattr.c -+++ b/fs/ext4/xattr.c -@@ -1516,6 +1516,7 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize, - error = ext4_xattr_ibody_set(handle, inode, &i, is); - if (error) - goto cleanup; -+ total_ino -= entry_size; - - entry = IFIRST(header); - if (entry_size + EXT4_XATTR_SIZE(size) >= isize_diff) -@@ -1526,11 +1527,11 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize, - ext4_xattr_shift_entries(entry, -shift_bytes, - (void *)raw_inode + EXT4_GOOD_OLD_INODE_SIZE + - EXT4_I(inode)->i_extra_isize + shift_bytes, -- (void *)header, total_ino - entry_size, -- inode->i_sb->s_blocksize); -+ (void *)header, total_ino, inode->i_sb->s_blocksize); - - isize_diff -= shift_bytes; - EXT4_I(inode)->i_extra_isize += shift_bytes; -+ header = IHDR(inode, raw_inode); - - i.name = b_entry_name; - i.value = buffer; --- -2.9.3 - -From 443a8c41cd49de66a3fda45b32b9860ea0292b84 Mon Sep 17 00:00:00 2001 -From: Jan Kara -Date: Thu, 11 Aug 2016 12:00:01 -0400 -Subject: [PATCH] ext4: properly align shifted xattrs when expanding inodes - -We did not count with the padding of xattr value when computing desired -shift of xattrs in the inode when expanding i_extra_isize. As a result -we could create unaligned start of inline xattrs. Account for alignment -properly. - -CC: stable@vger.kernel.org # 4.4.x- -Signed-off-by: Jan Kara ---- - fs/ext4/xattr.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c -index b18b1ff..c893f00 100644 ---- a/fs/ext4/xattr.c -+++ b/fs/ext4/xattr.c -@@ -1522,7 +1522,7 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize, - if (entry_size + EXT4_XATTR_SIZE(size) >= isize_diff) - shift_bytes = isize_diff; - else -- shift_bytes = entry_size + size; -+ shift_bytes = entry_size + EXT4_XATTR_SIZE(size); - /* Adjust the offsets and shift the remaining entries ahead */ - ext4_xattr_shift_entries(entry, -shift_bytes, - (void *)raw_inode + EXT4_GOOD_OLD_INODE_SIZE + --- -2.9.3 - -From e3014d14a81edde488d9a6758eea8afc41752d2d Mon Sep 17 00:00:00 2001 -From: Jan Kara -Date: Mon, 29 Aug 2016 15:38:11 -0400 -Subject: [PATCH] ext4: fixup free space calculations when expanding inodes - -Conditions checking whether there is enough free space in an xattr block -and when xattr is large enough to make enough space in the inode forgot -to account for the fact that inode need not be completely filled up with -xattrs. Thus we could move unnecessarily many xattrs out of inode or -even falsely claim there is not enough space to expand the inode. We -also forgot to update the amount of free space in xattr block when moving -more xattrs and thus could decide to move too big xattr resulting in -unexpected failure. - -Fix these problems by properly updating free space in the inode and -xattr block as we move xattrs. To simplify the math, avoid shifting -xattrs after removing each one xattr and instead just shift xattrs only -once there is enough free space in the inode. - -Signed-off-by: Jan Kara -Signed-off-by: Theodore Ts'o ---- - fs/ext4/xattr.c | 58 ++++++++++++++++++++++++--------------------------------- - 1 file changed, 24 insertions(+), 34 deletions(-) - -diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c -index 2eb935c..22d2ebc 100644 ---- a/fs/ext4/xattr.c -+++ b/fs/ext4/xattr.c -@@ -1350,7 +1350,8 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize, - struct ext4_xattr_ibody_find *is = NULL; - struct ext4_xattr_block_find *bs = NULL; - char *buffer = NULL, *b_entry_name = NULL; -- size_t min_offs, free; -+ size_t min_offs; -+ size_t ifree, bfree; - int total_ino; - void *base, *start, *end; - int error = 0, tried_min_extra_isize = 0; -@@ -1385,17 +1386,9 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize, - if (error) - goto cleanup; - -- free = ext4_xattr_free_space(last, &min_offs, base, &total_ino); -- if (free >= isize_diff) { -- entry = IFIRST(header); -- ext4_xattr_shift_entries(entry, EXT4_I(inode)->i_extra_isize -- - new_extra_isize, (void *)raw_inode + -- EXT4_GOOD_OLD_INODE_SIZE + new_extra_isize, -- (void *)header, total_ino, -- inode->i_sb->s_blocksize); -- EXT4_I(inode)->i_extra_isize = new_extra_isize; -- goto out; -- } -+ ifree = ext4_xattr_free_space(last, &min_offs, base, &total_ino); -+ if (ifree >= isize_diff) -+ goto shift; - - /* - * Enough free space isn't available in the inode, check if -@@ -1416,8 +1409,8 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize, - first = BFIRST(bh); - end = bh->b_data + bh->b_size; - min_offs = end - base; -- free = ext4_xattr_free_space(first, &min_offs, base, NULL); -- if (free < isize_diff) { -+ bfree = ext4_xattr_free_space(first, &min_offs, base, NULL); -+ if (bfree + ifree < isize_diff) { - if (!tried_min_extra_isize && s_min_extra_isize) { - tried_min_extra_isize++; - new_extra_isize = s_min_extra_isize; -@@ -1428,10 +1421,10 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize, - goto cleanup; - } - } else { -- free = inode->i_sb->s_blocksize; -+ bfree = inode->i_sb->s_blocksize; - } - -- while (isize_diff > 0) { -+ while (isize_diff > ifree) { - size_t offs, size, entry_size; - struct ext4_xattr_entry *small_entry = NULL; - struct ext4_xattr_info i = { -@@ -1439,7 +1432,6 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize, - .value_len = 0, - }; - unsigned int total_size; /* EA entry size + value size */ -- unsigned int shift_bytes; /* No. of bytes to shift EAs by? */ - unsigned int min_total_size = ~0U; - - is = kzalloc(sizeof(struct ext4_xattr_ibody_find), GFP_NOFS); -@@ -1461,8 +1453,9 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize, - total_size = - EXT4_XATTR_SIZE(le32_to_cpu(last->e_value_size)) + - EXT4_XATTR_LEN(last->e_name_len); -- if (total_size <= free && total_size < min_total_size) { -- if (total_size < isize_diff) { -+ if (total_size <= bfree && -+ total_size < min_total_size) { -+ if (total_size + ifree < isize_diff) { - small_entry = last; - } else { - entry = last; -@@ -1491,6 +1484,7 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize, - offs = le16_to_cpu(entry->e_value_offs); - size = le32_to_cpu(entry->e_value_size); - entry_size = EXT4_XATTR_LEN(entry->e_name_len); -+ total_size = entry_size + EXT4_XATTR_SIZE(size); - i.name_index = entry->e_name_index, - buffer = kmalloc(EXT4_XATTR_SIZE(size), GFP_NOFS); - b_entry_name = kmalloc(entry->e_name_len + 1, GFP_NOFS); -@@ -1518,21 +1512,8 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize, - if (error) - goto cleanup; - total_ino -= entry_size; -- -- entry = IFIRST(header); -- if (entry_size + EXT4_XATTR_SIZE(size) >= isize_diff) -- shift_bytes = isize_diff; -- else -- shift_bytes = entry_size + EXT4_XATTR_SIZE(size); -- /* Adjust the offsets and shift the remaining entries ahead */ -- ext4_xattr_shift_entries(entry, -shift_bytes, -- (void *)raw_inode + EXT4_GOOD_OLD_INODE_SIZE + -- EXT4_I(inode)->i_extra_isize + shift_bytes, -- (void *)header, total_ino, inode->i_sb->s_blocksize); -- -- isize_diff -= shift_bytes; -- EXT4_I(inode)->i_extra_isize += shift_bytes; -- header = IHDR(inode, raw_inode); -+ ifree += total_size; -+ bfree -= total_size; - - i.name = b_entry_name; - i.value = buffer; -@@ -1553,6 +1534,15 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize, - kfree(is); - kfree(bs); - } -+ -+shift: -+ /* Adjust the offsets and shift the remaining entries ahead */ -+ entry = IFIRST(header); -+ ext4_xattr_shift_entries(entry, EXT4_I(inode)->i_extra_isize -+ - new_extra_isize, (void *)raw_inode + -+ EXT4_GOOD_OLD_INODE_SIZE + new_extra_isize, -+ (void *)header, total_ino, inode->i_sb->s_blocksize); -+ EXT4_I(inode)->i_extra_isize = new_extra_isize; - brelse(bh); - out: - ext4_clear_inode_state(inode, EXT4_STATE_NO_EXPAND); --- -2.9.3 - -From 94405713889d4a9d341b4ad92956e4e2ec8ec2c2 Mon Sep 17 00:00:00 2001 -From: Jan Kara -Date: Mon, 29 Aug 2016 15:41:11 -0400 -Subject: [PATCH] ext4: replace bogus assertion in ext4_xattr_shift_entries() - -We were checking whether computed offsets do not exceed end of block in -ext4_xattr_shift_entries(). However this does not make sense since we -always only decrease offsets. So replace that assertion with a check -whether we really decrease xattrs value offsets. - -Signed-off-by: Jan Kara -Signed-off-by: Theodore Ts'o ---- - fs/ext4/xattr.c | 9 +++++---- - 1 file changed, 5 insertions(+), 4 deletions(-) - -diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c -index 1447860..82b025c 100644 ---- a/fs/ext4/xattr.c -+++ b/fs/ext4/xattr.c -@@ -1319,18 +1319,19 @@ ext4_xattr_set(struct inode *inode, int name_index, const char *name, - */ - static void ext4_xattr_shift_entries(struct ext4_xattr_entry *entry, - int value_offs_shift, void *to, -- void *from, size_t n, int blocksize) -+ void *from, size_t n) - { - struct ext4_xattr_entry *last = entry; - int new_offs; - -+ /* We always shift xattr headers further thus offsets get lower */ -+ BUG_ON(value_offs_shift > 0); -+ - /* Adjust the value offsets of the entries */ - for (; !IS_LAST_ENTRY(last); last = EXT4_XATTR_NEXT(last)) { - if (!last->e_value_inum && last->e_value_size) { - new_offs = le16_to_cpu(last->e_value_offs) + - value_offs_shift; -- BUG_ON(new_offs + le32_to_cpu(last->e_value_size) -- > blocksize); - last->e_value_offs = cpu_to_le16(new_offs); - } - } -@@ -1542,7 +1543,7 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize, - ext4_xattr_shift_entries(entry, EXT4_I(inode)->i_extra_isize - - new_extra_isize, (void *)raw_inode + - EXT4_GOOD_OLD_INODE_SIZE + new_extra_isize, -- (void *)header, total_ino, inode->i_sb->s_blocksize); -+ (void *)header, total_ino); - EXT4_I(inode)->i_extra_isize = new_extra_isize; - brelse(bh); - out: --- -2.9.3 - -From 887a9730614727c4fff7cb756711b190593fc1df Mon Sep 17 00:00:00 2001 -From: Konstantin Khlebnikov -Date: Sun, 21 May 2017 22:36:23 -0400 -Subject: [PATCH] ext4: keep existing extra fields when inode expands - -ext4_expand_extra_isize() should clear only space between old and new -size. - -Fixes: 6dd4ee7cab7e # v2.6.23 -Cc: stable@vger.kernel.org -Signed-off-by: Konstantin Khlebnikov -Signed-off-by: Theodore Ts'o ---- - fs/ext4/inode.c | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c -index 1bd0bfa..7cd99de 100644 ---- a/fs/ext4/inode.c -+++ b/fs/ext4/inode.c -@@ -5637,8 +5637,9 @@ static int ext4_expand_extra_isize(struct inode *inode, - /* No extended attributes present */ - if (!ext4_test_inode_state(inode, EXT4_STATE_XATTR) || - header->h_magic != cpu_to_le32(EXT4_XATTR_MAGIC)) { -- memset((void *)raw_inode + EXT4_GOOD_OLD_INODE_SIZE, 0, -- new_extra_isize); -+ memset((void *)raw_inode + EXT4_GOOD_OLD_INODE_SIZE + -+ EXT4_I(inode)->i_extra_isize, 0, -+ new_extra_isize - EXT4_I(inode)->i_extra_isize); - EXT4_I(inode)->i_extra_isize = new_extra_isize; - return 0; - } --- -2.9.3 - diff --git a/ldiskfs/kernel_patches/patches/rhel7/ext4-large-dir.patch b/ldiskfs/kernel_patches/patches/rhel7/ext4-large-dir.patch deleted file mode 100644 index 15c0899..0000000 --- a/ldiskfs/kernel_patches/patches/rhel7/ext4-large-dir.patch +++ /dev/null @@ -1,351 +0,0 @@ -This INCOMPAT_LARGEDIR feature allows larger directories -to be created in ldiskfs, both with directory sizes over -2GB and and a maximum htree depth of 3 instead of the -current limit of 2. These features are needed in order -to exceed the current limit of approximately 10M entries -in a single directory. - -Index: linux-3.10.0-229.1.2.fc21.x86_64/fs/ext4/ext4.h -=================================================================== ---- linux-3.10.0-229.1.2.fc21.x86_64.orig/fs/ext4/ext4.h -+++ linux-3.10.0-229.1.2.fc21.x86_64/fs/ext4/ext4.h -@@ -1585,7 +1585,8 @@ static inline void ext4_clear_state_flag - EXT4_FEATURE_INCOMPAT_EA_INODE| \ - EXT4_FEATURE_INCOMPAT_MMP | \ - EXT4_FEATURE_INCOMPAT_DIRDATA| \ -- EXT4_FEATURE_INCOMPAT_INLINE_DATA) -+ EXT4_FEATURE_INCOMPAT_INLINE_DATA| \ -+ EXT4_FEATURE_INCOMPAT_LARGEDIR) - #define EXT4_FEATURE_RO_COMPAT_SUPP (EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER| \ - EXT4_FEATURE_RO_COMPAT_LARGE_FILE| \ - EXT4_FEATURE_RO_COMPAT_GDT_CSUM| \ -@@ -1999,6 +2000,9 @@ struct mmpd_data { - # define NORET_TYPE /**/ - # define ATTRIB_NORET __attribute__((noreturn)) - # define NORET_AND noreturn, -+/* htree levels for ext4 */ -+#define EXT4_HTREE_LEVEL_COMPAT 2 -+#define EXT4_HTREE_LEVEL 3 - - struct ext4_xattr_ino_array { - unsigned int xia_count; /* # of used item in the array */ -@@ -2472,13 +2476,16 @@ static inline void ext4_r_blocks_count_s - es->s_r_blocks_count_hi = cpu_to_le32(blk >> 32); - } - --static inline loff_t ext4_isize(struct ext4_inode *raw_inode) -+static inline loff_t ext4_isize(struct super_block *sb, -+ struct ext4_inode *raw_inode) - { -- if (S_ISREG(le16_to_cpu(raw_inode->i_mode))) -+ if (S_ISREG(le16_to_cpu(raw_inode->i_mode)) || -+ (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_LARGEDIR) && -+ S_ISDIR(le16_to_cpu(raw_inode->i_mode)))) - return ((loff_t)le32_to_cpu(raw_inode->i_size_high) << 32) | - le32_to_cpu(raw_inode->i_size_lo); -- else -- return (loff_t) le32_to_cpu(raw_inode->i_size_lo); -+ -+ return (loff_t)le32_to_cpu(raw_inode->i_size_lo); - } - - static inline void ext4_isize_set(struct ext4_inode *raw_inode, loff_t i_size) -Index: linux-3.10.0-229.1.2.fc21.x86_64/fs/ext4/namei.c -=================================================================== ---- linux-3.10.0-229.1.2.fc21.x86_64.orig/fs/ext4/namei.c -+++ linux-3.10.0-229.1.2.fc21.x86_64/fs/ext4/namei.c -@@ -513,7 +513,14 @@ struct dx_root_info * dx_get_dx_info(str - - static inline ext4_lblk_t dx_get_block(struct dx_entry *entry) - { -- return le32_to_cpu(entry->block) & 0x00ffffff; -+ return le32_to_cpu(entry->block) & 0x0fffffff; -+} -+ -+static inline int -+ext4_dir_htree_level(struct super_block *sb) -+{ -+ return EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_LARGEDIR) ? -+ EXT4_HTREE_LEVEL : EXT4_HTREE_LEVEL_COMPAT; - } - - static inline void dx_set_block(struct dx_entry *entry, ext4_lblk_t value) -@@ -681,7 +688,7 @@ dx_probe(const struct qstr *d_name, stru - struct dx_frame *frame = frame_in; - u32 hash; - -- frame->bh = NULL; -+ memset(frame_in, 0, EXT4_HTREE_LEVEL * sizeof(frame_in[0])); - bh = ext4_read_dirblock(dir, 0, INDEX); - if (IS_ERR(bh)) { - *err = PTR_ERR(bh); -@@ -714,10 +721,15 @@ dx_probe(const struct qstr *d_name, stru - } - - indirect = info->indirect_levels; -- if (indirect > 1) { -- ext4_warning(dir->i_sb, -- "inode #%lu: unimplemented hash depth %u", -- dir->i_ino, info->indirect_levels); -+ if (indirect >= ext4_dir_htree_level(dir->i_sb)) { -+ ext4_warning(dir->i_sb, -+ "inode #%lu: comm %s: htree depth %#06x exceed max depth %u", -+ dir->i_ino, current->comm, indirect, -+ ext4_dir_htree_level(dir->i_sb)); -+ if (ext4_dir_htree_level(dir->i_sb) < EXT4_HTREE_LEVEL) { -+ ext4_warning(dir->i_sb, "Enable large directory " -+ "feature to access it"); -+ } - brelse(bh); - *err = ERR_BAD_DX_DIR; - goto fail; -@@ -812,13 +826,18 @@ fail: - static void dx_release (struct dx_frame *frames) - { - struct dx_root_info *info; -+ int i; -+ - if (frames[0].bh == NULL) - return; - - info = dx_get_dx_info((struct ext4_dir_entry_2 *)frames[0].bh->b_data); -- if (info->indirect_levels) -- brelse(frames[1].bh); -- brelse(frames[0].bh); -+ for (i = 0; i <= info->indirect_levels; i++) { -+ if (frames[i].bh == NULL) -+ break; -+ brelse(frames[i].bh); -+ frames[i].bh = NULL; -+ } - } - - /* -@@ -960,7 +979,7 @@ int ext4_htree_fill_tree(struct file *di - { - struct dx_hash_info hinfo; - struct ext4_dir_entry_2 *de; -- struct dx_frame frames[2], *frame; -+ struct dx_frame frames[EXT4_HTREE_LEVEL], *frame; - struct inode *dir; - ext4_lblk_t block; - int count = 0; -@@ -1376,7 +1395,7 @@ static struct buffer_head * ext4_dx_find - { - struct super_block * sb = dir->i_sb; - struct dx_hash_info hinfo; -- struct dx_frame frames[2], *frame; -+ struct dx_frame frames[EXT4_HTREE_LEVEL], *frame; - struct buffer_head *bh; - ext4_lblk_t block; - int retval; -@@ -1832,7 +1851,7 @@ static int make_indexed_dir(handle_t *ha - const char *name = dentry->d_name.name; - int namelen = dentry->d_name.len; - struct buffer_head *bh2; -- struct dx_frame frames[2], *frame; -+ struct dx_frame frames[EXT4_HTREE_LEVEL], *frame; - struct dx_entry *entries; - struct ext4_dir_entry_2 *de, *de2, *dot_de, *dotdot_de; - struct ext4_dir_entry_tail *t; -@@ -2117,15 +2136,18 @@ static int ext4_add_entry(handle_t *hand - static int ext4_dx_add_entry(handle_t *handle, struct dentry *dentry, - struct inode *inode) - { -- struct dx_frame frames[2], *frame; -+ struct dx_frame frames[EXT4_HTREE_LEVEL], *frame; - struct dx_entry *entries, *at; - struct dx_hash_info hinfo; - struct buffer_head *bh; - struct inode *dir = dentry->d_parent->d_inode; - struct super_block *sb = dir->i_sb; - struct ext4_dir_entry_2 *de; -+ int restart; - int err; - -+again: -+ restart = 0; - frame = dx_probe(&dentry->d_name, dir, &hinfo, frames, &err); - if (!frame) - return err; -@@ -2138,33 +2160,48 @@ static int ext4_dx_add_entry(handle_t *h - goto cleanup; - } - -- BUFFER_TRACE(bh, "get_write_access"); -- err = ext4_journal_get_write_access(handle, bh); -- if (err) -- goto journal_error; -- - err = add_dirent_to_buf(handle, dentry, inode, NULL, bh); - if (err != -ENOSPC) - goto cleanup; - -+ err = 0; - /* Block full, should compress but for now just split */ - dxtrace(printk(KERN_DEBUG "using %u of %u node entries\n", - dx_get_count(entries), dx_get_limit(entries))); - /* Need to split index? */ - if (dx_get_count(entries) == dx_get_limit(entries)) { - ext4_lblk_t newblock; -- unsigned icount = dx_get_count(entries); -- int levels = frame - frames; -+ int levels = frame - frames + 1; -+ unsigned icount; -+ int add_level = 1; - struct dx_entry *entries2; - struct dx_node *node2; - struct buffer_head *bh2; - -- if (levels && (dx_get_count(frames->entries) == -- dx_get_limit(frames->entries))) { -- ext4_warning(sb, "Directory index full!"); -+ while (frame > frames) { -+ if (dx_get_count((frame - 1)->entries) < -+ dx_get_limit((frame - 1)->entries)) { -+ add_level = 0; -+ break; -+ } -+ frame--; /* split higher index block */ -+ at = frame->at; -+ entries = frame->entries; -+ restart = 1; -+ } -+ if (add_level && levels == ext4_dir_htree_level(sb)) { -+ ext4_warning(sb, "inode %lu: comm %s: index %u: reach max htree level %u", -+ dir->i_ino, current->comm, levels, -+ ext4_dir_htree_level(sb)); -+ if (ext4_dir_htree_level(sb) < EXT4_HTREE_LEVEL) { -+ ext4_warning(sb, "Large directory feature is" -+ "not enabled on this " -+ "filesystem"); -+ } - err = -ENOSPC; - goto cleanup; - } -+ icount = dx_get_count(entries); - bh2 = ext4_append(handle, dir, &newblock); - if (IS_ERR(bh2)) { - err = PTR_ERR(bh2); -@@ -2179,7 +2216,7 @@ static int ext4_dx_add_entry(handle_t *h - err = ext4_journal_get_write_access(handle, frame->bh); - if (err) - goto journal_error; -- if (levels) { -+ if (!add_level) { - unsigned icount1 = icount/2, icount2 = icount - icount1; - unsigned hash2 = dx_get_hash(entries + icount1); - dxtrace(printk(KERN_DEBUG "Split index %i/%i\n", -@@ -2187,7 +2224,7 @@ static int ext4_dx_add_entry(handle_t *h - - BUFFER_TRACE(frame->bh, "get_write_access"); /* index root */ - err = ext4_journal_get_write_access(handle, -- frames[0].bh); -+ (frame - 1)->bh); - if (err) - goto journal_error; - -@@ -2203,19 +2240,27 @@ static int ext4_dx_add_entry(handle_t *h - frame->entries = entries = entries2; - swap(frame->bh, bh2); - } -- dx_insert_block(frames + 0, hash2, newblock); -- dxtrace(dx_show_index("node", frames[1].entries)); -+ dx_insert_block(frame - 1, hash2, newblock); -+ dxtrace(dx_show_index("node", frame->entries)); - dxtrace(dx_show_index("node", -- ((struct dx_node *) bh2->b_data)->entries)); -+ ((struct dx_node *)bh2->b_data)->entries)); - err = ext4_handle_dirty_dx_node(handle, dir, bh2); - if (err) - goto journal_error; - brelse (bh2); -+ err = ext4_handle_dirty_dx_node(handle, dir, -+ (frame - 1)->bh); -+ if (err) -+ goto journal_error; -+ if (restart) { -+ err = ext4_handle_dirty_dx_node(handle, dir, -+ frame->bh); -+ goto journal_error; -+ } - } else { - struct dx_root_info *info; -- dxtrace(printk(KERN_DEBUG -- "Creating second level index...\n")); -- memcpy((char *) entries2, (char *) entries, -+ -+ memcpy((char *)entries2, (char *)entries, - icount * sizeof(struct dx_entry)); - dx_set_limit(entries2, dx_node_limit(dir)); - -@@ -2224,22 +2267,17 @@ static int ext4_dx_add_entry(handle_t *h - dx_set_block(entries + 0, newblock); - info = dx_get_dx_info((struct ext4_dir_entry_2*) - frames[0].bh->b_data); -- info->indirect_levels = 1; -- -- /* Add new access path frame */ -- frame = frames + 1; -- frame->at = at = at - entries + entries2; -- frame->entries = entries = entries2; -- frame->bh = bh2; -- err = ext4_journal_get_write_access(handle, -- frame->bh); -+ info->indirect_levels += 1; -+ dxtrace(printk(KERN_DEBUG -+ "Creating %d level index...\n", -+ info->indirect_levels)); -+ err = ext4_handle_dirty_dx_node(handle, dir, frame->bh); - if (err) - goto journal_error; -- } -- err = ext4_handle_dirty_dx_node(handle, dir, frames[0].bh); -- if (err) { -- ext4_std_error(inode->i_sb, err); -- goto cleanup; -+ err = ext4_handle_dirty_dx_node(handle, dir, bh2); -+ brelse(bh2); -+ restart = 1; -+ goto journal_error; - } - } - de = do_split(handle, dir, &bh, frame, &hinfo, &err); -@@ -2249,10 +2285,14 @@ static int ext4_dx_add_entry(handle_t *h - goto cleanup; - - journal_error: -- ext4_std_error(dir->i_sb, err); -+ ext4_std_error(dir->i_sb, err); /* this is a no-op if err == 0 */ - cleanup: - brelse(bh); - dx_release(frames); -+ /* @restart is true means htree-path has been changed, we need to -+ * repeat dx_probe() to find out valid htree-path */ -+ if (restart && err == 0) -+ goto again; - return err; - } - -Index: linux-3.10.0-229.1.2.fc21.x86_64/fs/ext4/inode.c -=================================================================== ---- linux-3.10.0-229.1.2.fc21.x86_64.orig/fs/ext4/inode.c -+++ linux-3.10.0-229.1.2.fc21.x86_64/fs/ext4/inode.c -@@ -4056,7 +4056,7 @@ struct inode *ext4_iget(struct super_blo - if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_64BIT)) - ei->i_file_acl |= - ((__u64)le16_to_cpu(raw_inode->i_file_acl_high)) << 32; -- inode->i_size = ext4_isize(raw_inode); -+ inode->i_size = ext4_isize(sb, raw_inode); - ei->i_disksize = inode->i_size; - #ifdef CONFIG_QUOTA - ei->i_reserved_quota = 0; -@@ -4306,7 +4306,7 @@ static int ext4_do_update_inode(handle_t - raw_inode->i_file_acl_high = - cpu_to_le16(ei->i_file_acl >> 32); - raw_inode->i_file_acl_lo = cpu_to_le32(ei->i_file_acl); -- if (ei->i_disksize != ext4_isize(raw_inode)) { -+ if (ei->i_disksize != ext4_isize(inode->i_sb, raw_inode)) { - ext4_isize_set(raw_inode, ei->i_disksize); - need_datasync = 1; - } diff --git a/ldiskfs/kernel_patches/patches/rhel7/ext4-large-eas.patch b/ldiskfs/kernel_patches/patches/rhel7/ext4-large-eas.patch deleted file mode 100644 index 5ef75ea..0000000 --- a/ldiskfs/kernel_patches/patches/rhel7/ext4-large-eas.patch +++ /dev/null @@ -1,1097 +0,0 @@ -This patch implements the large EA support in ext4. If the size of -an EA value is larger than the blocksize, then the EA value would -not be saved in the external EA block, instead it would be saved -in an external EA inode. So, the patch also helps support a larger -number of EAs. - -Index: linux-stage/fs/ext4/ext4.h -=================================================================== ---- linux-stage.orig/fs/ext4/ext4.h -+++ linux-stage/fs/ext4/ext4.h -@@ -1579,6 +1579,7 @@ static inline void ext4_clear_state_flag - EXT4_FEATURE_INCOMPAT_EXTENTS| \ - EXT4_FEATURE_INCOMPAT_64BIT| \ - EXT4_FEATURE_INCOMPAT_FLEX_BG| \ -+ EXT4_FEATURE_INCOMPAT_EA_INODE| \ - EXT4_FEATURE_INCOMPAT_MMP | \ - EXT4_FEATURE_INCOMPAT_DIRDATA| \ - EXT4_FEATURE_INCOMPAT_INLINE_DATA) -@@ -1990,6 +1997,10 @@ struct mmpd_data { - # define ATTRIB_NORET __attribute__((noreturn)) - # define NORET_AND noreturn, - -+struct ext4_xattr_ino_array { -+ unsigned int xia_count; /* # of used item in the array */ -+ unsigned int xia_inodes[0]; -+}; - /* bitmap.c */ - extern unsigned int ext4_count_free(char *bitmap, unsigned numchars); - void ext4_inode_bitmap_csum_set(struct super_block *sb, ext4_group_t group, -@@ -2194,6 +2205,7 @@ extern void ext4_set_inode_flags(struct - extern void ext4_get_inode_flags(struct ext4_inode_info *); - extern int ext4_alloc_da_blocks(struct inode *inode); - extern void ext4_set_aops(struct inode *inode); -+extern int ext4_meta_trans_blocks(struct inode *, int nrblocks, int chunk); - extern int ext4_writepage_trans_blocks(struct inode *); - extern int ext4_chunk_trans_blocks(struct inode *, int nrblocks); - extern int ext4_zero_partial_blocks(handle_t *handle, struct inode *inode, -Index: linux-stage/fs/ext4/inode.c -=================================================================== ---- linux-stage.orig/fs/ext4/inode.c -+++ linux-stage/fs/ext4/inode.c -@@ -134,8 +134,6 @@ static void ext4_invalidatepage(struct p - unsigned int length); - static int __ext4_journalled_writepage(struct page *page, unsigned int len); - static int ext4_bh_delay_or_unwritten(handle_t *handle, struct buffer_head *bh); --static int ext4_meta_trans_blocks(struct inode *inode, int lblocks, -- int pextents); - - /* - * Test whether an inode is a fast symlink. -@@ -184,6 +182,8 @@ void ext4_evict_inode(struct inode *inod - { - handle_t *handle; - int err; -+ int extra_credits = 3; -+ struct ext4_xattr_ino_array *lea_ino_array = NULL; - - trace_ext4_evict_inode(inode); - -@@ -236,8 +236,8 @@ void ext4_evict_inode(struct inode *inod - * protection against it - */ - sb_start_intwrite(inode->i_sb); -- handle = ext4_journal_start(inode, EXT4_HT_TRUNCATE, -- ext4_blocks_for_truncate(inode)+3); -+ -+ handle = ext4_journal_start(inode, EXT4_HT_TRUNCATE, extra_credits); - if (IS_ERR(handle)) { - ext4_std_error(inode->i_sb, PTR_ERR(handle)); - /* -@@ -249,9 +249,36 @@ void ext4_evict_inode(struct inode *inod - sb_end_intwrite(inode->i_sb); - goto no_delete; - } -- - if (IS_SYNC(inode)) - ext4_handle_sync(handle); -+ -+ /* -+ * Delete xattr inode before deleting the main inode. -+ */ -+ err = ext4_xattr_delete_inode(handle, inode, &lea_ino_array); -+ if (err) { -+ ext4_warning(inode->i_sb, -+ "couldn't delete inode's xattr (err %d)", err); -+ goto stop_handle; -+ } -+ -+ if (!IS_NOQUOTA(inode)) -+ extra_credits += 2 * EXT4_QUOTA_DEL_BLOCKS(inode->i_sb); -+ -+ if (!ext4_handle_has_enough_credits(handle, -+ ext4_blocks_for_truncate(inode) + extra_credits)) { -+ err = ext4_journal_extend(handle, -+ ext4_blocks_for_truncate(inode) + extra_credits); -+ if (err > 0) -+ err = ext4_journal_restart(handle, -+ ext4_blocks_for_truncate(inode) + extra_credits); -+ if (err != 0) { -+ ext4_warning(inode->i_sb, -+ "couldn't extend journal (err %d)", err); -+ goto stop_handle; -+ } -+ } -+ - inode->i_size = 0; - err = ext4_mark_inode_dirty(handle, inode); - if (err) { -@@ -269,10 +296,10 @@ void ext4_evict_inode(struct inode *inod - * enough credits left in the handle to remove the inode from - * the orphan list and set the dtime field. - */ -- if (!ext4_handle_has_enough_credits(handle, 3)) { -- err = ext4_journal_extend(handle, 3); -+ if (!ext4_handle_has_enough_credits(handle, extra_credits)) { -+ err = ext4_journal_extend(handle, extra_credits); - if (err > 0) -- err = ext4_journal_restart(handle, 3); -+ err = ext4_journal_restart(handle, extra_credits); - if (err != 0) { - ext4_warning(inode->i_sb, - "couldn't extend journal (err %d)", err); -@@ -306,8 +333,12 @@ void ext4_evict_inode(struct inode *inod - ext4_clear_inode(inode); - else - ext4_free_inode(handle, inode); -+ - ext4_journal_stop(handle); - sb_end_intwrite(inode->i_sb); -+ -+ if (lea_ino_array != NULL) -+ ext4_xattr_inode_array_free(inode, lea_ino_array); - return; - no_delete: - ext4_clear_inode(inode); /* We must guarantee clearing of inode... */ -@@ -4681,7 +4712,7 @@ static int ext4_index_trans_blocks(struc - * - * Also account for superblock, inode, quota and xattr blocks - */ --static int ext4_meta_trans_blocks(struct inode *inode, int lblocks, -+int ext4_meta_trans_blocks(struct inode *inode, int lblocks, - int pextents) - { - ext4_group_t groups, ngroups = ext4_get_groups_count(inode->i_sb); -Index: linux-stage/fs/ext4/xattr.c -=================================================================== ---- linux-stage.orig/fs/ext4/xattr.c -+++ linux-stage/fs/ext4/xattr.c -@@ -201,6 +201,7 @@ ext4_xattr_check_names(struct ext4_xattr - - while (!IS_LAST_ENTRY(entry)) { - if (entry->e_value_size != 0 && -+ entry->e_value_inum == 0 && - (value_start + le16_to_cpu(entry->e_value_offs) < - (void *)e + sizeof(__u32) || - value_start + le16_to_cpu(entry->e_value_offs) + -@@ -233,19 +234,26 @@ ext4_xattr_check_block(struct inode *ino - } - - static inline int --ext4_xattr_check_entry(struct ext4_xattr_entry *entry, size_t size) -+ext4_xattr_check_entry(struct ext4_xattr_entry *entry, size_t size, -+ struct inode *inode) - { - size_t value_size = le32_to_cpu(entry->e_value_size); - -- if (entry->e_value_block != 0 || value_size > size || -+ if (!entry->e_value_inum && - le16_to_cpu(entry->e_value_offs) + value_size > size) -+ return -EIO; -+ if (entry->e_value_inum && -+ (le32_to_cpu(entry->e_value_inum) < EXT4_FIRST_INO(inode->i_sb) || -+ le32_to_cpu(entry->e_value_inum) > -+ le32_to_cpu(EXT4_SB(inode->i_sb)->s_es->s_inodes_count))) - return -EIO; - return 0; - } - - static int - ext4_xattr_find_entry(struct ext4_xattr_entry **pentry, int name_index, -- const char *name, size_t size, int sorted) -+ const char *name, size_t size, int sorted, -+ struct inode *inode) - { - struct ext4_xattr_entry *entry; - size_t name_len; -@@ -265,11 +273,104 @@ ext4_xattr_find_entry(struct ext4_xattr_ - break; - } - *pentry = entry; -- if (!cmp && ext4_xattr_check_entry(entry, size)) -+ if (!cmp && ext4_xattr_check_entry(entry, size, inode)) - return -EIO; - return cmp ? -ENODATA : 0; - } - -+/* -+ * Read the EA value from an inode. -+ */ -+static int -+ext4_xattr_inode_read(struct inode *ea_inode, void *buf, size_t *size) -+{ -+ unsigned long block = 0; -+ struct buffer_head *bh = NULL; -+ int err, blocksize; -+ size_t csize, ret_size = 0; -+ -+ if (*size == 0) -+ return 0; -+ -+ blocksize = ea_inode->i_sb->s_blocksize; -+ -+ while (ret_size < *size) { -+ csize = (*size - ret_size) > blocksize ? blocksize : -+ *size - ret_size; -+ bh = ext4_bread(NULL, ea_inode, block, 0, &err); -+ if (!bh) { -+ *size = ret_size; -+ return err; -+ } -+ memcpy(buf, bh->b_data, csize); -+ brelse(bh); -+ -+ buf += csize; -+ block += 1; -+ ret_size += csize; -+ } -+ -+ *size = ret_size; -+ -+ return err; -+} -+ -+struct inode *ext4_xattr_inode_iget(struct inode *parent, unsigned long ea_ino, int *err) -+{ -+ struct inode *ea_inode = NULL; -+ -+ ea_inode = ext4_iget(parent->i_sb, ea_ino); -+ if (IS_ERR(ea_inode) || is_bad_inode(ea_inode)) { -+ int rc = IS_ERR(ea_inode) ? PTR_ERR(ea_inode) : 0; -+ ext4_error(parent->i_sb, "error while reading EA inode %lu " -+ "/ %d %d", ea_ino, rc, is_bad_inode(ea_inode)); -+ *err = rc != 0 ? rc : -EIO; -+ return NULL; -+ } -+ -+ if (EXT4_XATTR_INODE_GET_PARENT(ea_inode) != parent->i_ino || -+ ea_inode->i_generation != parent->i_generation) { -+ ext4_error(parent->i_sb, "Backpointer from EA inode %lu " -+ "to parent invalid.", ea_ino); -+ *err = -EINVAL; -+ goto error; -+ } -+ -+ if (!(EXT4_I(ea_inode)->i_flags & EXT4_EA_INODE_FL)) { -+ ext4_error(parent->i_sb, "EA inode %lu does not have " -+ "EXT4_EA_INODE_FL flag set.\n", ea_ino); -+ *err = -EINVAL; -+ goto error; -+ } -+ -+ *err = 0; -+ return ea_inode; -+ -+error: -+ iput(ea_inode); -+ return NULL; -+} -+ -+/* -+ * Read the value from the EA inode. -+ */ -+static int -+ext4_xattr_inode_get(struct inode *inode, unsigned long ea_ino, void *buffer, -+ size_t *size) -+{ -+ struct inode *ea_inode = NULL; -+ int err; -+ -+ ea_inode = ext4_xattr_inode_iget(inode, ea_ino, &err); -+ if (err) -+ return err; -+ -+ err = ext4_xattr_inode_read(ea_inode, buffer, size); -+ iput(ea_inode); -+ -+ return err; -+} -+ - static int - ext4_xattr_block_get(struct inode *inode, int name_index, const char *name, - void *buffer, size_t buffer_size) -@@ -301,7 +401,8 @@ bad_block: - } - ext4_xattr_cache_insert(bh); - entry = BFIRST(bh); -- error = ext4_xattr_find_entry(&entry, name_index, name, bh->b_size, 1); -+ error = ext4_xattr_find_entry(&entry, name_index, name, bh->b_size, 1, -+ inode); - if (error == -EIO) - goto bad_block; - if (error) -@@ -311,8 +412,16 @@ bad_block: - error = -ERANGE; - if (size > buffer_size) - goto cleanup; -- memcpy(buffer, bh->b_data + le16_to_cpu(entry->e_value_offs), -- size); -+ if (entry->e_value_inum) { -+ error = ext4_xattr_inode_get(inode, -+ le32_to_cpu(entry->e_value_inum), -+ buffer, &size); -+ if (error) -+ goto cleanup; -+ } else { -+ memcpy(buffer, bh->b_data + -+ le16_to_cpu(entry->e_value_offs), size); -+ } - } - error = size; - -@@ -346,7 +455,7 @@ ext4_xattr_ibody_get(struct inode *inode - if (error) - goto cleanup; - error = ext4_xattr_find_entry(&entry, name_index, name, -- end - (void *)entry, 0); -+ end - (void *)entry, 0, inode); - if (error) - goto cleanup; - size = le32_to_cpu(entry->e_value_size); -@@ -354,8 +463,16 @@ ext4_xattr_ibody_get(struct inode *inode - error = -ERANGE; - if (size > buffer_size) - goto cleanup; -- memcpy(buffer, (void *)IFIRST(header) + -- le16_to_cpu(entry->e_value_offs), size); -+ if (entry->e_value_inum) { -+ error = ext4_xattr_inode_get(inode, -+ le32_to_cpu(entry->e_value_inum), -+ buffer, &size); -+ if (error) -+ goto cleanup; -+ } else { -+ memcpy(buffer, (void *)IFIRST(header) + -+ le16_to_cpu(entry->e_value_offs), size); -+ } - } - error = size; - -@@ -600,7 +717,7 @@ static size_t ext4_xattr_free_space(stru - size_t *min_offs, void *base, int *total) - { - for (; !IS_LAST_ENTRY(last); last = EXT4_XATTR_NEXT(last)) { -- if (!last->e_value_block && last->e_value_size) { -+ if (!last->e_value_inum && last->e_value_size) { - size_t offs = le16_to_cpu(last->e_value_offs); - if (offs < *min_offs) - *min_offs = offs; -@@ -611,16 +728,198 @@ static size_t ext4_xattr_free_space(stru - return (*min_offs - ((void *)last - base) - sizeof(__u32)); - } - -+/* -+ * Write the value of the EA in an inode. -+ */ - static int --ext4_xattr_set_entry(struct ext4_xattr_info *i, struct ext4_xattr_search *s) -+ext4_xattr_inode_write(handle_t *handle, struct inode *ea_inode, -+ const void *buf, int bufsize) -+{ -+ struct buffer_head *bh = NULL; -+ unsigned long block = 0; -+ unsigned blocksize = ea_inode->i_sb->s_blocksize; -+ unsigned max_blocks = (bufsize + blocksize - 1) >> ea_inode->i_blkbits; -+ int csize, wsize = 0; -+ int ret = 0; -+ int retries = 0; -+ -+retry: -+ while (ret >= 0 && ret < max_blocks) { -+ struct ext4_map_blocks map; -+ map.m_lblk = block += ret; -+ map.m_len = max_blocks -= ret; -+ -+ ret = ext4_map_blocks(handle, ea_inode, &map, -+ EXT4_GET_BLOCKS_CREATE); -+ if (ret <= 0) { -+ ext4_mark_inode_dirty(handle, ea_inode); -+ if (ret == -ENOSPC && -+ ext4_should_retry_alloc(ea_inode->i_sb, &retries)) { -+ ret = 0; -+ goto retry; -+ } -+ break; -+ } -+ } -+ -+ if (ret < 0) -+ return ret; -+ -+ block = 0; -+ while (wsize < bufsize) { -+ if (bh != NULL) -+ brelse(bh); -+ csize = (bufsize - wsize) > blocksize ? blocksize : -+ bufsize - wsize; -+ bh = ext4_getblk(handle, ea_inode, block, 0, &ret); -+ if (!bh) -+ goto out; -+ ret = ext4_journal_get_write_access(handle, bh); -+ if (ret) -+ goto out; -+ -+ memcpy(bh->b_data, buf, csize); -+ set_buffer_uptodate(bh); -+ ext4_handle_dirty_metadata(handle, ea_inode, bh); -+ -+ buf += csize; -+ wsize += csize; -+ block += 1; -+ } -+ -+ mutex_lock(&ea_inode->i_mutex); -+ i_size_write(ea_inode, wsize); -+ ext4_update_i_disksize(ea_inode, wsize); -+ mutex_unlock(&ea_inode->i_mutex); -+ -+ ext4_mark_inode_dirty(handle, ea_inode); -+ -+out: -+ brelse(bh); -+ -+ return ret; -+} -+ -+static void ext4_xattr_inode_set_ref(struct inode *ea_inode, __u64 ref_count) -+{ -+ ea_inode->i_ctime.tv_sec = (__u32)(ref_count >> 32); -+ ea_inode->i_version = (__u32)ref_count; -+} -+ -+static void ext4_xattr_inode_set_hash(struct inode *ea_inode, __u32 hash) -+{ -+ ea_inode->i_atime.tv_sec = hash; -+} -+ -+/* -+ * Create an inode to store the value of a large EA. -+ */ -+static struct inode * -+ext4_xattr_inode_create(handle_t *handle, struct inode *inode, __u32 hash) -+{ -+ struct inode *ea_inode = NULL; -+ -+ /* -+ * Let the next inode be the goal, so we try and allocate the EA inode -+ * in the same group, or nearby one. -+ */ -+ ea_inode = ext4_new_inode(handle, inode->i_sb->s_root->d_inode, -+ S_IFREG|0600, NULL, inode->i_ino + 1, NULL); -+ -+ if (!IS_ERR(ea_inode)) { -+ ea_inode->i_op = &ext4_file_inode_operations; -+ ea_inode->i_fop = &ext4_file_operations; -+ ext4_set_aops(ea_inode); -+ ea_inode->i_generation = inode->i_generation; -+ EXT4_I(ea_inode)->i_flags |= EXT4_EA_INODE_FL; -+ -+ /* -+ * A back-pointer from EA inode to parent inode will be useful -+ * for e2fsck. -+ */ -+ EXT4_XATTR_INODE_SET_PARENT(ea_inode, inode->i_ino); -+ unlock_new_inode(ea_inode); -+ -+ ext4_xattr_inode_set_ref(ea_inode, 1); -+ ext4_xattr_inode_set_hash(ea_inode, hash); -+ } -+ -+ return ea_inode; -+} -+ -+/* -+ * Unlink the inode storing the value of the EA. -+ */ -+int -+ext4_xattr_inode_unlink(struct inode *inode, unsigned long ea_ino) -+{ -+ struct inode *ea_inode = NULL; -+ int err; -+ -+ ea_inode = ext4_xattr_inode_iget(inode, ea_ino, &err); -+ if (err) -+ return err; -+ -+ clear_nlink(ea_inode); -+ iput(ea_inode); -+ -+ return 0; -+} -+ -+static __u32 -+ext4_xattr_inode_hash(struct ext4_sb_info *sbi, const void *buffer, size_t size) -+{ -+ if (ext4_has_metadata_csum(sbi->s_sb)) -+ return ext4_chksum(sbi, sbi->s_csum_seed, buffer, size); -+ return 0; -+} -+ -+/* -+ * Add value of the EA in an inode. -+ */ -+static int -+ext4_xattr_inode_set(handle_t *handle, struct inode *inode, unsigned long *ea_ino, -+ const void *value, size_t value_len) -+{ -+ struct inode *ea_inode = NULL; -+ __u32 hash; -+ int err; -+ -+ /* Create an inode for the EA value */ -+ hash = ext4_xattr_inode_hash(EXT4_SB(inode->i_sb), value, value_len); -+ ea_inode = ext4_xattr_inode_create(handle, inode, hash); -+ if (IS_ERR(ea_inode)) -+ return -1; -+ -+ err = ext4_xattr_inode_write(handle, ea_inode, value, value_len); -+ if (err) -+ clear_nlink(ea_inode); -+ else -+ *ea_ino = ea_inode->i_ino; -+ -+ iput(ea_inode); -+ -+ return err; -+} -+ -+static int -+ext4_xattr_set_entry(struct ext4_xattr_info *i, struct ext4_xattr_search *s, -+ handle_t *handle, struct inode *inode) - { - struct ext4_xattr_entry *last; - size_t free, min_offs = s->end - s->base, name_len = strlen(i->name); -+ int in_inode = i->in_inode; -+ -+ if (EXT4_HAS_INCOMPAT_FEATURE(inode->i_sb, -+ EXT4_FEATURE_INCOMPAT_EA_INODE) && -+ (EXT4_XATTR_SIZE(i->value_len) > -+ EXT4_XATTR_MIN_LARGE_EA_SIZE(inode->i_sb->s_blocksize))) -+ in_inode = 1; - - /* Compute min_offs and last. */ - last = s->first; - for (; !IS_LAST_ENTRY(last); last = EXT4_XATTR_NEXT(last)) { -- if (!last->e_value_block && last->e_value_size) { -+ if (!last->e_value_inum && last->e_value_size) { - size_t offs = le16_to_cpu(last->e_value_offs); - if (offs < min_offs) - min_offs = offs; -@@ -628,16 +927,21 @@ ext4_xattr_set_entry(struct ext4_xattr_i - } - free = min_offs - ((void *)last - s->base) - sizeof(__u32); - if (!s->not_found) { -- if (!s->here->e_value_block && s->here->e_value_size) { -+ if (!in_inode && -+ !s->here->e_value_inum && s->here->e_value_size) { - size_t size = le32_to_cpu(s->here->e_value_size); - free += EXT4_XATTR_SIZE(size); - } - free += EXT4_XATTR_LEN(name_len); - } - if (i->value) { -- if (free < EXT4_XATTR_SIZE(i->value_len) || -- free < EXT4_XATTR_LEN(name_len) + -- EXT4_XATTR_SIZE(i->value_len)) -+ size_t value_len = EXT4_XATTR_SIZE(i->value_len); -+ -+ if (in_inode) -+ value_len = 0; -+ -+ if (free < value_len || -+ free < EXT4_XATTR_LEN(name_len) + value_len) - return -ENOSPC; - } - -@@ -651,7 +955,8 @@ ext4_xattr_set_entry(struct ext4_xattr_i - s->here->e_name_len = name_len; - memcpy(s->here->e_name, i->name, name_len); - } else { -- if (!s->here->e_value_block && s->here->e_value_size) { -+ if (!s->here->e_value_inum && s->here->e_value_size && -+ s->here->e_value_offs > 0) { - void *first_val = s->base + min_offs; - size_t offs = le16_to_cpu(s->here->e_value_offs); - void *val = s->base + offs; -@@ -685,13 +990,18 @@ ext4_xattr_set_entry(struct ext4_xattr_i - last = s->first; - while (!IS_LAST_ENTRY(last)) { - size_t o = le16_to_cpu(last->e_value_offs); -- if (!last->e_value_block && -+ if (!last->e_value_inum && - last->e_value_size && o < offs) - last->e_value_offs = - cpu_to_le16(o + size); - last = EXT4_XATTR_NEXT(last); - } - } -+ if (s->here->e_value_inum) { -+ ext4_xattr_inode_unlink(inode, -+ le32_to_cpu(s->here->e_value_inum)); -+ s->here->e_value_inum = 0; -+ } - if (!i->value) { - /* Remove the old name. */ - size_t size = EXT4_XATTR_LEN(name_len); -@@ -705,10 +1014,17 @@ ext4_xattr_set_entry(struct ext4_xattr_i - if (i->value) { - /* Insert the new value. */ - s->here->e_value_size = cpu_to_le32(i->value_len); -- if (i->value_len) { -+ if (in_inode) { -+ unsigned long ea_ino = le32_to_cpu(s->here->e_value_inum); -+ ext4_xattr_inode_set(handle, inode, &ea_ino, i->value, -+ i->value_len); -+ s->here->e_value_inum = cpu_to_le32(ea_ino); -+ s->here->e_value_offs = 0; -+ } else if (i->value_len) { - size_t size = EXT4_XATTR_SIZE(i->value_len); - void *val = s->base + min_offs - size; - s->here->e_value_offs = cpu_to_le16(min_offs - size); -+ s->here->e_value_inum = 0; - if (i->value == EXT4_ZERO_XATTR_VALUE) { - memset(val, 0, size); - } else { -@@ -758,7 +1074,7 @@ ext4_xattr_block_find(struct inode *inod - bs->s.end = bs->bh->b_data + bs->bh->b_size; - bs->s.here = bs->s.first; - error = ext4_xattr_find_entry(&bs->s.here, i->name_index, -- i->name, bs->bh->b_size, 1); -+ i->name, bs->bh->b_size, 1, inode); - if (error && error != -ENODATA) - goto cleanup; - bs->s.not_found = error; -@@ -782,8 +1098,6 @@ ext4_xattr_block_set(handle_t *handle, s - - #define header(x) ((struct ext4_xattr_header *)(x)) - -- if (i->value && i->value_len > sb->s_blocksize) -- return -ENOSPC; - if (s->base) { - ce = mb_cache_entry_get(ext4_xattr_cache, bs->bh->b_bdev, - bs->bh->b_blocknr); -@@ -799,7 +1113,7 @@ ext4_xattr_block_set(handle_t *handle, s - ce = NULL; - } - ea_bdebug(bs->bh, "modifying in-place"); -- error = ext4_xattr_set_entry(i, s); -+ error = ext4_xattr_set_entry(i, s, handle, inode); - if (!error) { - if (!IS_LAST_ENTRY(s->first)) - ext4_xattr_rehash(header(s->base), -@@ -850,7 +1164,7 @@ ext4_xattr_block_set(handle_t *handle, s - s->end = s->base + sb->s_blocksize; - } - -- error = ext4_xattr_set_entry(i, s); -+ error = ext4_xattr_set_entry(i, s, handle, inode); - if (error == -EIO) - goto bad_block; - if (error) -@@ -1000,7 +1314,7 @@ int ext4_xattr_ibody_find(struct inode * - /* Find the named attribute. */ - error = ext4_xattr_find_entry(&is->s.here, i->name_index, - i->name, is->s.end - -- (void *)is->s.base, 0); -+ (void *)is->s.base, 0, inode); - if (error && error != -ENODATA) - return error; - is->s.not_found = error; -@@ -1018,7 +1332,7 @@ int ext4_xattr_ibody_inline_set(handle_t - - if (EXT4_I(inode)->i_extra_isize == 0) - return -ENOSPC; -- error = ext4_xattr_set_entry(i, s); -+ error = ext4_xattr_set_entry(i, s, handle, inode); - if (error) { - if (error == -ENOSPC && - ext4_has_inline_data(inode)) { -@@ -1030,7 +1344,7 @@ int ext4_xattr_ibody_inline_set(handle_t - error = ext4_xattr_ibody_find(inode, i, is); - if (error) - return error; -- error = ext4_xattr_set_entry(i, s); -+ error = ext4_xattr_set_entry(i, s, handle, inode); - } - if (error) - return error; -@@ -1056,7 +1370,7 @@ static int ext4_xattr_ibody_set(handle_t - - if (EXT4_I(inode)->i_extra_isize == 0) - return -ENOSPC; -- error = ext4_xattr_set_entry(i, s); -+ error = ext4_xattr_set_entry(i, s, handle, inode); - if (error) - return error; - header = IHDR(inode, ext4_raw_inode(&is->iloc)); -@@ -1092,7 +1406,7 @@ ext4_xattr_set_handle(handle_t *handle, - .name = name, - .value = value, - .value_len = value_len, -- -+ .in_inode = 0, - }; - struct ext4_xattr_ibody_find is = { - .s = { .not_found = -ENODATA, }, -@@ -1157,6 +1471,15 @@ ext4_xattr_set_handle(handle_t *handle, - goto cleanup; - } - error = ext4_xattr_block_set(handle, inode, &i, &bs); -+ if (EXT4_HAS_INCOMPAT_FEATURE(inode->i_sb, -+ EXT4_FEATURE_INCOMPAT_EA_INODE) && -+ error == -ENOSPC) { -+ /* xattr not fit to block, store at external -+ * inode */ -+ i.in_inode = 1; -+ error = ext4_xattr_ibody_set(handle, inode, -+ &i, &is); -+ } - if (error) - goto cleanup; - if (!is.s.not_found) { -@@ -1203,9 +1526,22 @@ ext4_xattr_set(struct inode *inode, int - const void *value, size_t value_len, int flags) - { - handle_t *handle; -+ struct super_block *sb = inode->i_sb; - int error, retries = 0; - int credits = ext4_jbd2_credits_xattr(inode); - -+ if ((value_len >= EXT4_XATTR_MIN_LARGE_EA_SIZE(sb->s_blocksize)) && -+ EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EA_INODE)) { -+ int nrblocks = (value_len + sb->s_blocksize - 1) >> -+ sb->s_blocksize_bits; -+ -+ /* For new inode */ -+ credits += EXT4_SINGLEDATA_TRANS_BLOCKS(sb) + 3; -+ -+ /* For data blocks of EA inode */ -+ credits += ext4_meta_trans_blocks(inode, nrblocks, 0); -+ } -+ - retry: - handle = ext4_journal_start(inode, EXT4_HT_XATTR, credits); - if (IS_ERR(handle)) { -@@ -1217,7 +1553,7 @@ retry: - value, value_len, flags); - error2 = ext4_journal_stop(handle); - if (error == -ENOSPC && -- ext4_should_retry_alloc(inode->i_sb, &retries)) -+ ext4_should_retry_alloc(sb, &retries)) - goto retry; - if (error == 0) - error = error2; -@@ -1239,7 +1575,7 @@ static void ext4_xattr_shift_entries(str - - /* Adjust the value offsets of the entries */ - for (; !IS_LAST_ENTRY(last); last = EXT4_XATTR_NEXT(last)) { -- if (!last->e_value_block && last->e_value_size) { -+ if (!last->e_value_inum && last->e_value_size) { - new_offs = le16_to_cpu(last->e_value_offs) + - value_offs_shift; - BUG_ON(new_offs + le32_to_cpu(last->e_value_size) -@@ -1477,21 +1813,135 @@ cleanup: - } - - -+#define EIA_INCR 16 /* must be 2^n */ -+#define EIA_MASK (EIA_INCR - 1) -+/* Add the large xattr @ino into @lea_ino_array for later deletion. -+ * If @lea_ino_array is new or full it will be grown and the old -+ * contents copied over. -+ */ -+static int -+ext4_expand_ino_array(struct ext4_xattr_ino_array **lea_ino_array, __u32 ino) -+{ -+ if (*lea_ino_array == NULL) { -+ /* -+ * Start with 15 inodes, so it fits into a power-of-two size. -+ * If *lea_ino_array is NULL, this is essentially offsetof() -+ */ -+ (*lea_ino_array) = -+ kmalloc(offsetof(struct ext4_xattr_ino_array, -+ xia_inodes[EIA_MASK]), -+ GFP_NOFS); -+ if (*lea_ino_array == NULL) -+ return -ENOMEM; -+ (*lea_ino_array)->xia_count = 0; -+ } else if (((*lea_ino_array)->xia_count & EIA_MASK) == EIA_MASK) { -+ /* expand the array once all 15 + n * 16 slots are full */ -+ struct ext4_xattr_ino_array *new_array = NULL; -+ int count = (*lea_ino_array)->xia_count; -+ -+ /* if new_array is NULL, this is essentially offsetof() */ -+ new_array = kmalloc( -+ offsetof(struct ext4_xattr_ino_array, -+ xia_inodes[count + EIA_INCR]), -+ GFP_NOFS); -+ if (new_array == NULL) -+ return -ENOMEM; -+ memcpy(new_array, *lea_ino_array, -+ offsetof(struct ext4_xattr_ino_array, -+ xia_inodes[count])); -+ kfree(*lea_ino_array); -+ *lea_ino_array = new_array; -+ } -+ (*lea_ino_array)->xia_inodes[(*lea_ino_array)->xia_count++] = ino; -+ return 0; -+} -+ -+/** -+ * Add xattr inode to orphan list -+ */ -+static int -+ext4_xattr_inode_orphan_add(handle_t *handle, struct inode *inode, -+ int credits, struct ext4_xattr_ino_array *lea_ino_array) -+{ -+ struct inode *ea_inode = NULL; -+ int idx = 0, error = 0; -+ -+ if (lea_ino_array == NULL) -+ return 0; -+ -+ for (; idx < lea_ino_array->xia_count; ++idx) { -+ if (!ext4_handle_has_enough_credits(handle, credits)) { -+ error = ext4_journal_extend(handle, credits); -+ if (error > 0) -+ error = ext4_journal_restart(handle, credits); -+ -+ if (error != 0) { -+ ext4_warning(inode->i_sb, -+ "couldn't extend journal " -+ "(err %d)", error); -+ return error; -+ } -+ } -+ ea_inode = ext4_xattr_inode_iget(inode, -+ lea_ino_array->xia_inodes[idx], &error); -+ if (error) -+ continue; -+ ext4_orphan_add(handle, ea_inode); -+ /* the inode's i_count will be released by caller */ -+ } -+ -+ return 0; -+} - - /* - * ext4_xattr_delete_inode() - * -- * Free extended attribute resources associated with this inode. This -+ * Free extended attribute resources associated with this inode. Traverse -+ * all entries and unlink any xattr inodes associated with this inode. This - * is called immediately before an inode is freed. We have exclusive -- * access to the inode. -+ * access to the inode. If an orphan inode is deleted it will also delete any -+ * xattr block and all xattr inodes. They are checked by ext4_xattr_inode_iget() -+ * to ensure they belong to the parent inode and were not deleted already. - */ --void --ext4_xattr_delete_inode(handle_t *handle, struct inode *inode) -+int -+ext4_xattr_delete_inode(handle_t *handle, struct inode *inode, -+ struct ext4_xattr_ino_array **lea_ino_array) - { - struct buffer_head *bh = NULL; -+ struct ext4_xattr_ibody_header *header; -+ struct ext4_inode *raw_inode; -+ struct ext4_iloc iloc; -+ struct ext4_xattr_entry *entry; -+ int credits = 3, error = 0; - -- if (!EXT4_I(inode)->i_file_acl) -+ if (!ext4_test_inode_state(inode, EXT4_STATE_XATTR)) -+ goto delete_external_ea; -+ -+ error = ext4_get_inode_loc(inode, &iloc); -+ if (error) - goto cleanup; -+ raw_inode = ext4_raw_inode(&iloc); -+ header = IHDR(inode, raw_inode); -+ for (entry = IFIRST(header); !IS_LAST_ENTRY(entry); -+ entry = EXT4_XATTR_NEXT(entry)) { -+ if (!entry->e_value_inum) -+ continue; -+ if (ext4_expand_ino_array(lea_ino_array, -+ entry->e_value_inum) != 0) { -+ brelse(iloc.bh); -+ goto cleanup; -+ } -+ entry->e_value_inum = 0; -+ } -+ brelse(iloc.bh); -+ -+delete_external_ea: -+ if (!EXT4_I(inode)->i_file_acl) { -+ /* add xattr inode to orphan list */ -+ ext4_xattr_inode_orphan_add(handle, inode, credits, -+ *lea_ino_array); -+ goto cleanup; -+ } - bh = sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl); - if (!bh) { - EXT4_ERROR_INODE(inode, "block %llu read error", -@@ -1504,11 +1954,69 @@ ext4_xattr_delete_inode(handle_t *handle - EXT4_I(inode)->i_file_acl); - goto cleanup; - } -+ -+ for (entry = BFIRST(bh); !IS_LAST_ENTRY(entry); -+ entry = EXT4_XATTR_NEXT(entry)) { -+ if (!entry->e_value_inum) -+ continue; -+ if (ext4_expand_ino_array(lea_ino_array, -+ entry->e_value_inum) != 0) -+ goto cleanup; -+ entry->e_value_inum = 0; -+ } -+ -+ /* add xattr inode to orphan list */ -+ error = ext4_xattr_inode_orphan_add(handle, inode, credits, -+ *lea_ino_array); -+ if (error != 0) -+ goto cleanup; -+ -+ if (!IS_NOQUOTA(inode)) -+ credits += 2 * EXT4_QUOTA_DEL_BLOCKS(inode->i_sb); -+ -+ if (!ext4_handle_has_enough_credits(handle, credits)) { -+ error = ext4_journal_extend(handle, credits); -+ if (error > 0) -+ error = ext4_journal_restart(handle, credits); -+ if (error != 0) { -+ ext4_warning(inode->i_sb, -+ "couldn't extend journal (err %d)", error); -+ goto cleanup; -+ } -+ } -+ - ext4_xattr_release_block(handle, inode, bh); - EXT4_I(inode)->i_file_acl = 0; - - cleanup: - brelse(bh); -+ -+ return error; -+} -+ -+void -+ext4_xattr_inode_array_free(struct inode *inode, -+ struct ext4_xattr_ino_array *lea_ino_array) -+{ -+ struct inode *ea_inode = NULL; -+ int idx = 0; -+ int err; -+ -+ if (lea_ino_array == NULL) -+ return; -+ -+ for (; idx < lea_ino_array->xia_count; ++idx) { -+ ea_inode = ext4_xattr_inode_iget(inode, -+ lea_ino_array->xia_inodes[idx], &err); -+ if (err) -+ continue; -+ /* for inode's i_count get from ext4_xattr_delete_inode */ -+ if (!list_empty(&EXT4_I(ea_inode)->i_orphan)) -+ iput(ea_inode); -+ clear_nlink(ea_inode); -+ iput(ea_inode); -+ } -+ kfree(lea_ino_array); - } - - /* -@@ -1578,10 +2086,9 @@ ext4_xattr_cmp(struct ext4_xattr_header - entry1->e_name_index != entry2->e_name_index || - entry1->e_name_len != entry2->e_name_len || - entry1->e_value_size != entry2->e_value_size || -+ entry1->e_value_inum != entry2->e_value_inum || - memcmp(entry1->e_name, entry2->e_name, entry1->e_name_len)) - return 1; -- if (entry1->e_value_block != 0 || entry2->e_value_block != 0) -- return -EIO; - if (memcmp((char *)header1 + le16_to_cpu(entry1->e_value_offs), - (char *)header2 + le16_to_cpu(entry2->e_value_offs), - le32_to_cpu(entry1->e_value_size))) -@@ -1665,7 +2172,7 @@ static inline void ext4_xattr_hash_entry - *name++; - } - -- if (entry->e_value_block == 0 && entry->e_value_size != 0) { -+ if (!entry->e_value_inum && entry->e_value_size) { - __le32 *value = (__le32 *)((char *)header + - le16_to_cpu(entry->e_value_offs)); - for (n = (le32_to_cpu(entry->e_value_size) + -Index: linux-stage/fs/ext4/xattr.h -=================================================================== ---- linux-stage.orig/fs/ext4/xattr.h -+++ linux-stage/fs/ext4/xattr.h -@@ -42,7 +42,7 @@ struct ext4_xattr_entry { - __u8 e_name_len; /* length of name */ - __u8 e_name_index; /* attribute name index */ - __le16 e_value_offs; /* offset in disk block of value */ -- __le32 e_value_block; /* disk block attribute is stored on (n/i) */ -+ __le32 e_value_inum; /* inode in which the value is stored */ - __le32 e_value_size; /* size of attribute value */ - __le32 e_hash; /* hash value of name and value */ - char e_name[0]; /* attribute name */ -@@ -67,6 +67,26 @@ struct ext4_xattr_entry { - EXT4_I(inode)->i_extra_isize)) - #define IFIRST(hdr) ((struct ext4_xattr_entry *)((hdr)+1)) - -+/* -+ * Link EA inode back to parent one using i_mtime field. -+ * Extra integer type conversion added to ignore higher -+ * bits in i_mtime.tv_sec which might be set by ext4_get() -+ */ -+#define EXT4_XATTR_INODE_SET_PARENT(inode, inum) \ -+do { \ -+ (inode)->i_mtime.tv_sec = inum; \ -+} while(0) -+ -+#define EXT4_XATTR_INODE_GET_PARENT(inode) \ -+((__u32)(inode)->i_mtime.tv_sec) -+ -+/* -+ * The minimum size of EA value when you start storing it in an external inode -+ * size of block - size of header - size of 1 entry - 4 null bytes -+*/ -+#define EXT4_XATTR_MIN_LARGE_EA_SIZE(b) \ -+ ((b) - EXT4_XATTR_LEN(3) - sizeof(struct ext4_xattr_header) - 4) -+ - #define BHDR(bh) ((struct ext4_xattr_header *)((bh)->b_data)) - #define ENTRY(ptr) ((struct ext4_xattr_entry *)(ptr)) - #define BFIRST(bh) ENTRY(BHDR(bh)+1) -@@ -75,10 +84,11 @@ struct ext4_xattr_entry { - #define EXT4_ZERO_XATTR_VALUE ((void *)-1) - - struct ext4_xattr_info { -- int name_index; - const char *name; - const void *value; - size_t value_len; -+ int name_index; -+ int in_inode; - }; - - struct ext4_xattr_search { -@@ -106,7 +116,13 @@ extern int ext4_xattr_get(struct inode * - extern int ext4_xattr_set(struct inode *, int, const char *, const void *, size_t, int); - extern int ext4_xattr_set_handle(handle_t *, struct inode *, int, const char *, const void *, size_t, int); - --extern void ext4_xattr_delete_inode(handle_t *, struct inode *); -+extern struct inode *ext4_xattr_inode_iget(struct inode *parent, unsigned long ea_ino, -+ int *err); -+extern int ext4_xattr_inode_unlink(struct inode *inode, unsigned long ea_ino); -+extern int ext4_xattr_delete_inode(handle_t *handle, struct inode *inode, -+ struct ext4_xattr_ino_array **array); -+extern void ext4_xattr_inode_array_free(struct inode *inode, -+ struct ext4_xattr_ino_array *array); - extern void ext4_xattr_put_super(struct super_block *); - - extern int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize, -Index: linux-stage/fs/ext4/ialloc.c -=================================================================== ---- linux-stage.orig/fs/ext4/ialloc.c -+++ linux-stage/fs/ext4/ialloc.c -@@ -269,7 +269,6 @@ void ext4_free_inode(handle_t *handle, s - * as writing the quota to disk may need the lock as well. - */ - dquot_initialize(inode); -- ext4_xattr_delete_inode(handle, inode); - dquot_free_inode(inode); - dquot_drop(inode); - -Index: linux-stage/fs/ext4/inline.c -=================================================================== ---- linux-stage.orig/fs/ext4/inline.c -+++ linux-stage/fs/ext4/inline.c -@@ -59,7 +59,7 @@ static int get_max_inline_xattr_value_si - - /* Compute min_offs. */ - for (; !IS_LAST_ENTRY(entry); entry = EXT4_XATTR_NEXT(entry)) { -- if (!entry->e_value_block && entry->e_value_size) { -+ if (!entry->e_value_inum && entry->e_value_size) { - size_t offs = le16_to_cpu(entry->e_value_offs); - if (offs < min_offs) - min_offs = offs; diff --git a/ldiskfs/kernel_patches/patches/rhel7/ext4-pdirop.patch b/ldiskfs/kernel_patches/patches/rhel7/ext4-pdirop.patch deleted file mode 100644 index f512009..0000000 --- a/ldiskfs/kernel_patches/patches/rhel7/ext4-pdirop.patch +++ /dev/null @@ -1,1932 +0,0 @@ -Single directory performance is a critical for HPC workloads. In a -typical use case an application creates a separate output file for -each node and task in a job. As nodes and tasks increase, hundreds -of thousands of files may be created in a single directory within -a short window of time. -Today, both filename lookup and file system modifying operations -(such as create and unlink) are protected with a single lock for -an entire ldiskfs directory. PDO project will remove this -bottleneck by introducing a parallel locking mechanism for entire -ldiskfs directories. This work will enable multiple application -threads to simultaneously lookup, create and unlink in parallel. - -This patch contains: - - pdirops support for ldiskfs - - integrate with osd-ldiskfs - -Index: linux-3.10.0-229.1.2.fc21.x86_64/include/linux/htree_lock.h -=================================================================== ---- /dev/null -+++ linux-3.10.0-229.1.2.fc21.x86_64/include/linux/htree_lock.h -@@ -0,0 +1,187 @@ -+/* -+ * include/linux/htree_lock.h -+ * -+ * Copyright (c) 2011, 2012, Intel Corporation. -+ * -+ * Author: Liang Zhen -+ */ -+ -+/* -+ * htree lock -+ * -+ * htree_lock is an advanced lock, it can support five lock modes (concept is -+ * taken from DLM) and it's a sleeping lock. -+ * -+ * most common use case is: -+ * - create a htree_lock_head for data -+ * - each thread (contender) creates it's own htree_lock -+ * - contender needs to call htree_lock(lock_node, mode) to protect data and -+ * call htree_unlock to release lock -+ * -+ * Also, there is advanced use-case which is more complex, user can have -+ * PW/PR lock on particular key, it's mostly used while user holding shared -+ * lock on the htree (CW, CR) -+ * -+ * htree_lock(lock_node, HTREE_LOCK_CR); lock the htree with CR -+ * htree_node_lock(lock_node, HTREE_LOCK_PR, key...); lock @key with PR -+ * ... -+ * htree_node_unlock(lock_node);; unlock the key -+ * -+ * Another tip is, we can have N-levels of this kind of keys, all we need to -+ * do is specifying N-levels while creating htree_lock_head, then we can -+ * lock/unlock a specific level by: -+ * htree_node_lock(lock_node, mode1, key1, level1...); -+ * do something; -+ * htree_node_lock(lock_node, mode1, key2, level2...); -+ * do something; -+ * htree_node_unlock(lock_node, level2); -+ * htree_node_unlock(lock_node, level1); -+ * -+ * NB: for multi-level, should be careful about locking order to avoid deadlock -+ */ -+ -+#ifndef _LINUX_HTREE_LOCK_H -+#define _LINUX_HTREE_LOCK_H -+ -+#include -+#include -+#include -+ -+/* -+ * Lock Modes -+ * more details can be found here: -+ * http://en.wikipedia.org/wiki/Distributed_lock_manager -+ */ -+typedef enum { -+ HTREE_LOCK_EX = 0, /* exclusive lock: incompatible with all others */ -+ HTREE_LOCK_PW, /* protected write: allows only CR users */ -+ HTREE_LOCK_PR, /* protected read: allow PR, CR users */ -+ HTREE_LOCK_CW, /* concurrent write: allow CR, CW users */ -+ HTREE_LOCK_CR, /* concurrent read: allow all but EX users */ -+ HTREE_LOCK_MAX, /* number of lock modes */ -+} htree_lock_mode_t; -+ -+#define HTREE_LOCK_NL HTREE_LOCK_MAX -+#define HTREE_LOCK_INVAL 0xdead10c -+ -+enum { -+ HTREE_HBITS_MIN = 2, -+ HTREE_HBITS_DEF = 14, -+ HTREE_HBITS_MAX = 32, -+}; -+ -+enum { -+ HTREE_EVENT_DISABLE = (0), -+ HTREE_EVENT_RD = (1 << HTREE_LOCK_PR), -+ HTREE_EVENT_WR = (1 << HTREE_LOCK_PW), -+ HTREE_EVENT_RDWR = (HTREE_EVENT_RD | HTREE_EVENT_WR), -+}; -+ -+struct htree_lock; -+ -+typedef void (*htree_event_cb_t)(void *target, void *event); -+ -+struct htree_lock_child { -+ struct list_head lc_list; /* granted list */ -+ htree_event_cb_t lc_callback; /* event callback */ -+ unsigned lc_events; /* event types */ -+}; -+ -+struct htree_lock_head { -+ unsigned long lh_lock; /* bits lock */ -+ /* blocked lock list (htree_lock) */ -+ struct list_head lh_blocked_list; -+ /* # key levels */ -+ u16 lh_depth; -+ /* hash bits for key and limit number of locks */ -+ u16 lh_hbits; -+ /* counters for blocked locks */ -+ u16 lh_nblocked[HTREE_LOCK_MAX]; -+ /* counters for granted locks */ -+ u16 lh_ngranted[HTREE_LOCK_MAX]; -+ /* private data */ -+ void *lh_private; -+ /* array of children locks */ -+ struct htree_lock_child lh_children[0]; -+}; -+ -+/* htree_lock_node_t is child-lock for a specific key (ln_value) */ -+struct htree_lock_node { -+ htree_lock_mode_t ln_mode; -+ /* major hash key */ -+ u16 ln_major_key; -+ /* minor hash key */ -+ u16 ln_minor_key; -+ struct list_head ln_major_list; -+ struct list_head ln_minor_list; -+ /* alive list, all locks (granted, blocked, listening) are on it */ -+ struct list_head ln_alive_list; -+ /* blocked list */ -+ struct list_head ln_blocked_list; -+ /* granted list */ -+ struct list_head ln_granted_list; -+ void *ln_ev_target; -+}; -+ -+struct htree_lock { -+ struct task_struct *lk_task; -+ struct htree_lock_head *lk_head; -+ void *lk_private; -+ unsigned lk_depth; -+ htree_lock_mode_t lk_mode; -+ struct list_head lk_blocked_list; -+ struct htree_lock_node lk_nodes[0]; -+}; -+ -+/* create a lock head, which stands for a resource */ -+struct htree_lock_head *htree_lock_head_alloc(unsigned depth, -+ unsigned hbits, unsigned priv); -+/* free a lock head */ -+void htree_lock_head_free(struct htree_lock_head *lhead); -+/* register event callback for child lock at level @depth */ -+void htree_lock_event_attach(struct htree_lock_head *lhead, unsigned depth, -+ unsigned events, htree_event_cb_t callback); -+/* create a lock handle, which stands for a thread */ -+struct htree_lock *htree_lock_alloc(unsigned depth, unsigned pbytes); -+/* free a lock handle */ -+void htree_lock_free(struct htree_lock *lck); -+/* lock htree, when @wait is true, 0 is returned if the lock can't -+ * be granted immediately */ -+int htree_lock_try(struct htree_lock *lck, struct htree_lock_head *lhead, -+ htree_lock_mode_t mode, int wait); -+/* unlock htree */ -+void htree_unlock(struct htree_lock *lck); -+/* unlock and relock htree with @new_mode */ -+int htree_change_lock_try(struct htree_lock *lck, -+ htree_lock_mode_t new_mode, int wait); -+void htree_change_mode(struct htree_lock *lck, htree_lock_mode_t mode); -+/* require child lock (key) of htree at level @dep, @event will be sent to all -+ * listeners on this @key while lock being granted */ -+int htree_node_lock_try(struct htree_lock *lck, htree_lock_mode_t mode, -+ u32 key, unsigned dep, int wait, void *event); -+/* release child lock at level @dep, this lock will listen on it's key -+ * if @event isn't NULL, event_cb will be called against @lck while granting -+ * any other lock at level @dep with the same key */ -+void htree_node_unlock(struct htree_lock *lck, unsigned dep, void *event); -+/* stop listening on child lock at level @dep */ -+void htree_node_stop_listen(struct htree_lock *lck, unsigned dep); -+/* for debug */ -+void htree_lock_stat_print(int depth); -+void htree_lock_stat_reset(void); -+ -+#define htree_lock(lck, lh, mode) htree_lock_try(lck, lh, mode, 1) -+#define htree_change_lock(lck, mode) htree_change_lock_try(lck, mode, 1) -+ -+#define htree_lock_mode(lck) ((lck)->lk_mode) -+ -+#define htree_node_lock(lck, mode, key, dep) \ -+ htree_node_lock_try(lck, mode, key, dep, 1, NULL) -+/* this is only safe in thread context of lock owner */ -+#define htree_node_is_granted(lck, dep) \ -+ ((lck)->lk_nodes[dep].ln_mode != HTREE_LOCK_INVAL && \ -+ (lck)->lk_nodes[dep].ln_mode != HTREE_LOCK_NL) -+/* this is only safe in thread context of lock owner */ -+#define htree_node_is_listening(lck, dep) \ -+ ((lck)->lk_nodes[dep].ln_mode == HTREE_LOCK_NL) -+ -+#endif -Index: linux-3.10.0-229.1.2.fc21.x86_64/fs/ext4/htree_lock.c -=================================================================== ---- /dev/null -+++ linux-3.10.0-229.1.2.fc21.x86_64/fs/ext4/htree_lock.c -@@ -0,0 +1,880 @@ -+/* -+ * fs/ext4/htree_lock.c -+ * -+ * Copyright (c) 2011, 2012, Intel Corporation. -+ * -+ * Author: Liang Zhen -+ */ -+#include -+#include -+#include -+#include -+ -+enum { -+ HTREE_LOCK_BIT_EX = (1 << HTREE_LOCK_EX), -+ HTREE_LOCK_BIT_PW = (1 << HTREE_LOCK_PW), -+ HTREE_LOCK_BIT_PR = (1 << HTREE_LOCK_PR), -+ HTREE_LOCK_BIT_CW = (1 << HTREE_LOCK_CW), -+ HTREE_LOCK_BIT_CR = (1 << HTREE_LOCK_CR), -+}; -+ -+enum { -+ HTREE_LOCK_COMPAT_EX = 0, -+ HTREE_LOCK_COMPAT_PW = HTREE_LOCK_COMPAT_EX | HTREE_LOCK_BIT_CR, -+ HTREE_LOCK_COMPAT_PR = HTREE_LOCK_COMPAT_PW | HTREE_LOCK_BIT_PR, -+ HTREE_LOCK_COMPAT_CW = HTREE_LOCK_COMPAT_PW | HTREE_LOCK_BIT_CW, -+ HTREE_LOCK_COMPAT_CR = HTREE_LOCK_COMPAT_CW | HTREE_LOCK_BIT_PR | -+ HTREE_LOCK_BIT_PW, -+}; -+ -+static int htree_lock_compat[] = { -+ [HTREE_LOCK_EX] HTREE_LOCK_COMPAT_EX, -+ [HTREE_LOCK_PW] HTREE_LOCK_COMPAT_PW, -+ [HTREE_LOCK_PR] HTREE_LOCK_COMPAT_PR, -+ [HTREE_LOCK_CW] HTREE_LOCK_COMPAT_CW, -+ [HTREE_LOCK_CR] HTREE_LOCK_COMPAT_CR, -+}; -+ -+/* max allowed htree-lock depth. -+ * We only need depth=3 for ext4 although user can have higher value. */ -+#define HTREE_LOCK_DEP_MAX 16 -+ -+#ifdef HTREE_LOCK_DEBUG -+ -+static char *hl_name[] = { -+ [HTREE_LOCK_EX] "EX", -+ [HTREE_LOCK_PW] "PW", -+ [HTREE_LOCK_PR] "PR", -+ [HTREE_LOCK_CW] "CW", -+ [HTREE_LOCK_CR] "CR", -+}; -+ -+/* lock stats */ -+struct htree_lock_node_stats { -+ unsigned long long blocked[HTREE_LOCK_MAX]; -+ unsigned long long granted[HTREE_LOCK_MAX]; -+ unsigned long long retried[HTREE_LOCK_MAX]; -+ unsigned long long events; -+}; -+ -+struct htree_lock_stats { -+ struct htree_lock_node_stats nodes[HTREE_LOCK_DEP_MAX]; -+ unsigned long long granted[HTREE_LOCK_MAX]; -+ unsigned long long blocked[HTREE_LOCK_MAX]; -+}; -+ -+static struct htree_lock_stats hl_stats; -+ -+void htree_lock_stat_reset(void) -+{ -+ memset(&hl_stats, 0, sizeof(hl_stats)); -+} -+ -+void htree_lock_stat_print(int depth) -+{ -+ int i; -+ int j; -+ -+ printk(KERN_DEBUG "HTREE LOCK STATS:\n"); -+ for (i = 0; i < HTREE_LOCK_MAX; i++) { -+ printk(KERN_DEBUG "[%s]: G [%10llu], B [%10llu]\n", -+ hl_name[i], hl_stats.granted[i], hl_stats.blocked[i]); -+ } -+ for (i = 0; i < depth; i++) { -+ printk(KERN_DEBUG "HTREE CHILD [%d] STATS:\n", i); -+ for (j = 0; j < HTREE_LOCK_MAX; j++) { -+ printk(KERN_DEBUG -+ "[%s]: G [%10llu], B [%10llu], R [%10llu]\n", -+ hl_name[j], hl_stats.nodes[i].granted[j], -+ hl_stats.nodes[i].blocked[j], -+ hl_stats.nodes[i].retried[j]); -+ } -+ } -+} -+ -+#define lk_grant_inc(m) do { hl_stats.granted[m]++; } while (0) -+#define lk_block_inc(m) do { hl_stats.blocked[m]++; } while (0) -+#define ln_grant_inc(d, m) do { hl_stats.nodes[d].granted[m]++; } while (0) -+#define ln_block_inc(d, m) do { hl_stats.nodes[d].blocked[m]++; } while (0) -+#define ln_retry_inc(d, m) do { hl_stats.nodes[d].retried[m]++; } while (0) -+#define ln_event_inc(d) do { hl_stats.nodes[d].events++; } while (0) -+ -+#else /* !DEBUG */ -+ -+void htree_lock_stat_reset(void) {} -+void htree_lock_stat_print(int depth) {} -+ -+#define lk_grant_inc(m) do {} while (0) -+#define lk_block_inc(m) do {} while (0) -+#define ln_grant_inc(d, m) do {} while (0) -+#define ln_block_inc(d, m) do {} while (0) -+#define ln_retry_inc(d, m) do {} while (0) -+#define ln_event_inc(d) do {} while (0) -+ -+#endif /* DEBUG */ -+ -+EXPORT_SYMBOL(htree_lock_stat_reset); -+EXPORT_SYMBOL(htree_lock_stat_print); -+ -+#define HTREE_DEP_ROOT (-1) -+ -+#define htree_spin_lock(lhead, dep) \ -+ bit_spin_lock((dep) + 1, &(lhead)->lh_lock) -+#define htree_spin_unlock(lhead, dep) \ -+ bit_spin_unlock((dep) + 1, &(lhead)->lh_lock) -+ -+#define htree_key_event_ignore(child, ln) \ -+ (!((child)->lc_events & (1 << (ln)->ln_mode))) -+ -+static int -+htree_key_list_empty(struct htree_lock_node *ln) -+{ -+ return list_empty(&ln->ln_major_list) && list_empty(&ln->ln_minor_list); -+} -+ -+static void -+htree_key_list_del_init(struct htree_lock_node *ln) -+{ -+ struct htree_lock_node *tmp = NULL; -+ -+ if (!list_empty(&ln->ln_minor_list)) { -+ tmp = list_entry(ln->ln_minor_list.next, -+ struct htree_lock_node, ln_minor_list); -+ list_del_init(&ln->ln_minor_list); -+ } -+ -+ if (list_empty(&ln->ln_major_list)) -+ return; -+ -+ if (tmp == NULL) { /* not on minor key list */ -+ list_del_init(&ln->ln_major_list); -+ } else { -+ BUG_ON(!list_empty(&tmp->ln_major_list)); -+ list_replace_init(&ln->ln_major_list, &tmp->ln_major_list); -+ } -+} -+ -+static void -+htree_key_list_replace_init(struct htree_lock_node *old, -+ struct htree_lock_node *new) -+{ -+ if (!list_empty(&old->ln_major_list)) -+ list_replace_init(&old->ln_major_list, &new->ln_major_list); -+ -+ if (!list_empty(&old->ln_minor_list)) -+ list_replace_init(&old->ln_minor_list, &new->ln_minor_list); -+} -+ -+static void -+htree_key_event_enqueue(struct htree_lock_child *child, -+ struct htree_lock_node *ln, int dep, void *event) -+{ -+ struct htree_lock_node *tmp; -+ -+ /* NB: ALWAYS called holding lhead::lh_lock(dep) */ -+ BUG_ON(ln->ln_mode == HTREE_LOCK_NL); -+ if (event == NULL || htree_key_event_ignore(child, ln)) -+ return; -+ -+ /* shouldn't be a very long list */ -+ list_for_each_entry(tmp, &ln->ln_alive_list, ln_alive_list) { -+ if (tmp->ln_mode == HTREE_LOCK_NL) { -+ ln_event_inc(dep); -+ if (child->lc_callback != NULL) -+ child->lc_callback(tmp->ln_ev_target, event); -+ } -+ } -+} -+ -+static int -+htree_node_lock_enqueue(struct htree_lock *newlk, struct htree_lock *curlk, -+ unsigned dep, int wait, void *event) -+{ -+ struct htree_lock_child *child = &newlk->lk_head->lh_children[dep]; -+ struct htree_lock_node *newln = &newlk->lk_nodes[dep]; -+ struct htree_lock_node *curln = &curlk->lk_nodes[dep]; -+ -+ /* NB: ALWAYS called holding lhead::lh_lock(dep) */ -+ /* NB: we only expect PR/PW lock mode at here, only these two modes are -+ * allowed for htree_node_lock(asserted in htree_node_lock_internal), -+ * NL is only used for listener, user can't directly require NL mode */ -+ if ((curln->ln_mode == HTREE_LOCK_NL) || -+ (curln->ln_mode != HTREE_LOCK_PW && -+ newln->ln_mode != HTREE_LOCK_PW)) { -+ /* no conflict, attach it on granted list of @curlk */ -+ if (curln->ln_mode != HTREE_LOCK_NL) { -+ list_add(&newln->ln_granted_list, -+ &curln->ln_granted_list); -+ } else { -+ /* replace key owner */ -+ htree_key_list_replace_init(curln, newln); -+ } -+ -+ list_add(&newln->ln_alive_list, &curln->ln_alive_list); -+ htree_key_event_enqueue(child, newln, dep, event); -+ ln_grant_inc(dep, newln->ln_mode); -+ return 1; /* still hold lh_lock */ -+ } -+ -+ if (!wait) { /* can't grant and don't want to wait */ -+ ln_retry_inc(dep, newln->ln_mode); -+ newln->ln_mode = HTREE_LOCK_INVAL; -+ return -1; /* don't wait and just return -1 */ -+ } -+ -+ newlk->lk_task = current; -+ set_current_state(TASK_UNINTERRUPTIBLE); -+ /* conflict, attach it on blocked list of curlk */ -+ list_add_tail(&newln->ln_blocked_list, &curln->ln_blocked_list); -+ list_add(&newln->ln_alive_list, &curln->ln_alive_list); -+ ln_block_inc(dep, newln->ln_mode); -+ -+ htree_spin_unlock(newlk->lk_head, dep); -+ /* wait to be given the lock */ -+ if (newlk->lk_task != NULL) -+ schedule(); -+ /* granted, no doubt, wake up will set me RUNNING */ -+ if (event == NULL || htree_key_event_ignore(child, newln)) -+ return 0; /* granted without lh_lock */ -+ -+ htree_spin_lock(newlk->lk_head, dep); -+ htree_key_event_enqueue(child, newln, dep, event); -+ return 1; /* still hold lh_lock */ -+} -+ -+/* -+ * get PR/PW access to particular tree-node according to @dep and @key, -+ * it will return -1 if @wait is false and can't immediately grant this lock. -+ * All listeners(HTREE_LOCK_NL) on @dep and with the same @key will get -+ * @event if it's not NULL. -+ * NB: ALWAYS called holding lhead::lh_lock -+ */ -+static int -+htree_node_lock_internal(struct htree_lock_head *lhead, struct htree_lock *lck, -+ htree_lock_mode_t mode, u32 key, unsigned dep, -+ int wait, void *event) -+{ -+ LIST_HEAD(list); -+ struct htree_lock *tmp; -+ struct htree_lock *tmp2; -+ u16 major; -+ u16 minor; -+ u8 reverse; -+ u8 ma_bits; -+ u8 mi_bits; -+ -+ BUG_ON(mode != HTREE_LOCK_PW && mode != HTREE_LOCK_PR); -+ BUG_ON(htree_node_is_granted(lck, dep)); -+ -+ key = hash_long(key, lhead->lh_hbits); -+ -+ mi_bits = lhead->lh_hbits >> 1; -+ ma_bits = lhead->lh_hbits - mi_bits; -+ -+ lck->lk_nodes[dep].ln_major_key = major = key & ((1U << ma_bits) - 1); -+ lck->lk_nodes[dep].ln_minor_key = minor = key >> ma_bits; -+ lck->lk_nodes[dep].ln_mode = mode; -+ -+ /* -+ * The major key list is an ordered list, so searches are started -+ * at the end of the list that is numerically closer to major_key, -+ * so at most half of the list will be walked (for well-distributed -+ * keys). The list traversal aborts early if the expected key -+ * location is passed. -+ */ -+ reverse = (major >= (1 << (ma_bits - 1))); -+ -+ if (reverse) { -+ list_for_each_entry_reverse(tmp, -+ &lhead->lh_children[dep].lc_list, -+ lk_nodes[dep].ln_major_list) { -+ if (tmp->lk_nodes[dep].ln_major_key == major) { -+ goto search_minor; -+ -+ } else if (tmp->lk_nodes[dep].ln_major_key < major) { -+ /* attach _after_ @tmp */ -+ list_add(&lck->lk_nodes[dep].ln_major_list, -+ &tmp->lk_nodes[dep].ln_major_list); -+ goto out_grant_major; -+ } -+ } -+ -+ list_add(&lck->lk_nodes[dep].ln_major_list, -+ &lhead->lh_children[dep].lc_list); -+ goto out_grant_major; -+ -+ } else { -+ list_for_each_entry(tmp, &lhead->lh_children[dep].lc_list, -+ lk_nodes[dep].ln_major_list) { -+ if (tmp->lk_nodes[dep].ln_major_key == major) { -+ goto search_minor; -+ -+ } else if (tmp->lk_nodes[dep].ln_major_key > major) { -+ /* insert _before_ @tmp */ -+ list_add_tail(&lck->lk_nodes[dep].ln_major_list, -+ &tmp->lk_nodes[dep].ln_major_list); -+ goto out_grant_major; -+ } -+ } -+ -+ list_add_tail(&lck->lk_nodes[dep].ln_major_list, -+ &lhead->lh_children[dep].lc_list); -+ goto out_grant_major; -+ } -+ -+ search_minor: -+ /* -+ * NB: minor_key list doesn't have a "head", @list is just a -+ * temporary stub for helping list searching, make sure it's removed -+ * after searching. -+ * minor_key list is an ordered list too. -+ */ -+ list_add_tail(&list, &tmp->lk_nodes[dep].ln_minor_list); -+ -+ reverse = (minor >= (1 << (mi_bits - 1))); -+ -+ if (reverse) { -+ list_for_each_entry_reverse(tmp2, &list, -+ lk_nodes[dep].ln_minor_list) { -+ if (tmp2->lk_nodes[dep].ln_minor_key == minor) { -+ goto out_enqueue; -+ -+ } else if (tmp2->lk_nodes[dep].ln_minor_key < minor) { -+ /* attach _after_ @tmp2 */ -+ list_add(&lck->lk_nodes[dep].ln_minor_list, -+ &tmp2->lk_nodes[dep].ln_minor_list); -+ goto out_grant_minor; -+ } -+ } -+ -+ list_add(&lck->lk_nodes[dep].ln_minor_list, &list); -+ -+ } else { -+ list_for_each_entry(tmp2, &list, -+ lk_nodes[dep].ln_minor_list) { -+ if (tmp2->lk_nodes[dep].ln_minor_key == minor) { -+ goto out_enqueue; -+ -+ } else if (tmp2->lk_nodes[dep].ln_minor_key > minor) { -+ /* insert _before_ @tmp2 */ -+ list_add_tail(&lck->lk_nodes[dep].ln_minor_list, -+ &tmp2->lk_nodes[dep].ln_minor_list); -+ goto out_grant_minor; -+ } -+ } -+ -+ list_add_tail(&lck->lk_nodes[dep].ln_minor_list, &list); -+ } -+ -+ out_grant_minor: -+ if (list.next == &lck->lk_nodes[dep].ln_minor_list) { -+ /* new lock @lck is the first one on minor_key list, which -+ * means it has the smallest minor_key and it should -+ * replace @tmp as minor_key owner */ -+ list_replace_init(&tmp->lk_nodes[dep].ln_major_list, -+ &lck->lk_nodes[dep].ln_major_list); -+ } -+ /* remove the temporary head */ -+ list_del(&list); -+ -+ out_grant_major: -+ ln_grant_inc(dep, lck->lk_nodes[dep].ln_mode); -+ return 1; /* granted with holding lh_lock */ -+ -+ out_enqueue: -+ list_del(&list); /* remove temprary head */ -+ return htree_node_lock_enqueue(lck, tmp2, dep, wait, event); -+} -+ -+/* -+ * release the key of @lck at level @dep, and grant any blocked locks. -+ * caller will still listen on @key if @event is not NULL, which means -+ * caller can see a event (by event_cb) while granting any lock with -+ * the same key at level @dep. -+ * NB: ALWAYS called holding lhead::lh_lock -+ * NB: listener will not block anyone because listening mode is HTREE_LOCK_NL -+ */ -+static void -+htree_node_unlock_internal(struct htree_lock_head *lhead, -+ struct htree_lock *curlk, unsigned dep, void *event) -+{ -+ struct htree_lock_node *curln = &curlk->lk_nodes[dep]; -+ struct htree_lock *grtlk = NULL; -+ struct htree_lock_node *grtln; -+ struct htree_lock *poslk; -+ struct htree_lock *tmplk; -+ -+ if (!htree_node_is_granted(curlk, dep)) -+ return; -+ -+ if (!list_empty(&curln->ln_granted_list)) { -+ /* there is another granted lock */ -+ grtlk = list_entry(curln->ln_granted_list.next, -+ struct htree_lock, -+ lk_nodes[dep].ln_granted_list); -+ list_del_init(&curln->ln_granted_list); -+ } -+ -+ if (grtlk == NULL && !list_empty(&curln->ln_blocked_list)) { -+ /* -+ * @curlk is the only granted lock, so we confirmed: -+ * a) curln is key owner (attached on major/minor_list), -+ * so if there is any blocked lock, it should be attached -+ * on curln->ln_blocked_list -+ * b) we always can grant the first blocked lock -+ */ -+ grtlk = list_entry(curln->ln_blocked_list.next, -+ struct htree_lock, -+ lk_nodes[dep].ln_blocked_list); -+ BUG_ON(grtlk->lk_task == NULL); -+ wake_up_process(grtlk->lk_task); -+ } -+ -+ if (event != NULL && -+ lhead->lh_children[dep].lc_events != HTREE_EVENT_DISABLE) { -+ curln->ln_ev_target = event; -+ curln->ln_mode = HTREE_LOCK_NL; /* listen! */ -+ } else { -+ curln->ln_mode = HTREE_LOCK_INVAL; -+ } -+ -+ if (grtlk == NULL) { /* I must be the only one locking this key */ -+ struct htree_lock_node *tmpln; -+ -+ BUG_ON(htree_key_list_empty(curln)); -+ -+ if (curln->ln_mode == HTREE_LOCK_NL) /* listening */ -+ return; -+ -+ /* not listening */ -+ if (list_empty(&curln->ln_alive_list)) { /* no more listener */ -+ htree_key_list_del_init(curln); -+ return; -+ } -+ -+ tmpln = list_entry(curln->ln_alive_list.next, -+ struct htree_lock_node, ln_alive_list); -+ -+ BUG_ON(tmpln->ln_mode != HTREE_LOCK_NL); -+ -+ htree_key_list_replace_init(curln, tmpln); -+ list_del_init(&curln->ln_alive_list); -+ -+ return; -+ } -+ -+ /* have a granted lock */ -+ grtln = &grtlk->lk_nodes[dep]; -+ if (!list_empty(&curln->ln_blocked_list)) { -+ /* only key owner can be on both lists */ -+ BUG_ON(htree_key_list_empty(curln)); -+ -+ if (list_empty(&grtln->ln_blocked_list)) { -+ list_add(&grtln->ln_blocked_list, -+ &curln->ln_blocked_list); -+ } -+ list_del_init(&curln->ln_blocked_list); -+ } -+ /* -+ * NB: this is the tricky part: -+ * We have only two modes for child-lock (PR and PW), also, -+ * only owner of the key (attached on major/minor_list) can be on -+ * both blocked_list and granted_list, so @grtlk must be one -+ * of these two cases: -+ * -+ * a) @grtlk is taken from granted_list, which means we've granted -+ * more than one lock so @grtlk has to be PR, the first blocked -+ * lock must be PW and we can't grant it at all. -+ * So even @grtlk is not owner of the key (empty blocked_list), -+ * we don't care because we can't grant any lock. -+ * b) we just grant a new lock which is taken from head of blocked -+ * list, and it should be the first granted lock, and it should -+ * be the first one linked on blocked_list. -+ * -+ * Either way, we can get correct result by iterating blocked_list -+ * of @grtlk, and don't have to bother on how to find out -+ * owner of current key. -+ */ -+ list_for_each_entry_safe(poslk, tmplk, &grtln->ln_blocked_list, -+ lk_nodes[dep].ln_blocked_list) { -+ if (grtlk->lk_nodes[dep].ln_mode == HTREE_LOCK_PW || -+ poslk->lk_nodes[dep].ln_mode == HTREE_LOCK_PW) -+ break; -+ /* grant all readers */ -+ list_del_init(&poslk->lk_nodes[dep].ln_blocked_list); -+ list_add(&poslk->lk_nodes[dep].ln_granted_list, -+ &grtln->ln_granted_list); -+ -+ BUG_ON(poslk->lk_task == NULL); -+ wake_up_process(poslk->lk_task); -+ } -+ -+ /* if @curln is the owner of this key, replace it with @grtln */ -+ if (!htree_key_list_empty(curln)) -+ htree_key_list_replace_init(curln, grtln); -+ -+ if (curln->ln_mode == HTREE_LOCK_INVAL) -+ list_del_init(&curln->ln_alive_list); -+} -+ -+/* -+ * it's just wrapper of htree_node_lock_internal, it returns 1 on granted -+ * and 0 only if @wait is false and can't grant it immediately -+ */ -+int -+htree_node_lock_try(struct htree_lock *lck, htree_lock_mode_t mode, -+ u32 key, unsigned dep, int wait, void *event) -+{ -+ struct htree_lock_head *lhead = lck->lk_head; -+ int rc; -+ -+ BUG_ON(dep >= lck->lk_depth); -+ BUG_ON(lck->lk_mode == HTREE_LOCK_INVAL); -+ -+ htree_spin_lock(lhead, dep); -+ rc = htree_node_lock_internal(lhead, lck, mode, key, dep, wait, event); -+ if (rc != 0) -+ htree_spin_unlock(lhead, dep); -+ return rc >= 0; -+} -+EXPORT_SYMBOL(htree_node_lock_try); -+ -+/* it's wrapper of htree_node_unlock_internal */ -+void -+htree_node_unlock(struct htree_lock *lck, unsigned dep, void *event) -+{ -+ struct htree_lock_head *lhead = lck->lk_head; -+ -+ BUG_ON(dep >= lck->lk_depth); -+ BUG_ON(lck->lk_mode == HTREE_LOCK_INVAL); -+ -+ htree_spin_lock(lhead, dep); -+ htree_node_unlock_internal(lhead, lck, dep, event); -+ htree_spin_unlock(lhead, dep); -+} -+EXPORT_SYMBOL(htree_node_unlock); -+ -+/* stop listening on child-lock level @dep */ -+void -+htree_node_stop_listen(struct htree_lock *lck, unsigned dep) -+{ -+ struct htree_lock_node *ln = &lck->lk_nodes[dep]; -+ struct htree_lock_node *tmp; -+ -+ BUG_ON(htree_node_is_granted(lck, dep)); -+ BUG_ON(!list_empty(&ln->ln_blocked_list)); -+ BUG_ON(!list_empty(&ln->ln_granted_list)); -+ -+ if (!htree_node_is_listening(lck, dep)) -+ return; -+ -+ htree_spin_lock(lck->lk_head, dep); -+ ln->ln_mode = HTREE_LOCK_INVAL; -+ ln->ln_ev_target = NULL; -+ -+ if (htree_key_list_empty(ln)) { /* not owner */ -+ list_del_init(&ln->ln_alive_list); -+ goto out; -+ } -+ -+ /* I'm the owner... */ -+ if (list_empty(&ln->ln_alive_list)) { /* no more listener */ -+ htree_key_list_del_init(ln); -+ goto out; -+ } -+ -+ tmp = list_entry(ln->ln_alive_list.next, -+ struct htree_lock_node, ln_alive_list); -+ -+ BUG_ON(tmp->ln_mode != HTREE_LOCK_NL); -+ htree_key_list_replace_init(ln, tmp); -+ list_del_init(&ln->ln_alive_list); -+ out: -+ htree_spin_unlock(lck->lk_head, dep); -+} -+EXPORT_SYMBOL(htree_node_stop_listen); -+ -+/* release all child-locks if we have any */ -+static void -+htree_node_release_all(struct htree_lock *lck) -+{ -+ int i; -+ -+ for (i = 0; i < lck->lk_depth; i++) { -+ if (htree_node_is_granted(lck, i)) -+ htree_node_unlock(lck, i, NULL); -+ else if (htree_node_is_listening(lck, i)) -+ htree_node_stop_listen(lck, i); -+ } -+} -+ -+/* -+ * obtain htree lock, it could be blocked inside if there's conflict -+ * with any granted or blocked lock and @wait is true. -+ * NB: ALWAYS called holding lhead::lh_lock -+ */ -+static int -+htree_lock_internal(struct htree_lock *lck, int wait) -+{ -+ struct htree_lock_head *lhead = lck->lk_head; -+ int granted = 0; -+ int blocked = 0; -+ int i; -+ -+ for (i = 0; i < HTREE_LOCK_MAX; i++) { -+ if (lhead->lh_ngranted[i] != 0) -+ granted |= 1 << i; -+ if (lhead->lh_nblocked[i] != 0) -+ blocked |= 1 << i; -+ } -+ if ((htree_lock_compat[lck->lk_mode] & granted) != granted || -+ (htree_lock_compat[lck->lk_mode] & blocked) != blocked) { -+ /* will block current lock even it just conflicts with any -+ * other blocked lock, so lock like EX wouldn't starve */ -+ if (!wait) -+ return -1; -+ lhead->lh_nblocked[lck->lk_mode]++; -+ lk_block_inc(lck->lk_mode); -+ -+ lck->lk_task = current; -+ list_add_tail(&lck->lk_blocked_list, &lhead->lh_blocked_list); -+ -+ set_current_state(TASK_UNINTERRUPTIBLE); -+ htree_spin_unlock(lhead, HTREE_DEP_ROOT); -+ /* wait to be given the lock */ -+ if (lck->lk_task != NULL) -+ schedule(); -+ /* granted, no doubt. wake up will set me RUNNING */ -+ return 0; /* without lh_lock */ -+ } -+ lhead->lh_ngranted[lck->lk_mode]++; -+ lk_grant_inc(lck->lk_mode); -+ return 1; -+} -+ -+/* release htree lock. NB: ALWAYS called holding lhead::lh_lock */ -+static void -+htree_unlock_internal(struct htree_lock *lck) -+{ -+ struct htree_lock_head *lhead = lck->lk_head; -+ struct htree_lock *tmp; -+ struct htree_lock *tmp2; -+ int granted = 0; -+ int i; -+ -+ BUG_ON(lhead->lh_ngranted[lck->lk_mode] == 0); -+ -+ lhead->lh_ngranted[lck->lk_mode]--; -+ lck->lk_mode = HTREE_LOCK_INVAL; -+ -+ for (i = 0; i < HTREE_LOCK_MAX; i++) { -+ if (lhead->lh_ngranted[i] != 0) -+ granted |= 1 << i; -+ } -+ list_for_each_entry_safe(tmp, tmp2, -+ &lhead->lh_blocked_list, lk_blocked_list) { -+ /* conflict with any granted lock? */ -+ if ((htree_lock_compat[tmp->lk_mode] & granted) != granted) -+ break; -+ -+ list_del_init(&tmp->lk_blocked_list); -+ -+ BUG_ON(lhead->lh_nblocked[tmp->lk_mode] == 0); -+ -+ lhead->lh_nblocked[tmp->lk_mode]--; -+ lhead->lh_ngranted[tmp->lk_mode]++; -+ granted |= 1 << tmp->lk_mode; -+ -+ BUG_ON(tmp->lk_task == NULL); -+ wake_up_process(tmp->lk_task); -+ } -+} -+ -+/* it's wrapper of htree_lock_internal and exported interface. -+ * It always return 1 with granted lock if @wait is true, it can return 0 -+ * if @wait is false and locking request can't be granted immediately */ -+int -+htree_lock_try(struct htree_lock *lck, struct htree_lock_head *lhead, -+ htree_lock_mode_t mode, int wait) -+{ -+ int rc; -+ -+ BUG_ON(lck->lk_depth > lhead->lh_depth); -+ BUG_ON(lck->lk_head != NULL); -+ BUG_ON(lck->lk_task != NULL); -+ -+ lck->lk_head = lhead; -+ lck->lk_mode = mode; -+ -+ htree_spin_lock(lhead, HTREE_DEP_ROOT); -+ rc = htree_lock_internal(lck, wait); -+ if (rc != 0) -+ htree_spin_unlock(lhead, HTREE_DEP_ROOT); -+ return rc >= 0; -+} -+EXPORT_SYMBOL(htree_lock_try); -+ -+/* it's wrapper of htree_unlock_internal and exported interface. -+ * It will release all htree_node_locks and htree_lock */ -+void -+htree_unlock(struct htree_lock *lck) -+{ -+ BUG_ON(lck->lk_head == NULL); -+ BUG_ON(lck->lk_mode == HTREE_LOCK_INVAL); -+ -+ htree_node_release_all(lck); -+ -+ htree_spin_lock(lck->lk_head, HTREE_DEP_ROOT); -+ htree_unlock_internal(lck); -+ htree_spin_unlock(lck->lk_head, HTREE_DEP_ROOT); -+ lck->lk_head = NULL; -+ lck->lk_task = NULL; -+} -+EXPORT_SYMBOL(htree_unlock); -+ -+/* change lock mode */ -+void -+htree_change_mode(struct htree_lock *lck, htree_lock_mode_t mode) -+{ -+ BUG_ON(lck->lk_mode == HTREE_LOCK_INVAL); -+ lck->lk_mode = mode; -+} -+EXPORT_SYMBOL(htree_change_mode); -+ -+/* release htree lock, and lock it again with new mode. -+ * This function will first release all htree_node_locks and htree_lock, -+ * then try to gain htree_lock with new @mode. -+ * It always return 1 with granted lock if @wait is true, it can return 0 -+ * if @wait is false and locking request can't be granted immediately */ -+int -+htree_change_lock_try(struct htree_lock *lck, htree_lock_mode_t mode, int wait) -+{ -+ struct htree_lock_head *lhead = lck->lk_head; -+ int rc; -+ -+ BUG_ON(lhead == NULL); -+ BUG_ON(lck->lk_mode == mode); -+ BUG_ON(lck->lk_mode == HTREE_LOCK_INVAL || mode == HTREE_LOCK_INVAL); -+ -+ htree_node_release_all(lck); -+ -+ htree_spin_lock(lhead, HTREE_DEP_ROOT); -+ htree_unlock_internal(lck); -+ lck->lk_mode = mode; -+ rc = htree_lock_internal(lck, wait); -+ if (rc != 0) -+ htree_spin_unlock(lhead, HTREE_DEP_ROOT); -+ return rc >= 0; -+} -+EXPORT_SYMBOL(htree_change_lock_try); -+ -+/* create a htree_lock head with @depth levels (number of child-locks), -+ * it is a per resoruce structure */ -+struct htree_lock_head * -+htree_lock_head_alloc(unsigned depth, unsigned hbits, unsigned priv) -+{ -+ struct htree_lock_head *lhead; -+ int i; -+ -+ if (depth > HTREE_LOCK_DEP_MAX) { -+ printk(KERN_ERR "%d is larger than max htree_lock depth %d\n", -+ depth, HTREE_LOCK_DEP_MAX); -+ return NULL; -+ } -+ -+ lhead = kzalloc(offsetof(struct htree_lock_head, -+ lh_children[depth]) + priv, GFP_NOFS); -+ if (lhead == NULL) -+ return NULL; -+ -+ if (hbits < HTREE_HBITS_MIN) -+ lhead->lh_hbits = HTREE_HBITS_MIN; -+ else if (hbits > HTREE_HBITS_MAX) -+ lhead->lh_hbits = HTREE_HBITS_MAX; -+ -+ lhead->lh_lock = 0; -+ lhead->lh_depth = depth; -+ INIT_LIST_HEAD(&lhead->lh_blocked_list); -+ if (priv > 0) { -+ lhead->lh_private = (void *)lhead + -+ offsetof(struct htree_lock_head, lh_children[depth]); -+ } -+ -+ for (i = 0; i < depth; i++) { -+ INIT_LIST_HEAD(&lhead->lh_children[i].lc_list); -+ lhead->lh_children[i].lc_events = HTREE_EVENT_DISABLE; -+ } -+ return lhead; -+} -+EXPORT_SYMBOL(htree_lock_head_alloc); -+ -+/* free the htree_lock head */ -+void -+htree_lock_head_free(struct htree_lock_head *lhead) -+{ -+ int i; -+ -+ BUG_ON(!list_empty(&lhead->lh_blocked_list)); -+ for (i = 0; i < lhead->lh_depth; i++) -+ BUG_ON(!list_empty(&lhead->lh_children[i].lc_list)); -+ kfree(lhead); -+} -+EXPORT_SYMBOL(htree_lock_head_free); -+ -+/* register event callback for @events of child-lock at level @dep */ -+void -+htree_lock_event_attach(struct htree_lock_head *lhead, unsigned dep, -+ unsigned events, htree_event_cb_t callback) -+{ -+ BUG_ON(lhead->lh_depth <= dep); -+ lhead->lh_children[dep].lc_events = events; -+ lhead->lh_children[dep].lc_callback = callback; -+} -+EXPORT_SYMBOL(htree_lock_event_attach); -+ -+/* allocate a htree_lock, which is per-thread structure, @pbytes is some -+ * extra-bytes as private data for caller */ -+struct htree_lock * -+htree_lock_alloc(unsigned depth, unsigned pbytes) -+{ -+ struct htree_lock *lck; -+ int i = offsetof(struct htree_lock, lk_nodes[depth]); -+ -+ if (depth > HTREE_LOCK_DEP_MAX) { -+ printk(KERN_ERR "%d is larger than max htree_lock depth %d\n", -+ depth, HTREE_LOCK_DEP_MAX); -+ return NULL; -+ } -+ lck = kzalloc(i + pbytes, GFP_NOFS); -+ if (lck == NULL) -+ return NULL; -+ -+ if (pbytes != 0) -+ lck->lk_private = (void *)lck + i; -+ lck->lk_mode = HTREE_LOCK_INVAL; -+ lck->lk_depth = depth; -+ INIT_LIST_HEAD(&lck->lk_blocked_list); -+ -+ for (i = 0; i < depth; i++) { -+ struct htree_lock_node *node = &lck->lk_nodes[i]; -+ -+ node->ln_mode = HTREE_LOCK_INVAL; -+ INIT_LIST_HEAD(&node->ln_major_list); -+ INIT_LIST_HEAD(&node->ln_minor_list); -+ INIT_LIST_HEAD(&node->ln_alive_list); -+ INIT_LIST_HEAD(&node->ln_blocked_list); -+ INIT_LIST_HEAD(&node->ln_granted_list); -+ } -+ -+ return lck; -+} -+EXPORT_SYMBOL(htree_lock_alloc); -+ -+/* free htree_lock node */ -+void -+htree_lock_free(struct htree_lock *lck) -+{ -+ BUG_ON(lck->lk_mode != HTREE_LOCK_INVAL); -+ kfree(lck); -+} -+EXPORT_SYMBOL(htree_lock_free); -Index: linux-3.10.0-229.1.2.fc21.x86_64/fs/ext4/Makefile -=================================================================== ---- linux-3.10.0-229.1.2.fc21.x86_64.orig/fs/ext4/Makefile -+++ linux-3.10.0-229.1.2.fc21.x86_64/fs/ext4/Makefile -@@ -6,6 +6,7 @@ obj-$(CONFIG_EXT4_FS) += ext4.o - - ext4-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o page-io.o \ - ioctl.o namei.o super.o symlink.o hash.o resize.o extents.o \ -+ htree_lock.o \ - ext4_jbd2.o migrate.o mballoc.o block_validity.o move_extent.o \ - mmp.o indirect.o extents_status.o xattr.o xattr_user.o \ - xattr_trusted.o inline.o -Index: linux-3.10.0-229.1.2.fc21.x86_64/fs/ext4/ext4.h -=================================================================== ---- linux-3.10.0-229.1.2.fc21.x86_64.orig/fs/ext4/ext4.h -+++ linux-3.10.0-229.1.2.fc21.x86_64/fs/ext4/ext4.h -@@ -27,6 +27,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -821,6 +822,9 @@ struct ext4_inode_info { - __u32 i_dtime; - ext4_fsblk_t i_file_acl; - -+ /* following fields for parallel directory operations -bzzz */ -+ struct semaphore i_append_sem; -+ - /* - * i_block_group is the number of the block group which contains - * this file's inode. Constant across the lifetime of the inode, -@@ -1846,6 +1850,71 @@ struct dx_hash_info - */ - #define HASH_NB_ALWAYS 1 - -+/* assume name-hash is protected by upper layer */ -+#define EXT4_HTREE_LOCK_HASH 0 -+ -+enum ext4_pdo_lk_types { -+#if EXT4_HTREE_LOCK_HASH -+ EXT4_LK_HASH, -+#endif -+ EXT4_LK_DX, /* index block */ -+ EXT4_LK_DE, /* directory entry block */ -+ EXT4_LK_SPIN, /* spinlock */ -+ EXT4_LK_MAX, -+}; -+ -+/* read-only bit */ -+#define EXT4_LB_RO(b) (1 << (b)) -+/* read + write, high bits for writer */ -+#define EXT4_LB_RW(b) ((1 << (b)) | (1 << (EXT4_LK_MAX + (b)))) -+ -+enum ext4_pdo_lock_bits { -+ /* DX lock bits */ -+ EXT4_LB_DX_RO = EXT4_LB_RO(EXT4_LK_DX), -+ EXT4_LB_DX = EXT4_LB_RW(EXT4_LK_DX), -+ /* DE lock bits */ -+ EXT4_LB_DE_RO = EXT4_LB_RO(EXT4_LK_DE), -+ EXT4_LB_DE = EXT4_LB_RW(EXT4_LK_DE), -+ /* DX spinlock bits */ -+ EXT4_LB_SPIN_RO = EXT4_LB_RO(EXT4_LK_SPIN), -+ EXT4_LB_SPIN = EXT4_LB_RW(EXT4_LK_SPIN), -+ /* accurate searching */ -+ EXT4_LB_EXACT = EXT4_LB_RO(EXT4_LK_MAX << 1), -+}; -+ -+enum ext4_pdo_lock_opc { -+ /* external */ -+ EXT4_HLOCK_READDIR = (EXT4_LB_DE_RO | EXT4_LB_DX_RO), -+ EXT4_HLOCK_LOOKUP = (EXT4_LB_DE_RO | EXT4_LB_SPIN_RO | -+ EXT4_LB_EXACT), -+ EXT4_HLOCK_DEL = (EXT4_LB_DE | EXT4_LB_SPIN_RO | -+ EXT4_LB_EXACT), -+ EXT4_HLOCK_ADD = (EXT4_LB_DE | EXT4_LB_SPIN_RO), -+ -+ /* internal */ -+ EXT4_HLOCK_LOOKUP_SAFE = (EXT4_LB_DE_RO | EXT4_LB_DX_RO | -+ EXT4_LB_EXACT), -+ EXT4_HLOCK_DEL_SAFE = (EXT4_LB_DE | EXT4_LB_DX_RO | EXT4_LB_EXACT), -+ EXT4_HLOCK_SPLIT = (EXT4_LB_DE | EXT4_LB_DX | EXT4_LB_SPIN), -+}; -+ -+extern struct htree_lock_head *ext4_htree_lock_head_alloc(unsigned hbits); -+#define ext4_htree_lock_head_free(lhead) htree_lock_head_free(lhead) -+ -+extern struct htree_lock *ext4_htree_lock_alloc(void); -+#define ext4_htree_lock_free(lck) htree_lock_free(lck) -+ -+extern void ext4_htree_lock(struct htree_lock *lck, -+ struct htree_lock_head *lhead, -+ struct inode *dir, unsigned flags); -+#define ext4_htree_unlock(lck) htree_unlock(lck) -+ -+extern struct buffer_head *__ext4_find_entry(struct inode *dir, -+ const struct qstr *d_name, -+ struct ext4_dir_entry_2 **res_dir, -+ int *inlined, struct htree_lock *lck); -+extern int __ext4_add_entry(handle_t *handle, struct dentry *dentry, -+ struct inode *inode, struct htree_lock *lck); - - /* - * Describe an inode's exact location on disk and in memory -@@ -2088,9 +2157,17 @@ void ext4_insert_dentry(struct inode *in - const char *name, int namelen, void *data); - static inline void ext4_update_dx_flag(struct inode *inode) - { -+ /* Disable it for ldiskfs, because going from a DX directory to -+ * a non-DX directory while it is in use will completely break -+ * the htree-locking. -+ * If we really want to support this operation in the future, -+ * we need to exclusively lock the directory at here which will -+ * increase complexity of code */ -+#if 0 - if (!EXT4_HAS_COMPAT_FEATURE(inode->i_sb, - EXT4_FEATURE_COMPAT_DIR_INDEX)) - ext4_clear_inode_flag(inode, EXT4_INODE_INDEX); -+#endif - } - static unsigned char ext4_filetype_table[] = { - DT_UNKNOWN, DT_REG, DT_DIR, DT_CHR, DT_BLK, DT_FIFO, DT_SOCK, DT_LNK -Index: linux-3.10.0-229.1.2.fc21.x86_64/fs/ext4/namei.c -=================================================================== ---- linux-3.10.0-229.1.2.fc21.x86_64.orig/fs/ext4/namei.c -+++ linux-3.10.0-229.1.2.fc21.x86_64/fs/ext4/namei.c -@@ -53,6 +53,7 @@ struct buffer_head *ext4_append(handle_t - ext4_lblk_t *block) - { - struct buffer_head *bh; -+ struct ext4_inode_info *ei = EXT4_I(inode); - int err = 0; - - if (unlikely(EXT4_SB(inode->i_sb)->s_max_dir_size_kb && -@@ -60,15 +61,22 @@ struct buffer_head *ext4_append(handle_t - EXT4_SB(inode->i_sb)->s_max_dir_size_kb))) - return ERR_PTR(-ENOSPC); - -+ /* with parallel dir operations all appends -+ * have to be serialized -bzzz */ -+ down(&ei->i_append_sem); -+ - *block = inode->i_size >> inode->i_sb->s_blocksize_bits; - - bh = ext4_bread(handle, inode, *block, 1, &err); -- if (!bh) -+ if (!bh) { -+ up(&ei->i_append_sem); - return ERR_PTR(err); -+ } - inode->i_size += inode->i_sb->s_blocksize; - EXT4_I(inode)->i_disksize = inode->i_size; - BUFFER_TRACE(bh, "get_write_access"); - err = ext4_journal_get_write_access(handle, bh); -+ up(&ei->i_append_sem); - if (err) { - brelse(bh); - ext4_std_error(inode->i_sb, err); -@@ -246,7 +254,7 @@ static struct dx_frame *dx_probe(const s - struct inode *dir, - struct dx_hash_info *hinfo, - struct dx_frame *frame, -- int *err); -+ struct htree_lock *lck, int *err); - static void dx_release(struct dx_frame *frames); - static int dx_make_map(struct ext4_dir_entry_2 *de, unsigned blocksize, - struct dx_hash_info *hinfo, struct dx_map_entry map[]); -@@ -259,13 +267,13 @@ static void dx_insert_block(struct dx_fr - static int ext4_htree_next_block(struct inode *dir, __u32 hash, - struct dx_frame *frame, - struct dx_frame *frames, -- __u32 *start_hash); -+ __u32 *start_hash, struct htree_lock *lck); - static struct buffer_head * ext4_dx_find_entry(struct inode *dir, - const struct qstr *d_name, - struct ext4_dir_entry_2 **res_dir, -- int *err); -+ struct htree_lock *lck, int *err); - static int ext4_dx_add_entry(handle_t *handle, struct dentry *dentry, -- struct inode *inode); -+ struct inode *inode, struct htree_lock *lck); - - /* checksumming functions */ - void initialize_dirent_tail(struct ext4_dir_entry_tail *t, -@@ -668,6 +676,227 @@ struct stats dx_show_entries(struct dx_h - } - #endif /* DX_DEBUG */ - -+/* private data for htree_lock */ -+struct ext4_dir_lock_data { -+ unsigned ld_flags; /* bits-map for lock types */ -+ unsigned ld_count; /* # entries of the last DX block */ -+ struct dx_entry ld_at_entry; /* copy of leaf dx_entry */ -+ struct dx_entry *ld_at; /* position of leaf dx_entry */ -+}; -+ -+#define ext4_htree_lock_data(l) ((struct ext4_dir_lock_data *)(l)->lk_private) -+#define ext4_find_entry(dir, name, dirent, inline) \ -+ __ext4_find_entry(dir, name, dirent, inline, NULL) -+#define ext4_add_entry(handle, dentry, inode) \ -+ __ext4_add_entry(handle, dentry, inode, NULL) -+ -+/* NB: ext4_lblk_t is 32 bits so we use high bits to identify invalid blk */ -+#define EXT4_HTREE_NODE_CHANGED (0xcafeULL << 32) -+ -+static void ext4_htree_event_cb(void *target, void *event) -+{ -+ u64 *block = (u64 *)target; -+ -+ if (*block == dx_get_block((struct dx_entry *)event)) -+ *block = EXT4_HTREE_NODE_CHANGED; -+} -+ -+struct htree_lock_head *ext4_htree_lock_head_alloc(unsigned hbits) -+{ -+ struct htree_lock_head *lhead; -+ -+ lhead = htree_lock_head_alloc(EXT4_LK_MAX, hbits, 0); -+ if (lhead != NULL) { -+ htree_lock_event_attach(lhead, EXT4_LK_SPIN, HTREE_EVENT_WR, -+ ext4_htree_event_cb); -+ } -+ return lhead; -+} -+EXPORT_SYMBOL(ext4_htree_lock_head_alloc); -+ -+struct htree_lock *ext4_htree_lock_alloc(void) -+{ -+ return htree_lock_alloc(EXT4_LK_MAX, -+ sizeof(struct ext4_dir_lock_data)); -+} -+EXPORT_SYMBOL(ext4_htree_lock_alloc); -+ -+static htree_lock_mode_t ext4_htree_mode(unsigned flags) -+{ -+ switch (flags) { -+ default: /* 0 or unknown flags require EX lock */ -+ return HTREE_LOCK_EX; -+ case EXT4_HLOCK_READDIR: -+ return HTREE_LOCK_PR; -+ case EXT4_HLOCK_LOOKUP: -+ return HTREE_LOCK_CR; -+ case EXT4_HLOCK_DEL: -+ case EXT4_HLOCK_ADD: -+ return HTREE_LOCK_CW; -+ } -+} -+ -+/* return PR for read-only operations, otherwise return EX */ -+static inline htree_lock_mode_t ext4_htree_safe_mode(unsigned flags) -+{ -+ int writer = (flags & EXT4_LB_DE) == EXT4_LB_DE; -+ -+ /* 0 requires EX lock */ -+ return (flags == 0 || writer) ? HTREE_LOCK_EX : HTREE_LOCK_PR; -+} -+ -+static int ext4_htree_safe_locked(struct htree_lock *lck) -+{ -+ int writer; -+ -+ if (lck == NULL || lck->lk_mode == HTREE_LOCK_EX) -+ return 1; -+ -+ writer = (ext4_htree_lock_data(lck)->ld_flags & EXT4_LB_DE) == -+ EXT4_LB_DE; -+ if (writer) /* all readers & writers are excluded? */ -+ return lck->lk_mode == HTREE_LOCK_EX; -+ -+ /* all writers are excluded? */ -+ return lck->lk_mode == HTREE_LOCK_PR || -+ lck->lk_mode == HTREE_LOCK_PW || -+ lck->lk_mode == HTREE_LOCK_EX; -+} -+ -+/* relock htree_lock with EX mode if it's change operation, otherwise -+ * relock it with PR mode. It's noop if PDO is disabled. */ -+static void ext4_htree_safe_relock(struct htree_lock *lck) -+{ -+ if (!ext4_htree_safe_locked(lck)) { -+ unsigned flags = ext4_htree_lock_data(lck)->ld_flags; -+ -+ htree_change_lock(lck, ext4_htree_safe_mode(flags)); -+ } -+} -+ -+void ext4_htree_lock(struct htree_lock *lck, struct htree_lock_head *lhead, -+ struct inode *dir, unsigned flags) -+{ -+ htree_lock_mode_t mode = is_dx(dir) ? ext4_htree_mode(flags) : -+ ext4_htree_safe_mode(flags); -+ -+ ext4_htree_lock_data(lck)->ld_flags = flags; -+ htree_lock(lck, lhead, mode); -+ if (!is_dx(dir)) -+ ext4_htree_safe_relock(lck); /* make sure it's safe locked */ -+} -+EXPORT_SYMBOL(ext4_htree_lock); -+ -+static int ext4_htree_node_lock(struct htree_lock *lck, struct dx_entry *at, -+ unsigned lmask, int wait, void *ev) -+{ -+ u32 key = (at == NULL) ? 0 : dx_get_block(at); -+ u32 mode; -+ -+ /* NOOP if htree is well protected or caller doesn't require the lock */ -+ if (ext4_htree_safe_locked(lck) || -+ !(ext4_htree_lock_data(lck)->ld_flags & lmask)) -+ return 1; -+ -+ mode = (ext4_htree_lock_data(lck)->ld_flags & lmask) == lmask ? -+ HTREE_LOCK_PW : HTREE_LOCK_PR; -+ while (1) { -+ if (htree_node_lock_try(lck, mode, key, ffz(~lmask), wait, ev)) -+ return 1; -+ if (!(lmask & EXT4_LB_SPIN)) /* not a spinlock */ -+ return 0; -+ cpu_relax(); /* spin until granted */ -+ } -+} -+ -+static int ext4_htree_node_locked(struct htree_lock *lck, unsigned lmask) -+{ -+ return ext4_htree_safe_locked(lck) || -+ htree_node_is_granted(lck, ffz(~lmask)); -+} -+ -+static void ext4_htree_node_unlock(struct htree_lock *lck, -+ unsigned lmask, void *buf) -+{ -+ /* NB: it's safe to call mutiple times or even it's not locked */ -+ if (!ext4_htree_safe_locked(lck) && -+ htree_node_is_granted(lck, ffz(~lmask))) -+ htree_node_unlock(lck, ffz(~lmask), buf); -+} -+ -+#define ext4_htree_dx_lock(lck, key) \ -+ ext4_htree_node_lock(lck, key, EXT4_LB_DX, 1, NULL) -+#define ext4_htree_dx_lock_try(lck, key) \ -+ ext4_htree_node_lock(lck, key, EXT4_LB_DX, 0, NULL) -+#define ext4_htree_dx_unlock(lck) \ -+ ext4_htree_node_unlock(lck, EXT4_LB_DX, NULL) -+#define ext4_htree_dx_locked(lck) \ -+ ext4_htree_node_locked(lck, EXT4_LB_DX) -+ -+static void ext4_htree_dx_need_lock(struct htree_lock *lck) -+{ -+ struct ext4_dir_lock_data *ld; -+ -+ if (ext4_htree_safe_locked(lck)) -+ return; -+ -+ ld = ext4_htree_lock_data(lck); -+ switch (ld->ld_flags) { -+ default: -+ return; -+ case EXT4_HLOCK_LOOKUP: -+ ld->ld_flags = EXT4_HLOCK_LOOKUP_SAFE; -+ return; -+ case EXT4_HLOCK_DEL: -+ ld->ld_flags = EXT4_HLOCK_DEL_SAFE; -+ return; -+ case EXT4_HLOCK_ADD: -+ ld->ld_flags = EXT4_HLOCK_SPLIT; -+ return; -+ } -+} -+ -+#define ext4_htree_de_lock(lck, key) \ -+ ext4_htree_node_lock(lck, key, EXT4_LB_DE, 1, NULL) -+#define ext4_htree_de_unlock(lck) \ -+ ext4_htree_node_unlock(lck, EXT4_LB_DE, NULL) -+ -+#define ext4_htree_spin_lock(lck, key, event) \ -+ ext4_htree_node_lock(lck, key, EXT4_LB_SPIN, 0, event) -+#define ext4_htree_spin_unlock(lck) \ -+ ext4_htree_node_unlock(lck, EXT4_LB_SPIN, NULL) -+#define ext4_htree_spin_unlock_listen(lck, p) \ -+ ext4_htree_node_unlock(lck, EXT4_LB_SPIN, p) -+ -+static void ext4_htree_spin_stop_listen(struct htree_lock *lck) -+{ -+ if (!ext4_htree_safe_locked(lck) && -+ htree_node_is_listening(lck, ffz(~EXT4_LB_SPIN))) -+ htree_node_stop_listen(lck, ffz(~EXT4_LB_SPIN)); -+} -+ -+enum { -+ DX_HASH_COL_IGNORE, /* ignore collision while probing frames */ -+ DX_HASH_COL_YES, /* there is collision and it does matter */ -+ DX_HASH_COL_NO, /* there is no collision */ -+}; -+ -+static int dx_probe_hash_collision(struct htree_lock *lck, -+ struct dx_entry *entries, -+ struct dx_entry *at, u32 hash) -+{ -+ if (!(lck && ext4_htree_lock_data(lck)->ld_flags & EXT4_LB_EXACT)) { -+ return DX_HASH_COL_IGNORE; /* don't care about collision */ -+ -+ } else if (at == entries + dx_get_count(entries) - 1) { -+ return DX_HASH_COL_IGNORE; /* not in any leaf of this DX */ -+ -+ } else { /* hash collision? */ -+ return ((dx_get_hash(at + 1) & ~1) == hash) ? -+ DX_HASH_COL_YES : DX_HASH_COL_NO; -+ } -+} -+ - /* - * Probe for a directory leaf block to search. - * -@@ -679,10 +908,11 @@ struct stats dx_show_entries(struct dx_h - */ - static struct dx_frame * - dx_probe(const struct qstr *d_name, struct inode *dir, -- struct dx_hash_info *hinfo, struct dx_frame *frame_in, int *err) -+ struct dx_hash_info *hinfo, struct dx_frame *frame_in, -+ struct htree_lock *lck, int *err) - { - unsigned count, indirect; -- struct dx_entry *at, *entries, *p, *q, *m; -+ struct dx_entry *at, *entries, *p, *q, *m, *dx = NULL; - struct dx_root_info *info; - struct buffer_head *bh; - struct dx_frame *frame = frame_in; -@@ -750,8 +980,15 @@ dx_probe(const struct qstr *d_name, stru - dxtrace(printk("Look up %x", hash)); - while (1) - { -+ if (indirect == 0) { /* the last index level */ -+ /* NB: ext4_htree_dx_lock() could be noop if -+ * DX-lock flag is not set for current operation */ -+ ext4_htree_dx_lock(lck, dx); -+ ext4_htree_spin_lock(lck, dx, NULL); -+ } - count = dx_get_count(entries); -- if (!count || count > dx_get_limit(entries)) { -+ if (count == 0 || count > dx_get_limit(entries)) { -+ ext4_htree_spin_unlock(lck); /* release spin */ - ext4_warning(dir->i_sb, - "dx entry: no count or count > limit"); - brelse(bh); -@@ -792,7 +1029,70 @@ dx_probe(const struct qstr *d_name, stru - frame->bh = bh; - frame->entries = entries; - frame->at = at; -- if (!indirect--) return frame; -+ -+ if (indirect == 0) { /* the last index level */ -+ struct ext4_dir_lock_data *ld; -+ u64 myblock; -+ -+ /* By default we only lock DE-block, however, we will -+ * also lock the last level DX-block if: -+ * a) there is hash collision -+ * we will set DX-lock flag (a few lines below) -+ * and redo to lock DX-block -+ * see detail in dx_probe_hash_collision() -+ * b) it's a retry from splitting -+ * we need to lock the last level DX-block so nobody -+ * else can split any leaf blocks under the same -+ * DX-block, see detail in ext4_dx_add_entry() -+ */ -+ if (ext4_htree_dx_locked(lck)) { -+ /* DX-block is locked, just lock DE-block -+ * and return */ -+ ext4_htree_spin_unlock(lck); -+ if (!ext4_htree_safe_locked(lck)) -+ ext4_htree_de_lock(lck, frame->at); -+ return frame; -+ } -+ /* it's pdirop and no DX lock */ -+ if (dx_probe_hash_collision(lck, entries, at, hash) == -+ DX_HASH_COL_YES) { -+ /* found hash collision, set DX-lock flag -+ * and retry to abtain DX-lock */ -+ ext4_htree_spin_unlock(lck); -+ ext4_htree_dx_need_lock(lck); -+ continue; -+ } -+ ld = ext4_htree_lock_data(lck); -+ /* because I don't lock DX, so @at can't be trusted -+ * after I release spinlock so I have to save it */ -+ ld->ld_at = at; -+ ld->ld_at_entry = *at; -+ ld->ld_count = dx_get_count(entries); -+ -+ frame->at = &ld->ld_at_entry; -+ myblock = dx_get_block(at); -+ -+ /* NB: ordering locking */ -+ ext4_htree_spin_unlock_listen(lck, &myblock); -+ /* other thread can split this DE-block because: -+ * a) I don't have lock for the DE-block yet -+ * b) I released spinlock on DX-block -+ * if it happened I can detect it by listening -+ * splitting event on this DE-block */ -+ ext4_htree_de_lock(lck, frame->at); -+ ext4_htree_spin_stop_listen(lck); -+ -+ if (myblock == EXT4_HTREE_NODE_CHANGED) { -+ /* someone split this DE-block before -+ * I locked it, I need to retry and lock -+ * valid DE-block */ -+ ext4_htree_de_unlock(lck); -+ continue; -+ } -+ return frame; -+ } -+ dx = at; -+ indirect--; - bh = ext4_read_dirblock(dir, dx_get_block(at), INDEX); - if (IS_ERR(bh)) { - *err = PTR_ERR(bh); -@@ -860,7 +1160,7 @@ static void dx_release (struct dx_frame - static int ext4_htree_next_block(struct inode *dir, __u32 hash, - struct dx_frame *frame, - struct dx_frame *frames, -- __u32 *start_hash) -+ __u32 *start_hash, struct htree_lock *lck) - { - struct dx_frame *p; - struct buffer_head *bh; -@@ -875,12 +1175,22 @@ static int ext4_htree_next_block(struct - * this loop, num_frames indicates the number of interior - * nodes need to be read. - */ -+ ext4_htree_de_unlock(lck); - while (1) { -- if (++(p->at) < p->entries + dx_get_count(p->entries)) -- break; -+ if (num_frames > 0 || ext4_htree_dx_locked(lck)) { -+ /* num_frames > 0 : -+ * DX block -+ * ext4_htree_dx_locked: -+ * frame->at is reliable pointer returned by dx_probe, -+ * otherwise dx_probe already knew no collision */ -+ if (++(p->at) < p->entries + dx_get_count(p->entries)) -+ break; -+ } - if (p == frames) - return 0; - num_frames++; -+ if (num_frames == 1) -+ ext4_htree_dx_unlock(lck); - p--; - } - -@@ -903,6 +1213,13 @@ static int ext4_htree_next_block(struct - * block so no check is necessary - */ - while (num_frames--) { -+ if (num_frames == 0) { -+ /* it's not always necessary, we just don't want to -+ * detect hash collision again */ -+ ext4_htree_dx_need_lock(lck); -+ ext4_htree_dx_lock(lck, p->at); -+ } -+ - bh = ext4_read_dirblock(dir, dx_get_block(p->at), INDEX); - if (IS_ERR(bh)) - return PTR_ERR(bh); -@@ -911,6 +1228,7 @@ static int ext4_htree_next_block(struct - p->bh = bh; - p->at = p->entries = ((struct dx_node *) bh->b_data)->entries; - } -+ ext4_htree_de_lock(lck, p->at); - return 1; - } - -@@ -1013,10 +1331,10 @@ int ext4_htree_fill_tree(struct file *di - } - hinfo.hash = start_hash; - hinfo.minor_hash = 0; -- frame = dx_probe(NULL, dir, &hinfo, frames, &err); -+ /* assume it's PR locked */ -+ frame = dx_probe(NULL, dir, &hinfo, frames, NULL, &err); - if (!frame) - return err; -- - /* Add '.' and '..' from the htree header */ - if (!start_hash && !start_minor_hash) { - de = (struct ext4_dir_entry_2 *) frames[0].bh->b_data; -@@ -1043,7 +1361,7 @@ int ext4_htree_fill_tree(struct file *di - count += ret; - hashval = ~0; - ret = ext4_htree_next_block(dir, HASH_NB_ALWAYS, -- frame, frames, &hashval); -+ frame, frames, &hashval, NULL); - *next_hash = hashval; - if (ret < 0) { - err = ret; -@@ -1236,10 +1554,10 @@ static int is_dx_internal_node(struct in - * The returned buffer_head has ->b_count elevated. The caller is expected - * to brelse() it when appropriate. - */ --static struct buffer_head * ext4_find_entry (struct inode *dir, -+struct buffer_head *__ext4_find_entry(struct inode *dir, - const struct qstr *d_name, - struct ext4_dir_entry_2 **res_dir, -- int *inlined) -+ int *inlined, struct htree_lock *lck) - { - struct super_block *sb; - struct buffer_head *bh_use[NAMEI_RA_SIZE]; -@@ -1283,7 +1601,7 @@ static struct buffer_head * ext4_find_en - goto restart; - } - if (is_dx(dir)) { -- bh = ext4_dx_find_entry(dir, d_name, res_dir, &err); -+ bh = ext4_dx_find_entry(dir, d_name, res_dir, lck, &err); - /* - * On success, or if the error was file not found, - * return. Otherwise, fall back to doing a search the -@@ -1297,6 +1615,7 @@ static struct buffer_head * ext4_find_en - return bh; - dxtrace(printk(KERN_DEBUG "ext4_find_entry: dx failed, " - "falling back\n")); -+ ext4_htree_safe_relock(lck); - } - nblocks = dir->i_size >> EXT4_BLOCK_SIZE_BITS(sb); - start = EXT4_I(dir)->i_dir_start_lookup; -@@ -1389,9 +1708,12 @@ cleanup_and_exit: - brelse(bh_use[ra_ptr]); - return ret; - } -+EXPORT_SYMBOL(__ext4_find_entry); - --static struct buffer_head * ext4_dx_find_entry(struct inode *dir, const struct qstr *d_name, -- struct ext4_dir_entry_2 **res_dir, int *err) -+static struct buffer_head *ext4_dx_find_entry(struct inode *dir, -+ const struct qstr *d_name, -+ struct ext4_dir_entry_2 **res_dir, -+ struct htree_lock *lck, int *err) - { - struct super_block * sb = dir->i_sb; - struct dx_hash_info hinfo; -@@ -1400,7 +1722,7 @@ static struct buffer_head * ext4_dx_find - ext4_lblk_t block; - int retval; - -- if (!(frame = dx_probe(d_name, dir, &hinfo, frames, err))) -+ if (!(frame = dx_probe(d_name, dir, &hinfo, frames, lck, err))) - return NULL; - do { - block = dx_get_block(frame->at); -@@ -1424,7 +1746,7 @@ static struct buffer_head * ext4_dx_find - - /* Check to see if we should continue to search */ - retval = ext4_htree_next_block(dir, hinfo.hash, frame, -- frames, NULL); -+ frames, NULL, lck); - if (retval < 0) { - ext4_warning(sb, - "error reading index page in directory #%lu", -@@ -1583,8 +1905,9 @@ static struct ext4_dir_entry_2* dx_pack_ - * Returns pointer to de in block into which the new entry will be inserted. - */ - static struct ext4_dir_entry_2 *do_split(handle_t *handle, struct inode *dir, -- struct buffer_head **bh,struct dx_frame *frame, -- struct dx_hash_info *hinfo, int *error) -+ struct buffer_head **bh, struct dx_frame *frames, -+ struct dx_frame *frame, struct dx_hash_info *hinfo, -+ struct htree_lock *lck, int *error) - { - unsigned blocksize = dir->i_sb->s_blocksize; - unsigned count, continued; -@@ -1647,7 +1970,14 @@ static struct ext4_dir_entry_2 *do_split - hash2, split, count-split)); - - /* Fancy dance to stay within two buffers */ -- de2 = dx_move_dirents(data1, data2, map + split, count - split, blocksize); -+ if (hinfo->hash < hash2) { -+ de2 = dx_move_dirents(data1, data2, map + split, -+ count - split, blocksize); -+ } else { -+ /* make sure we will add entry to the same block which -+ * we have already locked */ -+ de2 = dx_move_dirents(data1, data2, map, split, blocksize); -+ } - de = dx_pack_dirents(data1, blocksize); - de->rec_len = ext4_rec_len_to_disk(data1 + (blocksize - csum_size) - - (char *) de, -@@ -1666,13 +1996,21 @@ static struct ext4_dir_entry_2 *do_split - dxtrace(dx_show_leaf (hinfo, (struct ext4_dir_entry_2 *) data1, blocksize, 1)); - dxtrace(dx_show_leaf (hinfo, (struct ext4_dir_entry_2 *) data2, blocksize, 1)); - -- /* Which block gets the new entry? */ -- if (hinfo->hash >= hash2) -- { -- swap(*bh, bh2); -- de = de2; -+ ext4_htree_spin_lock(lck, frame > frames ? (frame - 1)->at : NULL, -+ frame->at); /* notify block is being split */ -+ if (hinfo->hash < hash2) { -+ dx_insert_block(frame, hash2 + continued, newblock); -+ -+ } else { -+ /* switch block number */ -+ dx_insert_block(frame, hash2 + continued, -+ dx_get_block(frame->at)); -+ dx_set_block(frame->at, newblock); -+ (frame->at)++; - } -- dx_insert_block(frame, hash2 + continued, newblock); -+ ext4_htree_spin_unlock(lck); -+ ext4_htree_dx_unlock(lck); -+ - err = ext4_handle_dirty_dirent_node(handle, dir, bh2); - if (err) - goto journal_error; -@@ -1945,7 +2283,7 @@ static int make_indexed_dir(handle_t *ha - ext4_handle_dirty_dx_node(handle, dir, frame->bh); - ext4_handle_dirty_dirent_node(handle, dir, bh); - -- de = do_split(handle,dir, &bh, frame, &hinfo, &retval); -+ de = do_split(handle, dir, &bh, frames, frame, &hinfo, NULL, &retval); - if (!de) { - /* - * Even if the block split failed, we have to properly write -@@ -2051,8 +2389,8 @@ out: - * may not sleep between calling this and putting something into - * the entry, as someone else might have used it while you slept. - */ --static int ext4_add_entry(handle_t *handle, struct dentry *dentry, -- struct inode *inode) -+int __ext4_add_entry(handle_t *handle, struct dentry *dentry, -+ struct inode *inode, struct htree_lock *lck) - { - struct inode *dir = dentry->d_parent->d_inode; - struct buffer_head *bh; -@@ -2087,9 +2425,10 @@ static int ext4_add_entry(handle_t *hand - if (dentry->d_name.len == 2 && - memcmp(dentry->d_name.name, "..", 2) == 0) - return ext4_update_dotdot(handle, dentry, inode); -- retval = ext4_dx_add_entry(handle, dentry, inode); -+ retval = ext4_dx_add_entry(handle, dentry, inode, lck); - if (!retval || (retval != ERR_BAD_DX_DIR)) - return retval; -+ ext4_htree_safe_relock(lck); - ext4_clear_inode_flag(dir, EXT4_INODE_INDEX); - dx_fallback++; - ext4_mark_inode_dirty(handle, dir); -@@ -2129,12 +2468,13 @@ static int ext4_add_entry(handle_t *hand - ext4_set_inode_state(inode, EXT4_STATE_NEWENTRY); - return retval; - } -+EXPORT_SYMBOL(__ext4_add_entry); - - /* - * Returns 0 for success, or a negative error value - */ - static int ext4_dx_add_entry(handle_t *handle, struct dentry *dentry, -- struct inode *inode) -+ struct inode *inode, struct htree_lock *lck) - { - struct dx_frame frames[EXT4_HTREE_LEVEL], *frame; - struct dx_entry *entries, *at; -@@ -2148,7 +2488,7 @@ static int ext4_dx_add_entry(handle_t *h - - again: - restart = 0; -- frame = dx_probe(&dentry->d_name, dir, &hinfo, frames, &err); -+ frame = dx_probe(&dentry->d_name, dir, &hinfo, frames, lck, &err); - if (!frame) - return err; - entries = frame->entries; -@@ -2178,6 +2518,11 @@ again: - struct dx_node *node2; - struct buffer_head *bh2; - -+ if (!ext4_htree_safe_locked(lck)) { /* retry with EX lock */ -+ ext4_htree_safe_relock(lck); -+ restart = 1; -+ goto cleanup; -+ } - while (frame > frames) { - if (dx_get_count((frame - 1)->entries) < - dx_get_limit((frame - 1)->entries)) { -@@ -2277,16 +2622,43 @@ again: - restart = 1; - goto journal_error; - } -+ } else if (!ext4_htree_dx_locked(lck)) { -+ struct ext4_dir_lock_data *ld = ext4_htree_lock_data(lck); -+ -+ /* not well protected, require DX lock */ -+ ext4_htree_dx_need_lock(lck); -+ at = frame > frames ? (frame - 1)->at : NULL; -+ -+ /* NB: no risk of deadlock because it's just a try. -+ * -+ * NB: we check ld_count for twice, the first time before -+ * having DX lock, the second time after holding DX lock. -+ * -+ * NB: We never free blocks for directory so far, which -+ * means value returned by dx_get_count() should equal to -+ * ld->ld_count if nobody split any DE-block under @at, -+ * and ld->ld_at still points to valid dx_entry. */ -+ if ((ld->ld_count != dx_get_count(entries)) || -+ !ext4_htree_dx_lock_try(lck, at) || -+ (ld->ld_count != dx_get_count(entries))) { -+ restart = 1; -+ goto cleanup; -+ } -+ /* OK, I've got DX lock and nothing changed */ -+ frame->at = ld->ld_at; - } -- de = do_split(handle, dir, &bh, frame, &hinfo, &err); -+ de = do_split(handle, dir, &bh, frames, frame, &hinfo, lck, &err); - if (!de) - goto cleanup; -+ - err = add_dirent_to_buf(handle, dentry, inode, de, bh); - goto cleanup; - - journal_error: - ext4_std_error(dir->i_sb, err); /* this is a no-op if err == 0 */ - cleanup: -+ ext4_htree_dx_unlock(lck); -+ ext4_htree_de_unlock(lck); - brelse(bh); - dx_release(frames); - /* @restart is true means htree-path has been changed, we need to -Index: linux-3.10.0-229.1.2.fc21.x86_64/fs/ext4/super.c -=================================================================== ---- linux-3.10.0-229.1.2.fc21.x86_64.orig/fs/ext4/super.c -+++ linux-3.10.0-229.1.2.fc21.x86_64/fs/ext4/super.c -@@ -875,6 +875,7 @@ static struct inode *ext4_alloc_inode(st - - ei->vfs_inode.i_version = 1; - spin_lock_init(&ei->i_raw_lock); -+ sema_init(&ei->i_append_sem, 1); - INIT_LIST_HEAD(&ei->i_prealloc_list); - spin_lock_init(&ei->i_prealloc_lock); - ext4_es_init_tree(&ei->i_es_tree); diff --git a/ldiskfs/kernel_patches/patches/rhel7/ext4-prealloc.patch b/ldiskfs/kernel_patches/patches/rhel7/ext4-prealloc.patch deleted file mode 100644 index 0e9c3ca..0000000 --- a/ldiskfs/kernel_patches/patches/rhel7/ext4-prealloc.patch +++ /dev/null @@ -1,400 +0,0 @@ -Index: linux-3.10.0-514.16.1.el7.x86_64/fs/ext4/ext4.h -=================================================================== ---- linux-3.10.0-514.16.1.el7.x86_64.orig/fs/ext4/ext4.h -+++ linux-3.10.0-514.16.1.el7.x86_64/fs/ext4/ext4.h -@@ -1270,11 +1270,14 @@ struct ext4_sb_info { - - /* tunables */ - unsigned long s_stripe; -- unsigned int s_mb_stream_request; -+ unsigned long s_mb_small_req; -+ unsigned long s_mb_large_req; - unsigned int s_mb_max_to_scan; - unsigned int s_mb_min_to_scan; - unsigned int s_mb_stats; - unsigned int s_mb_order2_reqs; -+ unsigned long *s_mb_prealloc_table; -+ unsigned long s_mb_prealloc_table_size; - unsigned int s_mb_group_prealloc; - unsigned int s_max_dir_size_kb; - /* where last allocation was done - for stream allocation */ -Index: linux-3.10.0-514.16.1.el7.x86_64/fs/ext4/mballoc.c -=================================================================== ---- linux-3.10.0-514.16.1.el7.x86_64.orig/fs/ext4/mballoc.c -+++ linux-3.10.0-514.16.1.el7.x86_64/fs/ext4/mballoc.c -@@ -1862,6 +1862,26 @@ int ext4_mb_find_by_goal(struct ext4_all - return 0; - } - -+static int ext4_mb_prealloc_table_add(struct ext4_sb_info *sbi, int value) -+{ -+ int i; -+ -+ if (value > (sbi->s_blocks_per_group - 1 - 1 - sbi->s_itb_per_group)) -+ return -1; -+ -+ for (i = 0; i < sbi->s_mb_prealloc_table_size; i++) { -+ if (sbi->s_mb_prealloc_table[i] == 0) { -+ sbi->s_mb_prealloc_table[i] = value; -+ return 0; -+ } -+ -+ /* they should add values in order */ -+ if (value <= sbi->s_mb_prealloc_table[i]) -+ return -1; -+ } -+ return -1; -+} -+ - /* - * The routine scans buddy structures (not bitmap!) from given order - * to max order and tries to find big enough chunk to satisfy the req -@@ -2301,6 +2321,90 @@ static const struct seq_operations ext4_ - .show = ext4_mb_seq_groups_show, - }; - -+#define EXT4_MB_PREALLOC_TABLE "prealloc_table" -+ -+static ssize_t ext4_mb_prealloc_table_proc_write(struct file *file, -+ const char __user *buf, -+ size_t cnt, loff_t *pos) -+{ -+ struct ext4_sb_info *sbi = EXT4_SB(PDE_DATA(file_inode(file))); -+ unsigned long value; -+ unsigned long prev = 0; -+ char str[128]; -+ char *cur; -+ char *end; -+ unsigned long *new_table; -+ int num = 0; -+ int i = 0; -+ -+ if (cnt >= sizeof(str)) -+ return -EINVAL; -+ if (copy_from_user(str, buf, cnt)) -+ return -EFAULT; -+ -+ num = 0; -+ cur = str; -+ end = str + cnt; -+ while (cur < end) { -+ while ((cur < end) && (*cur == ' ')) -+ cur++; -+ value = simple_strtol(cur, &cur, 0); -+ if (value == 0) -+ break; -+ if (value <= prev) -+ return -EINVAL; -+ prev = value; -+ num++; -+ } -+ -+ new_table = kmalloc(num * sizeof(*new_table), GFP_KERNEL); -+ if (new_table == NULL) -+ return -ENOMEM; -+ kfree(sbi->s_mb_prealloc_table); -+ memset(new_table, 0, num * sizeof(*new_table)); -+ sbi->s_mb_prealloc_table = new_table; -+ sbi->s_mb_prealloc_table_size = num; -+ cur = str; -+ end = str + cnt; -+ while (cur < end && i < num) { -+ while (cur < end && *cur == ' ') -+ cur++; -+ value = simple_strtol(cur, &cur, 0); -+ if (ext4_mb_prealloc_table_add(sbi, value) == 0) -+ ++i; -+ } -+ if (i != num) -+ sbi->s_mb_prealloc_table_size = i; -+ -+ return cnt; -+} -+ -+static int mb_prealloc_table_seq_show(struct seq_file *m, void *v) -+{ -+ struct ext4_sb_info *sbi = EXT4_SB(m->private); -+ int i; -+ -+ for (i = 0; i < sbi->s_mb_prealloc_table_size; i++) -+ seq_printf(m, "%ld ", sbi->s_mb_prealloc_table[i]); -+ seq_printf(m, "\n"); -+ -+ return 0; -+} -+ -+static int mb_prealloc_table_seq_open(struct inode *inode, struct file *file) -+{ -+ return single_open(file, mb_prealloc_table_seq_show, PDE_DATA(inode)); -+} -+ -+static const struct file_operations ext4_mb_prealloc_seq_fops = { -+ .owner = THIS_MODULE, -+ .open = mb_prealloc_table_seq_open, -+ .read = seq_read, -+ .llseek = seq_lseek, -+ .release = single_release, -+ .write = ext4_mb_prealloc_table_proc_write, -+}; -+ - static int ext4_mb_seq_groups_open(struct inode *inode, struct file *file) - { - struct super_block *sb = PDE_DATA(inode); -@@ -2550,7 +2657,7 @@ static int ext4_groupinfo_create_slab(si - int ext4_mb_init(struct super_block *sb) - { - struct ext4_sb_info *sbi = EXT4_SB(sb); -- unsigned i, j; -+ unsigned i, j, k, l; - unsigned offset; - unsigned max; - int ret; -@@ -2595,7 +2702,6 @@ int ext4_mb_init(struct super_block *sb) - sbi->s_mb_max_to_scan = MB_DEFAULT_MAX_TO_SCAN; - sbi->s_mb_min_to_scan = MB_DEFAULT_MIN_TO_SCAN; - sbi->s_mb_stats = MB_DEFAULT_STATS; -- sbi->s_mb_stream_request = MB_DEFAULT_STREAM_THRESHOLD; - sbi->s_mb_order2_reqs = MB_DEFAULT_ORDER2_REQS; - /* - * The default group preallocation is 512, which for 4k block -@@ -2619,9 +2725,47 @@ int ext4_mb_init(struct super_block *sb) - * RAID stripe size so that preallocations don't fragment - * the stripes. - */ -- if (sbi->s_stripe > 1) { -- sbi->s_mb_group_prealloc = roundup( -- sbi->s_mb_group_prealloc, sbi->s_stripe); -+ -+ if (sbi->s_stripe == 0) { -+ sbi->s_mb_prealloc_table_size = 10; -+ i = sbi->s_mb_prealloc_table_size * sizeof(unsigned long); -+ sbi->s_mb_prealloc_table = kmalloc(i, GFP_NOFS); -+ if (sbi->s_mb_prealloc_table == NULL) { -+ ret = -ENOMEM; -+ goto out; -+ } -+ memset(sbi->s_mb_prealloc_table, 0, i); -+ -+ for (k = 0, l = 4; k <= 9; ++k, l *= 2) { -+ if (ext4_mb_prealloc_table_add(sbi, l) < 0) { -+ sbi->s_mb_prealloc_table_size = k; -+ break; -+ } -+ } -+ -+ sbi->s_mb_small_req = 256; -+ sbi->s_mb_large_req = 1024; -+ sbi->s_mb_group_prealloc = 512; -+ } else { -+ sbi->s_mb_prealloc_table_size = 3; -+ i = sbi->s_mb_prealloc_table_size * sizeof(unsigned long); -+ sbi->s_mb_prealloc_table = kmalloc(i, GFP_NOFS); -+ if (sbi->s_mb_prealloc_table == NULL) { -+ ret = -ENOMEM; -+ goto out; -+ } -+ memset(sbi->s_mb_prealloc_table, 0, i); -+ -+ for (k = 0, l = sbi->s_stripe; k <= 2; ++k, l *= 2) { -+ if (ext4_mb_prealloc_table_add(sbi, l) < 0) { -+ sbi->s_mb_prealloc_table_size = k; -+ break; -+ } -+ } -+ -+ sbi->s_mb_small_req = sbi->s_stripe; -+ sbi->s_mb_large_req = sbi->s_stripe * 8; -+ sbi->s_mb_group_prealloc = sbi->s_stripe * 4; - } - - sbi->s_locality_groups = alloc_percpu(struct ext4_locality_group); -@@ -2643,9 +2787,13 @@ int ext4_mb_init(struct super_block *sb) - if (ret != 0) - goto out_free_locality_groups; - -- if (sbi->s_proc) -+ if (sbi->s_proc) { - proc_create_data("mb_groups", S_IRUGO, sbi->s_proc, - &ext4_mb_seq_groups_fops, sb); -+ proc_create_data(EXT4_MB_PREALLOC_TABLE, S_IFREG | S_IRUGO | -+ S_IWUSR, sbi->s_proc, -+ &ext4_mb_prealloc_seq_fops, sb); -+ } - - return 0; - -@@ -2653,6 +2801,7 @@ out_free_locality_groups: - free_percpu(sbi->s_locality_groups); - sbi->s_locality_groups = NULL; - out: -+ kfree(sbi->s_mb_prealloc_table); - kfree(sbi->s_mb_offsets); - sbi->s_mb_offsets = NULL; - kfree(sbi->s_mb_maxs); -@@ -2687,8 +2836,10 @@ int ext4_mb_release(struct super_block * - struct ext4_sb_info *sbi = EXT4_SB(sb); - struct kmem_cache *cachep = get_groupinfo_cache(sb->s_blocksize_bits); - -- if (sbi->s_proc) -+ if (sbi->s_proc) { - remove_proc_entry("mb_groups", sbi->s_proc); -+ remove_proc_entry(EXT4_MB_PREALLOC_TABLE, sbi->s_proc); -+ } - - if (sbi->s_group_info) { - for (i = 0; i < ngroups; i++) { -@@ -3000,9 +3151,9 @@ ext4_mb_normalize_request(struct ext4_al - struct ext4_allocation_request *ar) - { - struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb); -- int bsbits, max; -+ int bsbits, i, wind; - ext4_lblk_t end; -- loff_t size, start_off; -+ loff_t size; - loff_t orig_size __maybe_unused; - ext4_lblk_t start; - struct ext4_inode_info *ei = EXT4_I(ac->ac_inode); -@@ -3035,51 +3186,34 @@ ext4_mb_normalize_request(struct ext4_al - size = size << bsbits; - if (size < i_size_read(ac->ac_inode)) - size = i_size_read(ac->ac_inode); -- orig_size = size; -+ size = (size + ac->ac_sb->s_blocksize - 1) >> bsbits; - -- /* max size of free chunks */ -- max = 2 << bsbits; -+ start = wind = 0; - --#define NRL_CHECK_SIZE(req, size, max, chunk_size) \ -- (req <= (size) || max <= (chunk_size)) -+ /* let's choose preallocation window depending on file size */ -+ for (i = 0; i < sbi->s_mb_prealloc_table_size; i++) { -+ if (size <= sbi->s_mb_prealloc_table[i]) { -+ wind = sbi->s_mb_prealloc_table[i]; -+ break; -+ } -+ } -+ size = wind; - -- /* first, try to predict filesize */ -- /* XXX: should this table be tunable? */ -- start_off = 0; -- if (size <= 16 * 1024) { -- size = 16 * 1024; -- } else if (size <= 32 * 1024) { -- size = 32 * 1024; -- } else if (size <= 64 * 1024) { -- size = 64 * 1024; -- } else if (size <= 128 * 1024) { -- size = 128 * 1024; -- } else if (size <= 256 * 1024) { -- size = 256 * 1024; -- } else if (size <= 512 * 1024) { -- size = 512 * 1024; -- } else if (size <= 1024 * 1024) { -- size = 1024 * 1024; -- } else if (NRL_CHECK_SIZE(size, 4 * 1024 * 1024, max, 2 * 1024)) { -- start_off = ((loff_t)ac->ac_o_ex.fe_logical >> -- (21 - bsbits)) << 21; -- size = 2 * 1024 * 1024; -- } else if (NRL_CHECK_SIZE(size, 8 * 1024 * 1024, max, 4 * 1024)) { -- start_off = ((loff_t)ac->ac_o_ex.fe_logical >> -- (22 - bsbits)) << 22; -- size = 4 * 1024 * 1024; -- } else if (NRL_CHECK_SIZE(ac->ac_o_ex.fe_len, -- (8<<20)>>bsbits, max, 8 * 1024)) { -- start_off = ((loff_t)ac->ac_o_ex.fe_logical >> -- (23 - bsbits)) << 23; -- size = 8 * 1024 * 1024; -- } else { -- start_off = (loff_t) ac->ac_o_ex.fe_logical << bsbits; -- size = (loff_t) EXT4_C2B(EXT4_SB(ac->ac_sb), -- ac->ac_o_ex.fe_len) << bsbits; -+ if (wind == 0) { -+ __u64 tstart, tend; -+ /* file is quite large, we now preallocate with -+ * the biggest configured window with regart to -+ * logical offset */ -+ wind = sbi->s_mb_prealloc_table[i - 1]; -+ tstart = ac->ac_o_ex.fe_logical; -+ do_div(tstart, wind); -+ start = tstart * wind; -+ tend = ac->ac_o_ex.fe_logical + ac->ac_o_ex.fe_len - 1; -+ do_div(tend, wind); -+ tend = tend * wind + wind; -+ size = tend - start; - } -- size = size >> bsbits; -- start = start_off >> bsbits; -+ orig_size = size; - - /* don't cover already allocated blocks in selected range */ - if (ar->pleft && start <= ar->lleft) { -@@ -3154,7 +3288,6 @@ ext4_mb_normalize_request(struct ext4_al - (unsigned long) ac->ac_o_ex.fe_logical); - BUG(); - } -- BUG_ON(size <= 0 || size > EXT4_BLOCKS_PER_GROUP(ac->ac_sb)); - - /* now prepare goal request */ - -@@ -4119,11 +4252,19 @@ static void ext4_mb_group_or_file(struct - - /* don't use group allocation for large files */ - size = max(size, isize); -- if (size > sbi->s_mb_stream_request) { -+ if ((ac->ac_o_ex.fe_len >= sbi->s_mb_small_req) || -+ (size >= sbi->s_mb_large_req)) { - ac->ac_flags |= EXT4_MB_STREAM_ALLOC; - return; - } - -+ /* -+ * request is so large that we don't care about -+ * streaming - it overweights any possible seek -+ */ -+ if (ac->ac_o_ex.fe_len >= sbi->s_mb_large_req) -+ return; -+ - BUG_ON(ac->ac_lg != NULL); - /* - * locality group prealloc space are per cpu. The reason for having -Index: linux-3.10.0-514.16.1.el7.x86_64/fs/ext4/super.c -=================================================================== ---- linux-3.10.0-514.16.1.el7.x86_64.orig/fs/ext4/super.c -+++ linux-3.10.0-514.16.1.el7.x86_64/fs/ext4/super.c -@@ -2672,7 +2672,8 @@ EXT4_RW_ATTR_SBI_UI(mb_stats, s_mb_stats - EXT4_RW_ATTR_SBI_UI(mb_max_to_scan, s_mb_max_to_scan); - EXT4_RW_ATTR_SBI_UI(mb_min_to_scan, s_mb_min_to_scan); - EXT4_RW_ATTR_SBI_UI(mb_order2_req, s_mb_order2_reqs); --EXT4_RW_ATTR_SBI_UI(mb_stream_req, s_mb_stream_request); -+EXT4_RW_ATTR_SBI_UI(mb_small_req, s_mb_small_req); -+EXT4_RW_ATTR_SBI_UI(mb_large_req, s_mb_large_req); - EXT4_RW_ATTR_SBI_UI(mb_group_prealloc, s_mb_group_prealloc); - EXT4_DEPRECATED_ATTR(max_writeback_mb_bump, 128); - EXT4_RW_ATTR_SBI_UI(extent_max_zeroout_kb, s_extent_max_zeroout_kb); -@@ -2698,7 +2699,8 @@ static struct attribute *ext4_attrs[] = - ATTR_LIST(mb_max_to_scan), - ATTR_LIST(mb_min_to_scan), - ATTR_LIST(mb_order2_req), -- ATTR_LIST(mb_stream_req), -+ ATTR_LIST(mb_small_req), -+ ATTR_LIST(mb_large_req), - ATTR_LIST(mb_group_prealloc), - ATTR_LIST(max_writeback_mb_bump), - ATTR_LIST(extent_max_zeroout_kb), -Index: linux-3.10.0-514.16.1.el7.x86_64/fs/ext4/inode.c -=================================================================== ---- linux-3.10.0-514.16.1.el7.x86_64.orig/fs/ext4/inode.c -+++ linux-3.10.0-514.16.1.el7.x86_64/fs/ext4/inode.c -@@ -2399,6 +2399,9 @@ static int ext4_writepages(struct addres - ext4_journal_stop(handle); - } - -+ if (wbc->nr_to_write < sbi->s_mb_small_req) -+ wbc->nr_to_write = sbi->s_mb_small_req; -+ - if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX) - range_whole = 1; - diff --git a/ldiskfs/kernel_patches/patches/rhel7/ext4-projid-xfs-ioctls.patch b/ldiskfs/kernel_patches/patches/rhel7/ext4-projid-xfs-ioctls.patch deleted file mode 100644 index 0af277b..0000000 --- a/ldiskfs/kernel_patches/patches/rhel7/ext4-projid-xfs-ioctls.patch +++ /dev/null @@ -1,485 +0,0 @@ -diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h -index ce3b85f..29db502 100644 ---- a/fs/ext4/ext4.h -+++ b/fs/ext4/ext4.h -@@ -395,6 +395,13 @@ struct flex_groups { - #define EXT4_FL_USER_VISIBLE 0x304BDFFF /* User visible flags */ - #define EXT4_FL_USER_MODIFIABLE 0x204380FF /* User modifiable flags */ - -+#define EXT4_FL_XFLAG_VISIBLE (EXT4_SYNC_FL | \ -+ EXT4_IMMUTABLE_FL | \ -+ EXT4_APPEND_FL | \ -+ EXT4_NODUMP_FL | \ -+ EXT4_NOATIME_FL | \ -+ EXT4_PROJINHERIT_FL) -+ - /* Flags that should be inherited by new inodes from their parent. */ - #define EXT4_FL_INHERITED (EXT4_SECRM_FL | EXT4_UNRM_FL | EXT4_COMPR_FL |\ - EXT4_SYNC_FL | EXT4_NODUMP_FL | EXT4_NOATIME_FL |\ -@@ -620,6 +627,44 @@ enum { - #define EXT4_IOC_SWAP_BOOT _IO('f', 17) - #define EXT4_IOC_PRECACHE_EXTENTS _IO('f', 18) - -+#ifndef FS_IOC_FSGETXATTR -+/* Until the uapi changes get merged for project quota... */ -+#define FS_IOC_FSGETXATTR _IOR('X', 31, struct fsxattr) -+#define FS_IOC_FSSETXATTR _IOW('X', 32, struct fsxattr) -+/* -+ * Structure for FS_IOC_FSGETXATTR and FS_IOC_FSSETXATTR. -+ */ -+struct fsxattr { -+ __u32 fsx_xflags; /* xflags field value (get/set) */ -+ __u32 fsx_extsize; /* extsize field value (get/set)*/ -+ __u32 fsx_nextents; /* nextents field value (get) */ -+ __u32 fsx_projid; /* project identifier (get/set) */ -+ unsigned char fsx_pad[12]; -+}; -+ -+/* -+ * Flags for the fsx_xflags field -+ */ -+#define FS_XFLAG_REALTIME 0x00000001 /* data in realtime volume */ -+#define FS_XFLAG_PREALLOC 0x00000002 /* preallocated file extents */ -+#define FS_XFLAG_IMMUTABLE 0x00000008 /* file cannot be modified */ -+#define FS_XFLAG_APPEND 0x00000010 /* all writes append */ -+#define FS_XFLAG_SYNC 0x00000020 /* all writes synchronous */ -+#define FS_XFLAG_NOATIME 0x00000040 /* do not update access time */ -+#define FS_XFLAG_NODUMP 0x00000080 /* do not include in backups */ -+#define FS_XFLAG_RTINHERIT 0x00000100 /* create with rt bit set */ -+#define FS_XFLAG_PROJINHERIT 0x00000200 /* create with parents projid */ -+#define FS_XFLAG_NOSYMLINKS 0x00000400 /* disallow symlink creation */ -+#define FS_XFLAG_EXTSIZE 0x00000800 /* extent size allocator hint */ -+#define FS_XFLAG_EXTSZINHERIT 0x00001000 /* inherit inode extent size */ -+#define FS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */ -+#define FS_XFLAG_FILESTREAM 0x00004000 /* use filestream allocator */ -+#define FS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */ -+#endif /* !defined(FS_IOC_FSGETXATTR) */ -+ -+#define EXT4_IOC_FSGETXATTR FS_IOC_FSGETXATTR -+#define EXT4_IOC_FSSETXATTR FS_IOC_FSSETXATTR -+ - #if defined(__KERNEL__) && defined(CONFIG_COMPAT) - /* - * ioctl commands in 32 bit emulation -diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c -index 70c66d3..276d33d 100644 ---- a/fs/ext4/ioctl.c -+++ b/fs/ext4/ioctl.c -@@ -15,6 +15,7 @@ - #include - #include - #include -+#include - #include "ext4_jbd2.h" - #include "ext4.h" - -@@ -198,6 +199,242 @@ journal_err_out: - return err; - } - -+static int ext4_ioctl_setflags(struct inode *inode, -+ unsigned int flags) -+{ -+ struct ext4_inode_info *ei = EXT4_I(inode); -+ handle_t *handle = NULL; -+ int err = EPERM, migrate = 0; -+ struct ext4_iloc iloc; -+ unsigned int oldflags, mask, i; -+ unsigned int jflag; -+ -+ /* Is it quota file? Do not allow user to mess with it */ -+ if (IS_NOQUOTA(inode)) -+ goto flags_out; -+ -+ oldflags = ei->i_flags; -+ -+ /* The JOURNAL_DATA flag is modifiable only by root */ -+ jflag = flags & EXT4_JOURNAL_DATA_FL; -+ -+ /* -+ * The IMMUTABLE and APPEND_ONLY flags can only be changed by -+ * the relevant capability. -+ * -+ * This test looks nicer. Thanks to Pauline Middelink -+ */ -+ if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) { -+ if (!capable(CAP_LINUX_IMMUTABLE)) -+ goto flags_out; -+ } -+ -+ /* -+ * The JOURNAL_DATA flag can only be changed by -+ * the relevant capability. -+ */ -+ if ((jflag ^ oldflags) & (EXT4_JOURNAL_DATA_FL)) { -+ if (!capable(CAP_SYS_RESOURCE)) -+ goto flags_out; -+ } -+ if ((flags ^ oldflags) & EXT4_EXTENTS_FL) -+ migrate = 1; -+ -+ if (flags & EXT4_EOFBLOCKS_FL) { -+ /* we don't support adding EOFBLOCKS flag */ -+ if (!(oldflags & EXT4_EOFBLOCKS_FL)) { -+ err = -EOPNOTSUPP; -+ goto flags_out; -+ } -+ } else if (oldflags & EXT4_EOFBLOCKS_FL) -+ ext4_truncate(inode); -+ -+ handle = ext4_journal_start(inode, EXT4_HT_INODE, 1); -+ if (IS_ERR(handle)) { -+ err = PTR_ERR(handle); -+ goto flags_out; -+ } -+ if (IS_SYNC(inode)) -+ ext4_handle_sync(handle); -+ err = ext4_reserve_inode_write(handle, inode, &iloc); -+ if (err) -+ goto flags_err; -+ -+ for (i = 0, mask = 1; i < 32; i++, mask <<= 1) { -+ if (!(mask & EXT4_FL_USER_MODIFIABLE)) -+ continue; -+ if (mask & flags) -+ ext4_set_inode_flag(inode, i); -+ else -+ ext4_clear_inode_flag(inode, i); -+ } -+ -+ ext4_set_inode_flags(inode); -+ inode->i_ctime = ext4_current_time(inode); -+ -+ err = ext4_mark_iloc_dirty(handle, inode, &iloc); -+flags_err: -+ ext4_journal_stop(handle); -+ if (err) -+ goto flags_out; -+ -+ if ((jflag ^ oldflags) & (EXT4_JOURNAL_DATA_FL)) -+ err = ext4_change_inode_journal_flag(inode, jflag); -+ if (err) -+ goto flags_out; -+ if (migrate) { -+ if (flags & EXT4_EXTENTS_FL) -+ err = ext4_ext_migrate(inode); -+ else -+ err = ext4_ind_migrate(inode); -+ } -+ -+flags_out: -+ return err; -+} -+ -+#ifdef CONFIG_QUOTA -+static int ext4_ioctl_setproject(struct file *filp, __u32 projid) -+{ -+ struct inode *inode = file_inode(filp); -+ struct super_block *sb = inode->i_sb; -+ struct ext4_inode_info *ei = EXT4_I(inode); -+ int err, rc; -+ handle_t *handle; -+ kprojid_t kprojid; -+ struct ext4_iloc iloc; -+ struct ext4_inode *raw_inode; -+ struct dquot *transfer_to[EXT4_MAXQUOTAS] = { }; -+ -+ if (!EXT4_HAS_RO_COMPAT_FEATURE(sb, -+ EXT4_FEATURE_RO_COMPAT_PROJECT)) { -+ BUG_ON(__kprojid_val(EXT4_I(inode)->i_projid) -+ != EXT4_DEF_PROJID); -+ if (projid != EXT4_DEF_PROJID) -+ return -EOPNOTSUPP; -+ else -+ return 0; -+ } -+ -+ if (EXT4_INODE_SIZE(sb) <= EXT4_GOOD_OLD_INODE_SIZE) -+ return -EOPNOTSUPP; -+ -+ kprojid = make_kprojid(&init_user_ns, (projid_t)projid); -+ -+ if (projid_eq(kprojid, EXT4_I(inode)->i_projid)) -+ return 0; -+ -+ err = mnt_want_write_file(filp); -+ if (err) -+ return err; -+ -+ err = -EPERM; -+ mutex_lock(&inode->i_mutex); -+ /* Is it quota file? Do not allow user to mess with it */ -+ if (IS_NOQUOTA(inode)) -+ goto out_unlock; -+ -+ err = ext4_get_inode_loc(inode, &iloc); -+ if (err) -+ goto out_unlock; -+ -+ raw_inode = ext4_raw_inode(&iloc); -+ if (!EXT4_FITS_IN_INODE(raw_inode, ei, i_projid)) { -+ err = -EOVERFLOW; -+ brelse(iloc.bh); -+ goto out_unlock; -+ } -+ brelse(iloc.bh); -+ -+ dquot_initialize(inode); -+ -+ handle = ext4_journal_start(inode, EXT4_HT_QUOTA, -+ EXT4_QUOTA_INIT_BLOCKS(sb) + -+ EXT4_QUOTA_DEL_BLOCKS(sb) + 3); -+ if (IS_ERR(handle)) { -+ err = PTR_ERR(handle); -+ goto out_unlock; -+ } -+ -+ err = ext4_reserve_inode_write(handle, inode, &iloc); -+ if (err) -+ goto out_stop; -+ -+ transfer_to[PRJQUOTA] = dqget(sb, make_kqid_projid(kprojid)); -+ if (transfer_to[PRJQUOTA]) { -+ err = __dquot_transfer(inode, transfer_to); -+ dqput(transfer_to[PRJQUOTA]); -+ if (err) -+ goto out_dirty; -+ } -+ -+ EXT4_I(inode)->i_projid = kprojid; -+ inode->i_ctime = ext4_current_time(inode); -+out_dirty: -+ rc = ext4_mark_iloc_dirty(handle, inode, &iloc); -+ if (!err) -+ err = rc; -+out_stop: -+ ext4_journal_stop(handle); -+out_unlock: -+ mutex_unlock(&inode->i_mutex); -+ mnt_drop_write_file(filp); -+ return err; -+ -+ -+} -+ -+#else -+static int ext4_ioctl_setproject(struct file *filp, __u32 projid) -+{ -+ if (projid != EXT4_DEF_PROJID) -+ return -EOPNOTSUPP; -+ return 0; -+} -+#endif -+ -+ -+/* Transfer internal flags to xflags */ -+static inline __u32 ext4_iflags_to_xflags(unsigned long iflags) -+{ -+ __u32 xflags = 0; -+ -+ if (iflags & EXT4_SYNC_FL) -+ xflags |= FS_XFLAG_SYNC; -+ if (iflags & EXT4_IMMUTABLE_FL) -+ xflags |= FS_XFLAG_IMMUTABLE; -+ if (iflags & EXT4_APPEND_FL) -+ xflags |= FS_XFLAG_APPEND; -+ if (iflags & EXT4_NODUMP_FL) -+ xflags |= FS_XFLAG_NODUMP; -+ if (iflags & EXT4_NOATIME_FL) -+ xflags |= FS_XFLAG_NOATIME; -+ if (iflags & EXT4_PROJINHERIT_FL) -+ xflags |= FS_XFLAG_PROJINHERIT; -+ return xflags; -+} -+ -+/* Transfer xflags flags to internal */ -+static inline unsigned long ext4_xflags_to_iflags(__u32 xflags) -+{ -+ unsigned long iflags = 0; -+ -+ if (xflags & FS_XFLAG_SYNC) -+ iflags |= EXT4_SYNC_FL; -+ if (xflags & FS_XFLAG_IMMUTABLE) -+ iflags |= EXT4_IMMUTABLE_FL; -+ if (xflags & FS_XFLAG_APPEND) -+ iflags |= EXT4_APPEND_FL; -+ if (xflags & FS_XFLAG_NODUMP) -+ iflags |= EXT4_NODUMP_FL; -+ if (xflags & FS_XFLAG_NOATIME) -+ iflags |= EXT4_NOATIME_FL; -+ if (xflags & FS_XFLAG_PROJINHERIT) -+ iflags |= EXT4_PROJINHERIT_FL; -+ -+ return iflags; -+} -+ - long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) - { - struct inode *inode = file_inode(filp); -@@ -213,11 +502,7 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) - flags = ei->i_flags & EXT4_FL_USER_VISIBLE; - return put_user(flags, (int __user *) arg); - case EXT4_IOC_SETFLAGS: { -- handle_t *handle = NULL; -- int err, migrate = 0; -- struct ext4_iloc iloc; -- unsigned int oldflags, mask, i; -- unsigned int jflag; -+ int err; - - if (!inode_owner_or_capable(inode)) - return -EACCES; -@@ -231,89 +516,8 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) - - flags = ext4_mask_flags(inode->i_mode, flags); - -- err = -EPERM; - mutex_lock(&inode->i_mutex); -- /* Is it quota file? Do not allow user to mess with it */ -- if (IS_NOQUOTA(inode)) -- goto flags_out; -- -- oldflags = ei->i_flags; -- -- /* The JOURNAL_DATA flag is modifiable only by root */ -- jflag = flags & EXT4_JOURNAL_DATA_FL; -- -- /* -- * The IMMUTABLE and APPEND_ONLY flags can only be changed by -- * the relevant capability. -- * -- * This test looks nicer. Thanks to Pauline Middelink -- */ -- if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) { -- if (!capable(CAP_LINUX_IMMUTABLE)) -- goto flags_out; -- } -- -- /* -- * The JOURNAL_DATA flag can only be changed by -- * the relevant capability. -- */ -- if ((jflag ^ oldflags) & (EXT4_JOURNAL_DATA_FL)) { -- if (!capable(CAP_SYS_RESOURCE)) -- goto flags_out; -- } -- if ((flags ^ oldflags) & EXT4_EXTENTS_FL) -- migrate = 1; -- -- if (flags & EXT4_EOFBLOCKS_FL) { -- /* we don't support adding EOFBLOCKS flag */ -- if (!(oldflags & EXT4_EOFBLOCKS_FL)) { -- err = -EOPNOTSUPP; -- goto flags_out; -- } -- } else if (oldflags & EXT4_EOFBLOCKS_FL) -- ext4_truncate(inode); -- -- handle = ext4_journal_start(inode, EXT4_HT_INODE, 1); -- if (IS_ERR(handle)) { -- err = PTR_ERR(handle); -- goto flags_out; -- } -- if (IS_SYNC(inode)) -- ext4_handle_sync(handle); -- err = ext4_reserve_inode_write(handle, inode, &iloc); -- if (err) -- goto flags_err; -- -- for (i = 0, mask = 1; i < 32; i++, mask <<= 1) { -- if (!(mask & EXT4_FL_USER_MODIFIABLE)) -- continue; -- if (mask & flags) -- ext4_set_inode_flag(inode, i); -- else -- ext4_clear_inode_flag(inode, i); -- } -- -- ext4_set_inode_flags(inode); -- inode->i_ctime = ext4_current_time(inode); -- -- err = ext4_mark_iloc_dirty(handle, inode, &iloc); --flags_err: -- ext4_journal_stop(handle); -- if (err) -- goto flags_out; -- -- if ((jflag ^ oldflags) & (EXT4_JOURNAL_DATA_FL)) -- err = ext4_change_inode_journal_flag(inode, jflag); -- if (err) -- goto flags_out; -- if (migrate) { -- if (flags & EXT4_EXTENTS_FL) -- err = ext4_ext_migrate(inode); -- else -- err = ext4_ind_migrate(inode); -- } -- --flags_out: -+ err = ext4_ioctl_setflags(inode, flags); - mutex_unlock(&inode->i_mutex); - mnt_drop_write_file(filp); - return err; -@@ -622,6 +826,62 @@ resizefs_out: - } - case EXT4_IOC_PRECACHE_EXTENTS: - return ext4_ext_precache(inode); -+ case EXT4_IOC_FSGETXATTR: -+ { -+ struct fsxattr fa; -+ unsigned int flags; -+ -+ memset(&fa, 0, sizeof(struct fsxattr)); -+ ext4_get_inode_flags(ei); -+ flags = ei->i_flags & EXT4_FL_USER_VISIBLE; -+ fa.fsx_xflags = ext4_iflags_to_xflags(flags); -+ -+ if (EXT4_HAS_RO_COMPAT_FEATURE(inode->i_sb, -+ EXT4_FEATURE_RO_COMPAT_PROJECT)) { -+ fa.fsx_projid = (__u32)from_kprojid(&init_user_ns, -+ EXT4_I(inode)->i_projid); -+ } -+ -+ if (copy_to_user((struct fsxattr __user *)arg, -+ &fa, sizeof(fa))) -+ return -EFAULT; -+ return 0; -+ } -+ case EXT4_IOC_FSSETXATTR: -+ { -+ struct fsxattr fa; -+ int err; -+ -+ if (copy_from_user(&fa, (struct fsxattr __user *)arg, -+ sizeof(fa))) -+ return -EFAULT; -+ -+ /* Make sure caller has proper permission */ -+ if (!inode_owner_or_capable(inode)) -+ return -EACCES; -+ -+ err = mnt_want_write_file(filp); -+ if (err) -+ return err; -+ -+ flags = ext4_xflags_to_iflags(fa.fsx_xflags); -+ flags = ext4_mask_flags(inode->i_mode, flags); -+ -+ mutex_lock(&inode->i_mutex); -+ flags = (ei->i_flags & ~EXT4_FL_XFLAG_VISIBLE) | -+ (flags & EXT4_FL_XFLAG_VISIBLE); -+ err = ext4_ioctl_setflags(inode, flags); -+ mutex_unlock(&inode->i_mutex); -+ mnt_drop_write_file(filp); -+ if (err) -+ return err; -+ -+ err = ext4_ioctl_setproject(filp, fa.fsx_projid); -+ if (err) -+ return err; -+ -+ return 0; -+ } - - default: - return -ENOTTY; diff --git a/ldiskfs/kernel_patches/patches/rhel7/ext4-remove-i_data_sem-from-xattr.patch b/ldiskfs/kernel_patches/patches/rhel7/ext4-remove-i_data_sem-from-xattr.patch deleted file mode 100644 index 5f46cb9..0000000 --- a/ldiskfs/kernel_patches/patches/rhel7/ext4-remove-i_data_sem-from-xattr.patch +++ /dev/null @@ -1,475 +0,0 @@ -From a521100231f816f8cdd9c8e77da14ff1e42c2b17 Mon Sep 17 00:00:00 2001 -From: Theodore Ts'o -Date: Thu, 4 Sep 2014 18:06:25 -0400 -Subject: [PATCH] ext4: pass allocation_request struct to - ext4_(alloc,splice)_branch - -Instead of initializing the allocation_request structure in -ext4_alloc_branch(), set it up in ext4_ind_map_blocks(), and then pass -it to ext4_alloc_branch() and ext4_splice_branch(). - -This allows ext4_ind_map_blocks to pass flags in the allocation -request structure without having to add Yet Another argument to -ext4_alloc_branch(). - -Signed-off-by: Theodore Ts'o -Reviewed-by: Jan Kara ---- - fs/ext4/indirect.c | 82 +++++++++++++++++++++++++----------------------------- - 1 file changed, 38 insertions(+), 44 deletions(-) - -diff --git a/fs/ext4/indirect.c b/fs/ext4/indirect.c -index e75f840..69af0cd 100644 ---- a/fs/ext4/indirect.c -+++ b/fs/ext4/indirect.c -@@ -318,34 +318,22 @@ static int ext4_blks_to_allocate(Indirect *branch, int k, unsigned int blks, - * ext4_alloc_block() (normally -ENOSPC). Otherwise we set the chain - * as described above and return 0. - */ --static int ext4_alloc_branch(handle_t *handle, struct inode *inode, -- ext4_lblk_t iblock, int indirect_blks, -- int *blks, ext4_fsblk_t goal, -- ext4_lblk_t *offsets, Indirect *branch) -+static int ext4_alloc_branch(handle_t *handle, -+ struct ext4_allocation_request *ar, -+ int indirect_blks, ext4_lblk_t *offsets, -+ Indirect *branch) - { -- struct ext4_allocation_request ar; - struct buffer_head * bh; - ext4_fsblk_t b, new_blocks[4]; - __le32 *p; - int i, j, err, len = 1; - -- /* -- * Set up for the direct block allocation -- */ -- memset(&ar, 0, sizeof(ar)); -- ar.inode = inode; -- ar.len = *blks; -- ar.logical = iblock; -- if (S_ISREG(inode->i_mode)) -- ar.flags = EXT4_MB_HINT_DATA; -- - for (i = 0; i <= indirect_blks; i++) { - if (i == indirect_blks) { -- ar.goal = goal; -- new_blocks[i] = ext4_mb_new_blocks(handle, &ar, &err); -+ new_blocks[i] = ext4_mb_new_blocks(handle, ar, &err); - } else -- goal = new_blocks[i] = ext4_new_meta_blocks(handle, inode, -- goal, 0, NULL, &err); -+ ar->goal = new_blocks[i] = ext4_new_meta_blocks(handle, -+ ar->inode, ar->goal, 0, NULL, &err); - if (err) { - i--; - goto failed; -@@ -354,7 +342,7 @@ static int ext4_alloc_branch(handle_t *handle, struct inode *inode, - if (i == 0) - continue; - -- bh = branch[i].bh = sb_getblk(inode->i_sb, new_blocks[i-1]); -+ bh = branch[i].bh = sb_getblk(ar->inode->i_sb, new_blocks[i-1]); - if (unlikely(!bh)) { - err = -ENOMEM; - goto failed; -@@ -372,7 +360,7 @@ static int ext4_alloc_branch(handle_t *handle, struct inode *inode, - b = new_blocks[i]; - - if (i == indirect_blks) -- len = ar.len; -+ len = ar->len; - for (j = 0; j < len; j++) - *p++ = cpu_to_le32(b++); - -@@ -381,11 +369,10 @@ static int ext4_alloc_branch(handle_t *handle, struct inode *inode, - unlock_buffer(bh); - - BUFFER_TRACE(bh, "call ext4_handle_dirty_metadata"); -- err = ext4_handle_dirty_metadata(handle, inode, bh); -+ err = ext4_handle_dirty_metadata(handle, ar->inode, bh); - if (err) - goto failed; - } -- *blks = ar.len; - return 0; - failed: - for (; i >= 0; i--) { -@@ -396,10 +383,10 @@ static int ext4_alloc_branch(handle_t *handle, struct inode *inode, - * existing before ext4_alloc_branch() was called. - */ - if (i > 0 && i != indirect_blks && branch[i].bh) -- ext4_forget(handle, 1, inode, branch[i].bh, -+ ext4_forget(handle, 1, ar->inode, branch[i].bh, - branch[i].bh->b_blocknr); -- ext4_free_blocks(handle, inode, NULL, new_blocks[i], -- (i == indirect_blks) ? ar.len : 1, 0); -+ ext4_free_blocks(handle, ar->inode, NULL, new_blocks[i], -+ (i == indirect_blks) ? ar->len : 1, 0); - } - return err; - } -@@ -419,9 +406,9 @@ static int ext4_alloc_branch(handle_t *handle, struct inode *inode, - * inode (->i_blocks, etc.). In case of success we end up with the full - * chain to new block and return 0. - */ --static int ext4_splice_branch(handle_t *handle, struct inode *inode, -- ext4_lblk_t block, Indirect *where, int num, -- int blks) -+static int ext4_splice_branch(handle_t *handle, -+ struct ext4_allocation_request *ar, -+ Indirect *where, int num) - { - int i; - int err = 0; -@@ -446,9 +433,9 @@ static int ext4_splice_branch(handle_t *handle, struct inode *inode, - * Update the host buffer_head or inode to point to more just allocated - * direct blocks blocks - */ -- if (num == 0 && blks > 1) { -+ if (num == 0 && ar->len > 1) { - current_block = le32_to_cpu(where->key) + 1; -- for (i = 1; i < blks; i++) -+ for (i = 1; i < ar->len; i++) - *(where->p + i) = cpu_to_le32(current_block++); - } - -@@ -465,14 +452,14 @@ static int ext4_splice_branch(handle_t *handle, struct inode *inode, - */ - jbd_debug(5, "splicing indirect only\n"); - BUFFER_TRACE(where->bh, "call ext4_handle_dirty_metadata"); -- err = ext4_handle_dirty_metadata(handle, inode, where->bh); -+ err = ext4_handle_dirty_metadata(handle, ar->inode, where->bh); - if (err) - goto err_out; - } else { - /* - * OK, we spliced it into the inode itself on a direct block. - */ -- ext4_mark_inode_dirty(handle, inode); -+ ext4_mark_inode_dirty(handle, ar->inode); - jbd_debug(5, "splicing direct\n"); - } - return err; -@@ -484,11 +471,11 @@ static int ext4_splice_branch(handle_t *handle, struct inode *inode, - * need to revoke the block, which is why we don't - * need to set EXT4_FREE_BLOCKS_METADATA. - */ -- ext4_free_blocks(handle, inode, where[i].bh, 0, 1, -+ ext4_free_blocks(handle, ar->inode, where[i].bh, 0, 1, - EXT4_FREE_BLOCKS_FORGET); - } -- ext4_free_blocks(handle, inode, NULL, le32_to_cpu(where[num].key), -- blks, 0); -+ ext4_free_blocks(handle, ar->inode, NULL, le32_to_cpu(where[num].key), -+ ar->len, 0); - - return err; - } -@@ -525,11 +512,11 @@ int ext4_ind_map_blocks(handle_t *handle, struct inode *inode, - struct ext4_map_blocks *map, - int flags) - { -+ struct ext4_allocation_request ar; - int err = -EIO; - ext4_lblk_t offsets[4]; - Indirect chain[4]; - Indirect *partial; -- ext4_fsblk_t goal; - int indirect_blks; - int blocks_to_boundary = 0; - int depth; -@@ -579,7 +566,14 @@ int ext4_ind_map_blocks(handle_t *handle, struct inode *inode, - return -ENOSPC; - } - -- goal = ext4_find_goal(inode, map->m_lblk, partial); -+ /* Set up for the direct block allocation */ -+ memset(&ar, 0, sizeof(ar)); -+ ar.inode = inode; -+ ar.logical = map->m_lblk; -+ if (S_ISREG(inode->i_mode)) -+ ar.flags = EXT4_MB_HINT_DATA; -+ -+ ar.goal = ext4_find_goal(inode, map->m_lblk, partial); - - /* the number of blocks need to allocate for [d,t]indirect blocks */ - indirect_blks = (chain + depth) - partial - 1; -@@ -588,13 +582,13 @@ int ext4_ind_map_blocks(handle_t *handle, struct inode *inode, - * Next look up the indirect map to count the totoal number of - * direct blocks to allocate for this branch. - */ -- count = ext4_blks_to_allocate(partial, indirect_blks, -- map->m_len, blocks_to_boundary); -+ ar.len = ext4_blks_to_allocate(partial, indirect_blks, -+ map->m_len, blocks_to_boundary); -+ - /* - * Block out ext4_truncate while we alter the tree - */ -- err = ext4_alloc_branch(handle, inode, map->m_lblk, indirect_blks, -- &count, goal, -+ err = ext4_alloc_branch(handle, &ar, indirect_blks, - offsets + (partial - chain), partial); - - /* -@@ -605,14 +599,14 @@ int ext4_ind_map_blocks(handle_t *handle, struct inode *inode, - * may need to return -EAGAIN upwards in the worst case. --sct - */ - if (!err) -- err = ext4_splice_branch(handle, inode, map->m_lblk, -- partial, indirect_blks, count); -+ err = ext4_splice_branch(handle, &ar, partial, indirect_blks); - if (err) - goto cleanup; - - map->m_flags |= EXT4_MAP_NEW; - - ext4_update_inode_fsync_trans(handle, inode, 1); -+ count = ar.len; - got_it: - map->m_flags |= EXT4_MAP_MAPPED; - map->m_pblk = le32_to_cpu(chain[depth-1].key); --- -2.7.4 - -From e3cf5d5d9a86df1c5e413bdd3725c25a16ff854c Mon Sep 17 00:00:00 2001 -From: Theodore Ts'o -Date: Thu, 4 Sep 2014 18:07:25 -0400 -Subject: [PATCH] ext4: prepare to drop EXT4_STATE_DELALLOC_RESERVED - -The EXT4_STATE_DELALLOC_RESERVED flag was originally implemented -because it was too hard to make sure the mballoc and get_block flags -could be reliably passed down through all of the codepaths that end up -calling ext4_mb_new_blocks(). - -Since then, we have mb_flags passed down through most of the code -paths, so getting rid of EXT4_STATE_DELALLOC_RESERVED isn't as tricky -as it used to. - -This commit plumbs in the last of what is required, and then adds a -WARN_ON check to make sure we haven't missed anything. If this passes -a full regression test run, we can then drop -EXT4_STATE_DELALLOC_RESERVED. - -Signed-off-by: Theodore Ts'o -Reviewed-by: Jan Kara ---- - fs/ext4/balloc.c | 3 +-- - fs/ext4/extents.c | 6 +++++- - fs/ext4/indirect.c | 6 +++++- - fs/ext4/mballoc.c | 10 ++++++---- - fs/ext4/xattr.c | 6 ------ - 5 files changed, 17 insertions(+), 14 deletions(-) - -diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c -index 581ef40..d70f154 100644 ---- a/fs/ext4/balloc.c -+++ b/fs/ext4/balloc.c -@@ -636,8 +636,7 @@ ext4_fsblk_t ext4_new_meta_blocks(handle_t *handle, struct inode *inode, - * Account for the allocated meta blocks. We will never - * fail EDQUOT for metdata, but we do account for it. - */ -- if (!(*errp) && -- ext4_test_inode_state(inode, EXT4_STATE_DELALLOC_RESERVED)) { -+ if (!(*errp) && (flags & EXT4_MB_DELALLOC_RESERVED)) { - spin_lock(&EXT4_I(inode)->i_block_reservation_lock); - spin_unlock(&EXT4_I(inode)->i_block_reservation_lock); - dquot_alloc_block_nofail(inode, -diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c -index 3ac1686..8170b32 100644 ---- a/fs/ext4/extents.c -+++ b/fs/ext4/extents.c -@@ -1933,6 +1933,8 @@ int ext4_ext_insert_extent(handle_t *handle, struct inode *inode, - ext4_lblk_t next; - int mb_flags = 0, unwritten; - -+ if (gb_flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE) -+ mb_flags |= EXT4_MB_DELALLOC_RESERVED; - if (unlikely(ext4_ext_get_actual_len(newext) == 0)) { - EXT4_ERROR_INODE(inode, "ext4_ext_get_actual_len(newext) == 0"); - return -EIO; -@@ -2054,7 +2056,7 @@ int ext4_ext_insert_extent(handle_t *handle, struct inode *inode, - * We're gonna add a new leaf in the tree. - */ - if (gb_flags & EXT4_GET_BLOCKS_METADATA_NOFAIL) -- mb_flags = EXT4_MB_USE_RESERVED; -+ mb_flags |= EXT4_MB_USE_RESERVED; - err = ext4_ext_create_new_leaf(handle, inode, mb_flags, gb_flags, - ppath, newext); - if (err) -@@ -4438,6 +4440,8 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode, - ar.flags = 0; - if (flags & EXT4_GET_BLOCKS_NO_NORMALIZE) - ar.flags |= EXT4_MB_HINT_NOPREALLOC; -+ if (flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE) -+ ar.flags |= EXT4_MB_DELALLOC_RESERVED; - newblock = ext4_mb_new_blocks(handle, &ar, &err); - if (!newblock) - goto out2; -diff --git a/fs/ext4/indirect.c b/fs/ext4/indirect.c -index 69af0cd..36b3696 100644 ---- a/fs/ext4/indirect.c -+++ b/fs/ext4/indirect.c -@@ -333,7 +333,9 @@ static int ext4_alloc_branch(handle_t *handle, - new_blocks[i] = ext4_mb_new_blocks(handle, ar, &err); - } else - ar->goal = new_blocks[i] = ext4_new_meta_blocks(handle, -- ar->inode, ar->goal, 0, NULL, &err); -+ ar->inode, ar->goal, -+ ar->flags & EXT4_MB_DELALLOC_RESERVED, -+ NULL, &err); - if (err) { - i--; - goto failed; -@@ -572,6 +574,8 @@ int ext4_ind_map_blocks(handle_t *handle, struct inode *inode, - ar.logical = map->m_lblk; - if (S_ISREG(inode->i_mode)) - ar.flags = EXT4_MB_HINT_DATA; -+ if (flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE) -+ ar.flags |= EXT4_MB_DELALLOC_RESERVED; - - ar.goal = ext4_find_goal(inode, map->m_lblk, partial); - -diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c -index 8b0f9ef..15dffda 100644 ---- a/fs/ext4/mballoc.c -+++ b/fs/ext4/mballoc.c -@@ -4415,9 +4415,12 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle, - * EDQUOT check, as blocks and quotas have been already - * reserved when data being copied into pagecache. - */ -- if (ext4_test_inode_state(ar->inode, EXT4_STATE_DELALLOC_RESERVED)) -+ if (ext4_test_inode_state(ar->inode, EXT4_STATE_DELALLOC_RESERVED)) { -+ WARN_ON((ar->flags & EXT4_MB_DELALLOC_RESERVED) == 0); - ar->flags |= EXT4_MB_DELALLOC_RESERVED; -- else { -+ } -+ -+ if ((ar->flags & EXT4_MB_DELALLOC_RESERVED) == 0) { - /* Without delayed allocation we need to verify - * there is enough free blocks to do block allocation - * and verify allocation doesn't exceed the quota limits. -@@ -4528,8 +4531,7 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle, - if (inquota && ar->len < inquota) - dquot_free_block(ar->inode, EXT4_C2B(sbi, inquota - ar->len)); - if (!ar->len) { -- if (!ext4_test_inode_state(ar->inode, -- EXT4_STATE_DELALLOC_RESERVED)) -+ if ((ar->flags & EXT4_MB_DELALLOC_RESERVED) == 0) - /* release all the reserved blocks if non delalloc */ - percpu_counter_sub(&sbi->s_dirtyclusters_counter, - reserv_clstrs); -diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c -index e738733..da4df70 100644 ---- a/fs/ext4/xattr.c -+++ b/fs/ext4/xattr.c -@@ -899,14 +899,8 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode, - if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) - goal = goal & EXT4_MAX_BLOCK_FILE_PHYS; - -- /* -- * take i_data_sem because we will test -- * i_delalloc_reserved_flag in ext4_mb_new_blocks -- */ -- down_read(&EXT4_I(inode)->i_data_sem); - block = ext4_new_meta_blocks(handle, inode, goal, 0, - NULL, &error); -- up_read((&EXT4_I(inode)->i_data_sem)); - if (error) - goto cleanup; - --- -2.7.4 - -From 2e81a4eeedcaa66e35f58b81e0755b87057ce392 Mon Sep 17 00:00:00 2001 -From: Jan Kara -Date: Thu, 11 Aug 2016 12:38:55 -0400 -Subject: [PATCH] ext4: avoid deadlock when expanding inode size - -When we need to move xattrs into external xattr block, we call -ext4_xattr_block_set() from ext4_expand_extra_isize_ea(). That may end -up calling ext4_mark_inode_dirty() again which will recurse back into -the inode expansion code leading to deadlocks. - -Protect from recursion using EXT4_STATE_NO_EXPAND inode flag and move -its management into ext4_expand_extra_isize_ea() since its manipulation -is safe there (due to xattr_sem) from possible races with -ext4_xattr_set_handle() which plays with it as well. - -CC: stable@vger.kernel.org # 4.4.x -Signed-off-by: Jan Kara -Signed-off-by: Theodore Ts'o ---- - fs/ext4/inode.c | 2 -- - fs/ext4/xattr.c | 19 +++++++++++++------ - 2 files changed, 13 insertions(+), 8 deletions(-) - -diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c -index 5a6277d..13c95b2 100644 ---- a/fs/ext4/inode.c -+++ b/fs/ext4/inode.c -@@ -5466,8 +5466,6 @@ int ext4_mark_inode_dirty(handle_t *handle, struct inode *inode) - sbi->s_want_extra_isize, - iloc, handle); - if (ret) { -- ext4_set_inode_state(inode, -- EXT4_STATE_NO_EXPAND); - if (mnt_count != - le16_to_cpu(sbi->s_es->s_mnt_count)) { - ext4_warning(inode->i_sb, -diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c -index c893f00..2eb935c 100644 ---- a/fs/ext4/xattr.c -+++ b/fs/ext4/xattr.c -@@ -1358,11 +1358,13 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize, - int isize_diff; /* How much do we need to grow i_extra_isize */ - - down_write(&EXT4_I(inode)->xattr_sem); -+ /* -+ * Set EXT4_STATE_NO_EXPAND to avoid recursion when marking inode dirty -+ */ -+ ext4_set_inode_state(inode, EXT4_STATE_NO_EXPAND); - retry: -- if (EXT4_I(inode)->i_extra_isize >= new_extra_isize) { -- up_write(&EXT4_I(inode)->xattr_sem); -- return 0; -- } -+ if (EXT4_I(inode)->i_extra_isize >= new_extra_isize) -+ goto out; - - header = IHDR(inode, raw_inode); - entry = IFIRST(header); -@@ -1392,8 +1394,7 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize, - (void *)header, total_ino, - inode->i_sb->s_blocksize); - EXT4_I(inode)->i_extra_isize = new_extra_isize; -- error = 0; -- goto cleanup; -+ goto out; - } - - /* -@@ -1553,6 +1554,8 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize, - kfree(bs); - } - brelse(bh); -+out: -+ ext4_clear_inode_state(inode, EXT4_STATE_NO_EXPAND); - up_write(&EXT4_I(inode)->xattr_sem); - return 0; - -@@ -1564,6 +1567,10 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize, - kfree(is); - kfree(bs); - brelse(bh); -+ /* -+ * We deliberately leave EXT4_STATE_NO_EXPAND set here since inode -+ * size expansion failed. -+ */ - up_write(&EXT4_I(inode)->xattr_sem); - return error; - } --- -2.7.4 - diff --git a/ldiskfs/kernel_patches/patches/sles11sp1/ext4-notalloc_under_idatasem.patch b/ldiskfs/kernel_patches/patches/sles11sp1/ext4-notalloc_under_idatasem.patch deleted file mode 100644 index 659228c..0000000 --- a/ldiskfs/kernel_patches/patches/sles11sp1/ext4-notalloc_under_idatasem.patch +++ /dev/null @@ -1,14 +0,0 @@ -Index: linux-stage/fs/ext4/extents.c -=================================================================== ---- linux-stage.orig/fs/ext4/extents.c 2015-07-13 22:22:56.000000000 +0300 -+++ linux-stage/fs/ext4/extents.c 2015-07-13 22:24:05.000000000 +0300 -@@ -3954,7 +3954,8 @@ static int ext4_ext_fiemap_cb(struct ino - struct buffer_head *head = NULL; - unsigned int nr_pages = PAGE_SIZE / sizeof(struct page *); - -- pages = kmalloc(PAGE_SIZE, GFP_KERNEL); -+ /* we are running under i_data_sem so don't reenter the FS code */ -+ pages = kmalloc(PAGE_SIZE, GFP_NOFS); - if (pages == NULL) - return -ENOMEM; - diff --git a/ldiskfs/kernel_patches/patches/sles11sp2/export-ext4-3.0.patch b/ldiskfs/kernel_patches/patches/sles11sp2/export-ext4-3.0.patch deleted file mode 100644 index 3595d48..0000000 --- a/ldiskfs/kernel_patches/patches/sles11sp2/export-ext4-3.0.patch +++ /dev/null @@ -1,224 +0,0 @@ ---- - fs/ext4/balloc.c | 1 + - fs/ext4/ext4.h | 2 ++ - fs/ext4/ext4_extents.h | 9 +++++++++ - fs/ext4/ext4_jbd2.c | 2 ++ - fs/ext4/extents.c | 23 ++++++++++++++++------- - fs/ext4/ialloc.c | 3 ++- - fs/ext4/inode.c | 1 + - fs/ext4/mballoc.c | 4 ++++ - fs/ext4/super.c | 9 +++++++++ - 9 files changed, 46 insertions(+), 8 deletions(-) - -Index: linux-stage/fs/ext4/balloc.c -=================================================================== ---- linux-stage.orig/fs/ext4/balloc.c -+++ linux-stage/fs/ext4/balloc.c -@@ -231,6 +231,7 @@ struct ext4_group_desc * ext4_get_group_ - *bh = sbi->s_group_desc[group_desc]; - return desc; - } -+EXPORT_SYMBOL(ext4_get_group_desc); - - static int ext4_valid_block_bitmap(struct super_block *sb, - struct ext4_group_desc *desc, -Index: linux-stage/fs/ext4/ext4.h -=================================================================== ---- linux-stage.orig/fs/ext4/ext4.h -+++ linux-stage/fs/ext4/ext4.h -@@ -1783,6 +1783,8 @@ extern struct inode * ext4_orphan_get(st - extern unsigned long ext4_count_free_inodes(struct super_block *); - extern unsigned long ext4_count_dirs(struct super_block *); - extern void ext4_check_inodes_bitmap(struct super_block *); -+extern struct buffer_head *ext4_read_inode_bitmap(struct super_block *sb, -+ ext4_group_t block_group); - extern void ext4_mark_bitmap_end(int start_bit, int end_bit, char *bitmap); - extern int ext4_init_inode_table(struct super_block *sb, - ext4_group_t group, int barrier); -Index: linux-stage/fs/ext4/ext4_extents.h -=================================================================== ---- linux-stage.orig/fs/ext4/ext4_extents.h -+++ linux-stage/fs/ext4/ext4_extents.h -@@ -290,5 +290,14 @@ extern struct ext4_ext_path *ext4_ext_fi - struct ext4_ext_path *); - extern void ext4_ext_drop_refs(struct ext4_ext_path *); - extern int ext4_ext_check_inode(struct inode *inode); -+extern int ext4_ext_search_right(struct inode *inode, -+ struct ext4_ext_path *path, -+ ext4_lblk_t *logical, ext4_fsblk_t *phys); -+extern int ext4_ext_search_left(struct inode *inode, -+ struct ext4_ext_path *path, -+ ext4_lblk_t *logical, ext4_fsblk_t *phys); -+extern int ext4_ext_walk_space(struct inode *inode, ext4_lblk_t block, -+ ext4_lblk_t num, ext_prepare_callback func, -+ void *cbdata); - #endif /* _EXT4_EXTENTS */ - -Index: linux-stage/fs/ext4/ext4_jbd2.c -=================================================================== ---- linux-stage.orig/fs/ext4/ext4_jbd2.c -+++ linux-stage/fs/ext4/ext4_jbd2.c -@@ -19,6 +19,7 @@ int __ext4_journal_get_write_access(cons - } - return err; - } -+EXPORT_SYMBOL(__ext4_journal_get_write_access); - - /* - * The ext4 forget function must perform a revoke if we are freeing data -@@ -150,3 +151,4 @@ int __ext4_handle_dirty_super(const char - sb->s_dirt = 1; - return err; - } -+EXPORT_SYMBOL(__ext4_handle_dirty_metadata); -Index: linux-stage/fs/ext4/extents.c -=================================================================== ---- linux-stage.orig/fs/ext4/extents.c -+++ linux-stage/fs/ext4/extents.c -@@ -1236,9 +1236,9 @@ out: - * returns 0 at @phys - * return value contains 0 (success) or error code - */ --static int ext4_ext_search_left(struct inode *inode, -- struct ext4_ext_path *path, -- ext4_lblk_t *logical, ext4_fsblk_t *phys) -+int ext4_ext_search_left(struct inode *inode, -+ struct ext4_ext_path *path, -+ ext4_lblk_t *logical, ext4_fsblk_t *phys) - { - struct ext4_extent_idx *ix; - struct ext4_extent *ex; -@@ -1301,9 +1301,9 @@ static int ext4_ext_search_left(struct i - * returns 0 at @phys - * return value contains 0 (success) or error code - */ --static int ext4_ext_search_right(struct inode *inode, -- struct ext4_ext_path *path, -- ext4_lblk_t *logical, ext4_fsblk_t *phys) -+int ext4_ext_search_right(struct inode *inode, -+ struct ext4_ext_path *path, -+ ext4_lblk_t *logical, ext4_fsblk_t *phys) - { - struct buffer_head *bh = NULL; - struct ext4_extent_header *eh; -@@ -1878,7 +1878,7 @@ cleanup: - return err; - } - --static int ext4_ext_walk_space(struct inode *inode, ext4_lblk_t block, -+extern int ext4_ext_walk_space(struct inode *inode, ext4_lblk_t block, - ext4_lblk_t num, ext_prepare_callback func, - void *cbdata) - { -@@ -4415,3 +4415,12 @@ int ext4_fiemap(struct inode *inode, str - - return error; - } -+ -+EXPORT_SYMBOL(ext4_ext_search_right); -+EXPORT_SYMBOL(ext4_ext_search_left); -+EXPORT_SYMBOL(ext4_ext_insert_extent); -+EXPORT_SYMBOL(ext4_mb_new_blocks); -+EXPORT_SYMBOL(ext4_mark_inode_dirty); -+EXPORT_SYMBOL(ext4_ext_walk_space); -+EXPORT_SYMBOL(ext4_ext_find_extent); -+EXPORT_SYMBOL(ext4_ext_drop_refs); -Index: linux-stage/fs/ext4/ialloc.c -=================================================================== ---- linux-stage.orig/fs/ext4/ialloc.c -+++ linux-stage/fs/ext4/ialloc.c -@@ -99,7 +99,7 @@ static unsigned ext4_init_inode_bitmap(s - * - * Return buffer_head of bitmap on success or NULL. - */ --static struct buffer_head * -+struct buffer_head * - ext4_read_inode_bitmap(struct super_block *sb, ext4_group_t block_group) - { - struct ext4_group_desc *desc; -@@ -164,6 +164,7 @@ ext4_read_inode_bitmap(struct super_bloc - } - return bh; - } -+EXPORT_SYMBOL(ext4_read_inode_bitmap); - - /* - * NOTE! When we get the inode, we're the only people -Index: linux-stage/fs/ext4/inode.c -=================================================================== ---- linux-stage.orig/fs/ext4/inode.c -+++ linux-stage/fs/ext4/inode.c -@@ -1393,6 +1393,7 @@ int ext4_map_blocks(handle_t *handle, st - } - return retval; - } -+EXPORT_SYMBOL(ext4_map_blocks); - - /* Maximum number of blocks we map for direct IO at once. */ - #define DIO_MAX_BLOCKS 4096 -@@ -4689,6 +4690,7 @@ out_stop: - ext4_journal_stop(handle); - trace_ext4_truncate_exit(inode); - } -+EXPORT_SYMBOL(ext4_truncate); - - /* - * ext4_get_inode_loc returns with an extra refcount against the inode's -@@ -5102,6 +5104,7 @@ bad_inode: - iget_failed(inode); - return ERR_PTR(ret); - } -+EXPORT_SYMBOL(ext4_iget); - - static int ext4_inode_blocks_set(handle_t *handle, - struct ext4_inode *raw_inode, -Index: linux-stage/fs/ext4/mballoc.c -=================================================================== ---- linux-stage.orig/fs/ext4/mballoc.c -+++ linux-stage/fs/ext4/mballoc.c -@@ -3856,6 +3856,7 @@ repeat: - call_rcu(&(pa)->u.pa_rcu, ext4_mb_pa_callback); - } - } -+EXPORT_SYMBOL(ext4_discard_preallocations); - - #ifdef CONFIG_EXT4_DEBUG - static void ext4_mb_show_ac(struct ext4_allocation_context *ac) -@@ -4976,3 +4977,6 @@ int ext4_trim_fs(struct super_block *sb, - - return ret; - } -+ -+EXPORT_SYMBOL(ext4_free_blocks); -+ -Index: linux-stage/fs/ext4/super.c -=================================================================== ---- linux-stage.orig/fs/ext4/super.c -+++ linux-stage/fs/ext4/super.c -@@ -202,6 +202,7 @@ __u32 ext4_itable_unused_count(struct su - (EXT4_DESC_SIZE(sb) >= EXT4_MIN_DESC_SIZE_64BIT ? - (__u32)le16_to_cpu(bg->bg_itable_unused_hi) << 16 : 0); - } -+EXPORT_SYMBOL(ext4_itable_unused_count); - - void ext4_block_bitmap_set(struct super_block *sb, - struct ext4_group_desc *bg, ext4_fsblk_t blk) -@@ -4280,6 +4282,7 @@ int ext4_force_commit(struct super_block - - return ret; - } -+EXPORT_SYMBOL(ext4_force_commit); - - static void ext4_write_super(struct super_block *sb) - { -@@ -5210,6 +5213,10 @@ static void __exit ext4_exit_fs(void) - ext4_exit_pageio(); - } - -+EXPORT_SYMBOL(ext4_bread); -+EXPORT_SYMBOL(ext4_journal_start_sb); -+EXPORT_SYMBOL(__ext4_journal_stop); -+ - MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others"); - MODULE_DESCRIPTION("Fourth Extended Filesystem"); - MODULE_LICENSE("GPL"); diff --git a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-corrupted-inode-block-bitmaps-handling-patches.patch b/ldiskfs/kernel_patches/patches/sles11sp2/ext4-corrupted-inode-block-bitmaps-handling-patches.patch deleted file mode 100644 index 3b845e2..0000000 --- a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-corrupted-inode-block-bitmaps-handling-patches.patch +++ /dev/null @@ -1,438 +0,0 @@ -diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c -index db5b7a3..332078f 100644 ---- a/fs/ext4/balloc.c -+++ b/fs/ext4/balloc.c -@@ -99,12 +99,11 @@ unsigned ext4_init_block_bitmap(struct super_block *sb, struct buffer_head *bh, - /* If checksum is bad mark all blocks used to prevent allocation - * essentially implementing a per-group read-only flag. */ - if (!ext4_group_desc_csum_verify(sbi, block_group, gdp)) { -- ext4_error(sb, "Checksum bad for group %u", -+ ext4_corrupted_block_group(sb, block_group, -+ EXT4_GROUP_INFO_BBITMAP_CORRUPT | -+ EXT4_GROUP_INFO_IBITMAP_CORRUPT, -+ "Checksum bad for group %u", - block_group); -- ext4_free_blks_set(sb, gdp, 0); -- ext4_free_inodes_set(sb, gdp, 0); -- ext4_itable_unused_set(sb, gdp, 0); -- memset(bh->b_data, 0xff, sb->s_blocksize); - return 0; - } - memset(bh->b_data, 0, sb->s_blocksize); -@@ -279,8 +278,10 @@ static int ext4_valid_block_bitmap(struct super_block *sb, - return 1; - - err_out: -- ext4_error(sb, "Invalid block bitmap - block_group = %d, block = %llu", -- block_group, bitmap_blk); -+ ext4_corrupted_block_group(sb, block_group, -+ EXT4_GROUP_INFO_BBITMAP_CORRUPT, -+ "Invalid block bitmap - block_group = %d, block = %llu", -+ block_group, bitmap_blk); - return 0; - } - /** -diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h -index a18fd36..949d7be 100644 ---- a/fs/ext4/ext4.h -+++ b/fs/ext4/ext4.h -@@ -78,6 +78,18 @@ typedef __u32 ext4_lblk_t; - /* data type for block group number */ - typedef unsigned int ext4_group_t; - -+void __ext4_corrupted_block_group(struct super_block *sb, -+ ext4_group_t group, unsigned int flags, -+ const char *function, -+ unsigned int line); -+ -+#define ext4_corrupted_block_group(sb, group, flags, fmt...) \ -+ do { \ -+ __ext4_warning(sb, __func__, __LINE__, ## fmt); \ -+ __ext4_corrupted_block_group(sb, group, flags, \ -+ __func__, __LINE__); \ -+ } while (0) -+ - /* - * Flags used in mballoc's allocation_context flags field. - * -@@ -2257,9 +2269,19 @@ struct ext4_group_info { - - #define EXT4_GROUP_INFO_NEED_INIT_BIT 0 - #define EXT4_GROUP_INFO_WAS_TRIMMED_BIT 1 -+#define EXT4_GROUP_INFO_BBITMAP_CORRUPT_BIT 2 -+#define EXT4_GROUP_INFO_BBITMAP_CORRUPT \ -+ (1 << EXT4_GROUP_INFO_BBITMAP_CORRUPT_BIT) -+#define EXT4_GROUP_INFO_IBITMAP_CORRUPT_BIT 3 -+#define EXT4_GROUP_INFO_IBITMAP_CORRUPT \ -+ (1 << EXT4_GROUP_INFO_IBITMAP_CORRUPT_BIT) - - #define EXT4_MB_GRP_NEED_INIT(grp) \ - (test_bit(EXT4_GROUP_INFO_NEED_INIT_BIT, &((grp)->bb_state))) -+#define EXT4_MB_GRP_BBITMAP_CORRUPT(grp) \ -+ (test_bit(EXT4_GROUP_INFO_BBITMAP_CORRUPT_BIT, &((grp)->bb_state))) -+#define EXT4_MB_GRP_IBITMAP_CORRUPT(grp) \ -+ (test_bit(EXT4_GROUP_INFO_IBITMAP_CORRUPT_BIT, &((grp)->bb_state))) - - #define EXT4_MB_GRP_WAS_TRIMMED(grp) \ - (test_bit(EXT4_GROUP_INFO_WAS_TRIMMED_BIT, &((grp)->bb_state))) -diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c -index 532dcaa..6082e54 100644 ---- a/fs/ext4/ialloc.c -+++ b/fs/ext4/ialloc.c -@@ -78,11 +78,10 @@ static unsigned ext4_init_inode_bitmap(struct super_block *sb, - /* If checksum is bad mark all blocks and inodes use to prevent - * allocation, essentially implementing a per-group read-only flag. */ - if (!ext4_group_desc_csum_verify(sbi, block_group, gdp)) { -- ext4_error(sb, "Checksum bad for group %u", block_group); -- ext4_free_blks_set(sb, gdp, 0); -- ext4_free_inodes_set(sb, gdp, 0); -- ext4_itable_unused_set(sb, gdp, 0); -- memset(bh->b_data, 0xff, sb->s_blocksize); -+ ext4_corrupted_block_group(sb, block_group, -+ EXT4_GROUP_INFO_BBITMAP_CORRUPT | -+ EXT4_GROUP_INFO_IBITMAP_CORRUPT, -+ "Checksum bad for group %u", block_group); - return 0; - } - -@@ -195,6 +194,7 @@ void ext4_free_inode(handle_t *handle, struct inode *inode) - struct ext4_super_block *es; - struct ext4_sb_info *sbi; - int fatal = 0, err, count, cleared; -+ struct ext4_group_info *grp; - - if (atomic_read(&inode->i_count) > 1) { - printk(KERN_ERR "ext4_free_inode: inode has count=%d\n", -@@ -238,7 +238,9 @@ void ext4_free_inode(handle_t *handle, struct inode *inode) - block_group = (ino - 1) / EXT4_INODES_PER_GROUP(sb); - bit = (ino - 1) % EXT4_INODES_PER_GROUP(sb); - bitmap_bh = ext4_read_inode_bitmap(sb, block_group); -- if (!bitmap_bh) -+ /* Don't bother if the inode bitmap is corrupt. */ -+ grp = ext4_get_group_info(sb, block_group); -+ if (unlikely(EXT4_MB_GRP_IBITMAP_CORRUPT(grp)) || !bitmap_bh) - goto error_return; - - BUFFER_TRACE(bitmap_bh, "get_write_access"); -@@ -286,8 +288,12 @@ out: - if (!fatal) - fatal = err; - ext4_mark_super_dirty(sb); -- } else -- ext4_error(sb, "bit already cleared for inode %lu", ino); -+ } else { -+ ext4_corrupted_block_group(sb, block_group, -+ EXT4_GROUP_INFO_IBITMAP_CORRUPT, -+ "bit already cleared for inode %lu", -+ ino); -+ } - - error_return: - brelse(bitmap_bh); -@@ -820,6 +826,7 @@ struct inode *ext4_new_inode(handle_t *handle, struct inode *dir, int mode, - int free = 0; - static int once = 1; - ext4_group_t flex_group; -+ struct ext4_group_info *grp; - - /* Cannot create files in a deleted directory */ - if (!dir || !dir->i_nlink) -@@ -879,10 +886,21 @@ got_group: - if (!gdp) - goto fail; - -+ grp = ext4_get_group_info(sb, group); -+ /* Skip groups with already-known suspicious inode tables */ -+ if (EXT4_MB_GRP_IBITMAP_CORRUPT(grp)) { -+ if (++group == ngroups) -+ group = 0; -+ continue; -+ } - brelse(inode_bitmap_bh); - inode_bitmap_bh = ext4_read_inode_bitmap(sb, group); -- if (!inode_bitmap_bh) -- goto fail; -+ /* Skip groups with suspicious inode tables */ -+ if (EXT4_MB_GRP_IBITMAP_CORRUPT(grp) || !inode_bitmap_bh) { -+ if (++group == ngroups) -+ group = 0; -+ continue; -+ } - - repeat_in_this_group: - ino = ext4_find_next_zero_bit((unsigned long *) -diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c -index 1d77581..4d6558e 100644 ---- a/fs/ext4/mballoc.c -+++ b/fs/ext4/mballoc.c -@@ -740,7 +740,6 @@ int ext4_mb_generate_buddy(struct super_block *sb, - "%u blocks in bitmap, %u in bb, %u in gd", - free, grp->bb_free, - ext4_free_blks_count(sb, gdp)); -- - /* - * If we intent to continue, we consider group descritor - * corrupt and update bb_free using bitmap value -@@ -1124,7 +1123,7 @@ ext4_mb_load_buddy(struct super_block *sb, ext4_group_t group, - int block; - int pnum; - int poff; -- struct page *page; -+ struct page *page = NULL; - int ret; - struct ext4_group_info *grp; - struct ext4_sb_info *sbi = EXT4_SB(sb); -@@ -1149,7 +1148,7 @@ ext4_mb_load_buddy(struct super_block *sb, ext4_group_t group, - */ - ret = ext4_mb_init_group(sb, group); - if (ret) -- return ret; -+ goto err; - } - - /* -@@ -1233,6 +1232,8 @@ ext4_mb_load_buddy(struct super_block *sb, ext4_group_t group, - return 0; - - err: -+ ext4_warning(sb, "Error in loading buddy information for %u", -+ group); - if (page) - page_cache_release(page); - if (e4b->bd_bitmap_page) -@@ -1322,6 +1323,10 @@ static void mb_free_blocks(struct inode *inode, struct ext4_buddy *e4b, - - BUG_ON(first + count > (sb->s_blocksize << 3)); - assert_spin_locked(ext4_group_lock_ptr(sb, e4b->bd_group)); -+ /* Don't bother if the block group is corrupt. */ -+ if (unlikely(EXT4_MB_GRP_BBITMAP_CORRUPT(e4b->bd_info))) -+ return; -+ - mb_check_buddy(e4b); - mb_free_blocks_double(inode, e4b, first, count); - -@@ -1729,6 +1734,11 @@ int ext4_mb_find_by_goal(struct ext4_allocation_context *ac, - if (err) - return err; - -+ if (unlikely(EXT4_MB_GRP_BBITMAP_CORRUPT(e4b->bd_info))) { -+ ext4_mb_unload_buddy(e4b); -+ return 0; -+ } -+ - ext4_lock_group(ac->ac_sb, group); - max = mb_find_extent(e4b, 0, ac->ac_g_ex.fe_start, - ac->ac_g_ex.fe_len, &ex); -@@ -1940,6 +1950,9 @@ static int ext4_mb_good_group(struct ext4_allocation_context *ac, - - BUG_ON(cr < 0 || cr >= 4); - -+ if (unlikely(EXT4_MB_GRP_BBITMAP_CORRUPT(grp))) -+ return 0; -+ - /* We only do this if the grp has never been initialized */ - if (unlikely(EXT4_MB_GRP_NEED_INIT(grp))) { - int ret = ext4_mb_init_group(ac->ac_sb, group); -@@ -3458,9 +3471,11 @@ int ext4_mb_check_ondisk_bitmap(struct super_block *sb, void *bitmap, - } - - if (free != free_in_gdp) { -- ext4_error(sb, "on-disk bitmap for group %d" -- "corrupted: %u blocks free in bitmap, %u - in gd\n", -- group, free, free_in_gdp); -+ ext4_corrupted_block_group(sb, group, -+ EXT4_GROUP_INFO_BBITMAP_CORRUPT, -+ "on-disk bitmap for group %d corrupted: %u blocks free in bitmap, %u - in gd\n", -+ group, free, -+ free_in_gdp); - return -EIO; - } - return 0; -@@ -3813,17 +3828,9 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh, - /* "free < pa->pa_free" means we maybe double alloc the same blocks, - * otherwise maybe leave some free blocks unavailable, no need to BUG.*/ - if ((free > pa->pa_free && !pa->pa_error) || (free < pa->pa_free)) { -- ext4_error(sb, "pa free mismatch: [pa %p] " -- "[phy %lu] [logic %lu] [len %u] [free %u] " -- "[error %u] [inode %lu] [freed %u]", pa, -- (unsigned long)pa->pa_pstart, -- (unsigned long)pa->pa_lstart, -- (unsigned)pa->pa_len, (unsigned)pa->pa_free, -- (unsigned)pa->pa_error, pa->pa_inode->i_ino, -- free); - ext4_grp_locked_error(sb, group, 0, 0, -- "free %u, pa_free %u", -- free, pa->pa_free); -+ "free %u, pa_free %u", -+ free, pa->pa_free); - /* - * pa is already deleted so we use the value obtained - * from the bitmap and continue. -@@ -3883,14 +3890,11 @@ ext4_mb_discard_group_preallocations(struct super_block *sb, - return 0; - - bitmap_bh = ext4_read_block_bitmap(sb, group); -- if (bitmap_bh == NULL) { -- ext4_error(sb, "Error reading block bitmap for %u", group); -+ if (bitmap_bh == NULL) - return 0; -- } - - err = ext4_mb_load_buddy(sb, group, &e4b); - if (err) { -- ext4_error(sb, "Error loading buddy information for %u", group); - put_bh(bitmap_bh); - return 0; - } -@@ -4054,16 +4058,11 @@ repeat: - ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, NULL); - - err = ext4_mb_load_buddy(sb, group, &e4b); -- if (err) { -- ext4_error(sb, "Error loading buddy information for %u", -- group); -+ if (err) - return; -- } - - bitmap_bh = ext4_read_block_bitmap(sb, group); - if (bitmap_bh == NULL) { -- ext4_error(sb, "Error reading block bitmap for %u", -- group); - ext4_mb_unload_buddy(&e4b); - continue; - } -@@ -4324,11 +4323,8 @@ ext4_mb_discard_lg_preallocations(struct super_block *sb, - list_for_each_entry_safe(pa, tmp, &discard_list, u.pa_tmp_list) { - - ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, NULL); -- if (ext4_mb_load_buddy(sb, group, &e4b)) { -- ext4_error(sb, "Error loading buddy information for %u", -- group); -+ if (ext4_mb_load_buddy(sb, group, &e4b)) - continue; -- } - ext4_lock_group(sb, group); - list_del(&pa->pa_group_list); - ext4_get_group_info(sb, group)->bb_prealloc_nr--; -@@ -4585,7 +4581,7 @@ repeat: - * been updated or not when fail case. So can - * not revert pa_free back, just mark pa_error*/ - pa->pa_error++; -- ext4_error(sb, -+ ext4_corrupted_block_group(sb, 0, 0, - "Updating bitmap error: [err %d] " - "[pa %p] [phy %lu] [logic %lu] " - "[len %u] [free %u] [error %u] " -@@ -4731,6 +4727,7 @@ void ext4_free_blocks(handle_t *handle, struct inode *inode, - struct ext4_buddy e4b; - int err = 0; - int ret; -+ int skip_error = 0; - - if (bh) { - if (block) -@@ -4781,6 +4778,10 @@ do_more: - overflow = 0; - ext4_get_group_no_and_offset(sb, block, &block_group, &bit); - -+ if (unlikely(EXT4_MB_GRP_BBITMAP_CORRUPT( -+ ext4_get_group_info(sb, block_group)))) -+ return; -+ - /* - * Check to see if we are freeing blocks across a group - * boundary. -@@ -4837,8 +4838,10 @@ do_more: - trace_ext4_mballoc_free(sb, inode, block_group, bit, count); - - err = ext4_mb_load_buddy(sb, block_group, &e4b); -- if (err) -+ if (err) { -+ skip_error = 1; - goto error_return; -+ } - - if ((flags & EXT4_FREE_BLOCKS_METADATA) && ext4_handle_valid(handle)) { - struct ext4_free_data *new_entry; -@@ -4905,8 +4908,9 @@ do_more: - error_return: - if (freed && !(flags & EXT4_FREE_BLOCKS_NO_QUOT_UPDATE)) - dquot_free_block(inode, freed); -+ if (!skip_error) -+ ext4_std_error(sb, err); - brelse(bitmap_bh); -- ext4_std_error(sb, err); - return; - } - -@@ -4991,7 +4995,7 @@ void ext4_add_groupblocks(handle_t *handle, struct super_block *sb, - - err = ext4_mb_load_buddy(sb, block_group, &e4b); - if (err) -- goto error_return; -+ goto error_brelse; - - /* - * need to update group_info->bb_free and bitmap -@@ -5026,8 +5030,9 @@ void ext4_add_groupblocks(handle_t *handle, struct super_block *sb, - err = ret; - - error_return: -- brelse(bitmap_bh); - ext4_std_error(sb, err); -+error_brelse: -+ brelse(bitmap_bh); - return; - } - -@@ -5094,11 +5099,8 @@ ext4_trim_all_free(struct super_block *sb, ext4_group_t group, - int ret; - - ret = ext4_mb_load_buddy(sb, group, &e4b); -- if (ret) { -- ext4_error(sb, "Error in loading buddy " -- "information for %u", group); -+ if (ret) - return ret; -- } - bitmap = e4b.bd_bitmap; - - ext4_lock_group(sb, group); -diff --git a/fs/ext4/super.c b/fs/ext4/super.c -index a21e903..2fca810 100644 ---- a/fs/ext4/super.c -+++ b/fs/ext4/super.c -@@ -666,6 +666,32 @@ void __ext4_warning(struct super_block *sb, const char *function, - va_end(args); - } - -+void __ext4_corrupted_block_group(struct super_block *sb, ext4_group_t group, -+ unsigned int flags, const char *function, -+ unsigned int line) -+{ -+ struct ext4_group_info *grp = ext4_get_group_info(sb, group); -+ struct ext4_group_desc *gdp = ext4_get_group_desc(sb, group, NULL); -+ -+ if (flags & EXT4_GROUP_INFO_BBITMAP_CORRUPT && -+ !EXT4_MB_GRP_BBITMAP_CORRUPT(grp)) { -+ ext4_free_blks_set(sb, gdp, 0); -+ set_bit(EXT4_GROUP_INFO_BBITMAP_CORRUPT_BIT, -+ &grp->bb_state); -+ } -+ -+ if (flags & EXT4_GROUP_INFO_IBITMAP_CORRUPT && -+ !EXT4_MB_GRP_IBITMAP_CORRUPT(grp)) { -+ if (gdp) { -+ ext4_free_inodes_set(sb, gdp, 0); -+ ext4_itable_unused_set(sb, gdp, 0); -+ } -+ set_bit(EXT4_GROUP_INFO_IBITMAP_CORRUPT_BIT, -+ &grp->bb_state); -+ } -+ save_error_info(sb, function, line); -+} -+ - void __ext4_grp_locked_error(const char *function, unsigned int line, - struct super_block *sb, ext4_group_t grp, - unsigned long ino, ext4_fsblk_t block, diff --git a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-data-in-dirent.patch b/ldiskfs/kernel_patches/patches/sles11sp2/ext4-data-in-dirent.patch deleted file mode 100644 index f11f826..0000000 --- a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-data-in-dirent.patch +++ /dev/null @@ -1,555 +0,0 @@ ---- - fs/ext4/dir.c | 26 +++++++++--- - fs/ext4/ext4.h | 70 ++++++++++++++++++++++++++++++++- - fs/ext4/namei.c | 117 ++++++++++++++++++++++++++++++++++++++++---------------- - 3 files changed, 170 insertions(+), 43 deletions(-) - -Index: linux-3.0.101-0.5/fs/ext4/dir.c -=================================================================== ---- linux-3.0.101-0.5.orig/fs/ext4/dir.c -+++ linux-3.0.101-0.5/fs/ext4/dir.c -@@ -53,11 +53,18 @@ const struct file_operations ext4_dir_op - - static unsigned char get_dtype(struct super_block *sb, int filetype) - { -+ int fl_index = filetype & EXT4_FT_MASK; -+ - if (!EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_FILETYPE) || -- (filetype >= EXT4_FT_MAX)) -+ (fl_index >= EXT4_FT_MAX)) - return DT_UNKNOWN; - -- return (ext4_filetype_table[filetype]); -+ if (!test_opt(sb, DIRDATA)) -+ return (ext4_filetype_table[fl_index]); -+ -+ return (ext4_filetype_table[fl_index]) | -+ (filetype & EXT4_DIRENT_LUFID); -+ - } - - /* -@@ -75,11 +82,11 @@ int __ext4_check_dir_entry(const char *f - const int rlen = ext4_rec_len_from_disk(de->rec_len, - dir->i_sb->s_blocksize); - -- if (unlikely(rlen < EXT4_DIR_REC_LEN(1))) -+ if (unlikely(rlen < __EXT4_DIR_REC_LEN(1))) - error_msg = "rec_len is smaller than minimal"; - else if (unlikely(rlen % 4 != 0)) - error_msg = "rec_len % 4 != 0"; -- else if (unlikely(rlen < EXT4_DIR_REC_LEN(de->name_len))) -+ else if (unlikely(rlen < EXT4_DIR_REC_LEN(de))) - error_msg = "rec_len is too small for name_len"; - else if (unlikely(((char *) de - bh->b_data) + rlen > - dir->i_sb->s_blocksize)) -@@ -196,7 +203,7 @@ revalidate: - * failure will be detected in the - * dirent test below. */ - if (ext4_rec_len_from_disk(de->rec_len, -- sb->s_blocksize) < EXT4_DIR_REC_LEN(1)) -+ sb->s_blocksize) < __EXT4_DIR_REC_LEN(1)) - break; - i += ext4_rec_len_from_disk(de->rec_len, - sb->s_blocksize); -@@ -359,12 +366,17 @@ int ext4_htree_store_dirent(struct file - struct fname *fname, *new_fn; - struct dir_private_info *info; - int len; -+ int extra_data = 0; - - info = dir_file->private_data; - p = &info->root.rb_node; - - /* Create and allocate the fname structure */ -- len = sizeof(struct fname) + dirent->name_len + 1; -+ if (dirent->file_type & EXT4_DIRENT_LUFID) -+ extra_data = ext4_get_dirent_data_len(dirent); -+ -+ len = sizeof(struct fname) + dirent->name_len + extra_data + 1; -+ - new_fn = kzalloc(len, GFP_KERNEL); - if (!new_fn) - return -ENOMEM; -@@ -373,7 +385,7 @@ int ext4_htree_store_dirent(struct file - new_fn->inode = le32_to_cpu(dirent->inode); - new_fn->name_len = dirent->name_len; - new_fn->file_type = dirent->file_type; -- memcpy(new_fn->name, dirent->name, dirent->name_len); -+ memcpy(new_fn->name, dirent->name, dirent->name_len + extra_data); - new_fn->name[dirent->name_len] = 0; - - while (*p) { -Index: linux-3.0.101-0.5/fs/ext4/ext4.h -=================================================================== ---- linux-3.0.101-0.5.orig/fs/ext4/ext4.h -+++ linux-3.0.101-0.5/fs/ext4/ext4.h -@@ -901,6 +901,7 @@ struct ext4_inode_info { - #define EXT4_MOUNT_ERRORS_PANIC 0x00040 /* Panic on errors */ - #define EXT4_MOUNT_MINIX_DF 0x00080 /* Mimics the Minix statfs */ - #define EXT4_MOUNT_NOLOAD 0x00100 /* Don't use existing journal*/ -+#define EXT4_MOUNT_DIRDATA 0x00200 /* Data in directory entries */ - #define EXT4_MOUNT_DATA_FLAGS 0x00C00 /* Mode for data writes: */ - #define EXT4_MOUNT_JOURNAL_DATA 0x00400 /* Write data to journal */ - #define EXT4_MOUNT_ORDERED_DATA 0x00800 /* Flush data before commit */ -@@ -1407,7 +1408,9 @@ static inline void ext4_clear_state_flag - EXT4_FEATURE_INCOMPAT_EXTENTS| \ - EXT4_FEATURE_INCOMPAT_64BIT| \ - EXT4_FEATURE_INCOMPAT_FLEX_BG| \ -- EXT4_FEATURE_INCOMPAT_MMP) -+ EXT4_FEATURE_INCOMPAT_MMP| \ -+ EXT4_FEATURE_INCOMPAT_DIRDATA) -+ - #define EXT4_FEATURE_RO_COMPAT_SUPP (EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER| \ - EXT4_FEATURE_RO_COMPAT_LARGE_FILE| \ - EXT4_FEATURE_RO_COMPAT_GDT_CSUM| \ -@@ -1494,6 +1497,43 @@ struct ext4_dir_entry_2 { - #define EXT4_FT_SYMLINK 7 - - #define EXT4_FT_MAX 8 -+#define EXT4_FT_MASK 0xf -+ -+#if EXT4_FT_MAX > EXT4_FT_MASK -+#error "conflicting EXT4_FT_MAX and EXT4_FT_MASK" -+#endif -+ -+/* -+ * d_type has 4 unused bits, so it can hold four types data. these different -+ * type of data (e.g. lustre data, high 32 bits of 64-bit inode number) can be -+ * stored, in flag order, after file-name in ext4 dirent. -+*/ -+/* -+ * this flag is added to d_type if ext4 dirent has extra data after -+ * filename. this data length is variable and length is stored in first byte -+ * of data. data start after filename NUL byte. -+ * This is used by Lustre FS. -+ */ -+#define EXT4_DIRENT_LUFID 0x10 -+ -+#define EXT4_LUFID_MAGIC 0xAD200907UL -+struct ext4_dentry_param { -+ __u32 edp_magic; /* EXT4_LUFID_MAGIC */ -+ char edp_len; /* size of edp_data in bytes */ -+ char edp_data[0]; /* packed array of data */ -+} __attribute__((packed)); -+ -+static inline unsigned char *ext4_dentry_get_data(struct super_block *sb, -+ struct ext4_dentry_param* p) -+ -+{ -+ if (!EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_DIRDATA)) -+ return NULL; -+ if (p && p->edp_magic == EXT4_LUFID_MAGIC) -+ return &p->edp_len; -+ else -+ return NULL; -+} - - /* - * EXT4_DIR_PAD defines the directory entries boundaries -@@ -1502,8 +1542,11 @@ struct ext4_dir_entry_2 { - */ - #define EXT4_DIR_PAD 4 - #define EXT4_DIR_ROUND (EXT4_DIR_PAD - 1) --#define EXT4_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT4_DIR_ROUND) & \ -+#define __EXT4_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT4_DIR_ROUND) & \ - ~EXT4_DIR_ROUND) -+#define EXT4_DIR_REC_LEN(de) (__EXT4_DIR_REC_LEN(de->name_len +\ -+ ext4_get_dirent_data_len(de))) -+ - #define EXT4_MAX_REC_LEN ((1<<16)-1) - - /* -@@ -1895,7 +1938,7 @@ extern struct buffer_head * ext4_find_en - struct ext4_dir_entry_2 ** res_dir); - #define ll_ext4_find_entry(inode, dentry, res_dir) ext4_find_entry(inode, &(dentry)->d_name, res_dir) - extern int ext4_add_dot_dotdot(handle_t *handle, struct inode *dir, -- struct inode *inode); -+ struct inode *inode, const void *, const void *); - extern struct buffer_head *ext4_append(handle_t *handle, - struct inode *inode, - ext4_lblk_t *block, int *err); -@@ -2295,6 +2338,28 @@ static inline void set_bitmap_uptodate(s - extern wait_queue_head_t ext4__ioend_wq[EXT4_WQ_HASH_SZ]; - extern struct mutex ext4__aio_mutex[EXT4_WQ_HASH_SZ]; - -+/* -+ * Compute the total directory entry data length. -+ * This includes the filename and an implicit NUL terminator (always present), -+ * and optional extensions. Each extension has a bit set in the high 4 bits of -+ * de->file_type, and the extension length is the first byte in each entry. -+ */ -+static inline int ext4_get_dirent_data_len(struct ext4_dir_entry_2 *de) -+{ -+ char *len = de->name + de->name_len + 1 /* NUL terminator */; -+ int dlen = 0; -+ __u8 extra_data_flags = (de->file_type & ~EXT4_FT_MASK) >> 4; -+ -+ while (extra_data_flags) { -+ if (extra_data_flags & 1) { -+ dlen += *len + (dlen == 0); -+ len += *len; -+ } -+ extra_data_flags >>= 1; -+ } -+ return dlen; -+} -+ - #endif /* __KERNEL__ */ - - #endif /* _EXT4_H */ -Index: linux-3.0.101-0.5/fs/ext4/namei.c -=================================================================== ---- linux-3.0.101-0.5.orig/fs/ext4/namei.c -+++ linux-3.0.101-0.5/fs/ext4/namei.c -@@ -170,7 +170,8 @@ static unsigned dx_get_count(struct dx_e - static unsigned dx_get_limit(struct dx_entry *entries); - static void dx_set_count(struct dx_entry *entries, unsigned value); - static void dx_set_limit(struct dx_entry *entries, unsigned value); --static unsigned dx_root_limit(struct inode *dir, unsigned infosize); -+static inline unsigned dx_root_limit(__u32 blocksize, -+ struct ext4_dir_entry_2 *dot_de, unsigned infosize); - static unsigned dx_node_limit(struct inode *dir); - static struct dx_frame *dx_probe(const struct qstr *d_name, - struct inode *dir, -@@ -213,11 +214,12 @@ ext4_next_entry(struct ext4_dir_entry_2 - */ - struct dx_root_info * dx_get_dx_info(struct ext4_dir_entry_2 *de) - { -- /* get dotdot first */ -- de = (struct ext4_dir_entry_2 *)((char *)de + EXT4_DIR_REC_LEN(1)); -+ BUG_ON(de->name_len != 1); -+ /* get dotdot first */ -+ de = (struct ext4_dir_entry_2 *)((char *)de + EXT4_DIR_REC_LEN(de)); - -- /* dx root info is after dotdot entry */ -- de = (struct ext4_dir_entry_2 *)((char *)de + EXT4_DIR_REC_LEN(2)); -+ /* dx root info is after dotdot entry */ -+ de = (struct ext4_dir_entry_2 *)((char *)de + EXT4_DIR_REC_LEN(de)); - - return (struct dx_root_info *) de; - } -@@ -262,16 +264,23 @@ static inline void dx_set_limit(struct d - ((struct dx_countlimit *) entries)->limit = cpu_to_le16(value); - } - --static inline unsigned dx_root_limit(struct inode *dir, unsigned infosize) -+static inline unsigned dx_root_limit(__u32 blocksize, -+ struct ext4_dir_entry_2 *dot_de, unsigned infosize) - { -- unsigned entry_space = dir->i_sb->s_blocksize - EXT4_DIR_REC_LEN(1) - -- EXT4_DIR_REC_LEN(2) - infosize; -+ struct ext4_dir_entry_2 *dotdot_de; -+ unsigned entry_space; -+ -+ BUG_ON(dot_de->name_len != 1); -+ dotdot_de = ext4_next_entry(dot_de, blocksize); -+ entry_space = blocksize - EXT4_DIR_REC_LEN(dot_de) - -+ EXT4_DIR_REC_LEN(dotdot_de) - infosize; -+ - return entry_space / sizeof(struct dx_entry); - } - - static inline unsigned dx_node_limit(struct inode *dir) - { -- unsigned entry_space = dir->i_sb->s_blocksize - EXT4_DIR_REC_LEN(0); -+ unsigned entry_space = dir->i_sb->s_blocksize - __EXT4_DIR_REC_LEN(0); - return entry_space / sizeof(struct dx_entry); - } - -@@ -318,7 +327,7 @@ static struct stats dx_show_leaf(struct - printk(":%x.%u ", h.hash, - ((char *) de - base)); - } -- space += EXT4_DIR_REC_LEN(de->name_len); -+ space += EXT4_DIR_REC_LEN(de); - names++; - } - de = ext4_next_entry(de, size); -@@ -420,7 +429,8 @@ dx_probe(const struct qstr *d_name, stru - - entries = (struct dx_entry *) (((char *)info) + info->info_length); - -- if (dx_get_limit(entries) != dx_root_limit(dir, -+ if (dx_get_limit(entries) != dx_root_limit(dir->i_sb->s_blocksize, -+ (struct ext4_dir_entry_2*)bh->b_data, - info->info_length)) { - ext4_warning(dir->i_sb, "dx entry: limit != root limit"); - brelse(bh); -@@ -609,7 +619,7 @@ static int htree_dirblock_to_tree(struct - de = (struct ext4_dir_entry_2 *) bh->b_data; - top = (struct ext4_dir_entry_2 *) ((char *) de + - dir->i_sb->s_blocksize - -- EXT4_DIR_REC_LEN(0)); -+ __EXT4_DIR_REC_LEN(0)); - for (; de < top; de = ext4_next_entry(de, dir->i_sb->s_blocksize)) { - if (ext4_check_dir_entry(dir, NULL, de, bh, - (block<i_sb)) -@@ -1179,7 +1189,7 @@ dx_move_dirents(char *from, char *to, st - while (count--) { - struct ext4_dir_entry_2 *de = (struct ext4_dir_entry_2 *) - (from + (map->offs<<2)); -- rec_len = EXT4_DIR_REC_LEN(de->name_len); -+ rec_len = EXT4_DIR_REC_LEN(de); - memcpy (to, de, rec_len); - ((struct ext4_dir_entry_2 *) to)->rec_len = - ext4_rec_len_to_disk(rec_len, blocksize); -@@ -1203,7 +1213,7 @@ static struct ext4_dir_entry_2* dx_pack_ - while ((char*)de < base + blocksize) { - next = ext4_next_entry(de, blocksize); - if (de->inode && de->name_len) { -- rec_len = EXT4_DIR_REC_LEN(de->name_len); -+ rec_len = EXT4_DIR_REC_LEN(de); - if (de > to) - memmove(to, de, rec_len); - to->rec_len = ext4_rec_len_to_disk(rec_len, blocksize); -@@ -1332,11 +1342,28 @@ static int add_dirent_to_buf(handle_t *h - int namelen = dentry->d_name.len; - unsigned int offset = 0; - unsigned int blocksize = dir->i_sb->s_blocksize; -- unsigned short reclen; -- int nlen, rlen, err; -+ unsigned short reclen, dotdot_reclen = 0; -+ int nlen, rlen, err, dlen = 0; -+ int is_dotdot = 0, write_short_dotdot = 0; -+ unsigned char *data; - char *top; - -- reclen = EXT4_DIR_REC_LEN(namelen); -+ data = ext4_dentry_get_data(inode->i_sb, (struct ext4_dentry_param *) -+ dentry->d_fsdata); -+ if (data) -+ dlen = (*data) + 1; -+ -+ is_dotdot = (dentry->d_name.len == 2 && -+ memcmp(dentry->d_name.name, "..", 2) == 0); -+ -+ /* dotdot entries must be in the second place in a directory block, -+ * so calculate an alternate length without the FID so they can -+ * always be made to fit in the existing slot - LU-5626 */ -+ if (is_dotdot) -+ dotdot_reclen = __EXT4_DIR_REC_LEN(namelen); -+ -+ reclen = __EXT4_DIR_REC_LEN(namelen + dlen); -+ - if (!de) { - de = (struct ext4_dir_entry_2 *)bh->b_data; - top = bh->b_data + blocksize - reclen; -@@ -1345,10 +1372,25 @@ static int add_dirent_to_buf(handle_t *h - return -EIO; - if (ext4_match(namelen, name, de)) - return -EEXIST; -- nlen = EXT4_DIR_REC_LEN(de->name_len); -+ nlen = EXT4_DIR_REC_LEN(de); - rlen = ext4_rec_len_from_disk(de->rec_len, blocksize); -- if ((de->inode? rlen - nlen: rlen) >= reclen) -+ /* Check first for enough space for the full entry */ -+ if ((de->inode ? rlen - nlen : rlen) >= reclen) - break; -+ /* Then for dotdot entries, check for the smaller space -+ * required for just the entry, no FID */ -+ if (is_dotdot) { -+ if ((de->inode ? rlen - nlen : rlen) >= -+ dotdot_reclen) { -+ write_short_dotdot = true; -+ break; -+ } -+ /* The new ".." entry mut be written over the -+ * previous ".." entry, which is the first -+ * entry traversed by this scan. If it doesn't -+ * fit, something is badly wrong, so -EIO. */ -+ return -EIO; -+ } - de = (struct ext4_dir_entry_2 *)((char *)de + rlen); - offset += rlen; - } -@@ -1363,7 +1405,7 @@ static int add_dirent_to_buf(handle_t *h - } - - /* By now the buffer is marked for journaling */ -- nlen = EXT4_DIR_REC_LEN(de->name_len); -+ nlen = EXT4_DIR_REC_LEN(de); - rlen = ext4_rec_len_from_disk(de->rec_len, blocksize); - if (de->inode) { - struct ext4_dir_entry_2 *de1 = (struct ext4_dir_entry_2 *)((char *)de + nlen); -@@ -1379,6 +1421,13 @@ static int add_dirent_to_buf(handle_t *h - de->inode = 0; - de->name_len = namelen; - memcpy(de->name, name, namelen); -+ /* If we're writing the short form of "dotdot", don't add the data section */ -+ if (data && !write_short_dotdot) { -+ de->name[namelen] = 0; -+ memcpy(&de->name[namelen + 1], data, *(char *) data); -+ de->file_type |= EXT4_DIRENT_LUFID; -+ } -+ - /* - * XXX shouldn't update any times until successful - * completion of syscall, but too many callers depend -@@ -1475,7 +1524,8 @@ static int make_indexed_dir(handle_t *ha - - dx_set_block(entries, 1); - dx_set_count(entries, 1); -- dx_set_limit(entries, dx_root_limit(dir, sizeof(*dx_info))); -+ dx_set_limit(entries, dx_root_limit(dir->i_sb->s_blocksize, -+ dot_de, sizeof(*dx_info))); - - /* Initialize as for dx_probe */ - hinfo.hash_version = dx_info->hash_version; -@@ -1518,6 +1568,8 @@ static int ext4_update_dotdot(handle_t * - struct buffer_head * dir_block; - struct ext4_dir_entry_2 * de; - int len, journal = 0, err = 0; -+ int dlen = 0; -+ char *data; - - if (IS_ERR(handle)) - return PTR_ERR(handle); -@@ -1533,19 +1585,24 @@ static int ext4_update_dotdot(handle_t * - /* the first item must be "." */ - assert(de->name_len == 1 && de->name[0] == '.'); - len = le16_to_cpu(de->rec_len); -- assert(len >= EXT4_DIR_REC_LEN(1)); -- if (len > EXT4_DIR_REC_LEN(1)) { -+ assert(len >= __EXT4_DIR_REC_LEN(1)); -+ if (len > __EXT4_DIR_REC_LEN(1)) { - BUFFER_TRACE(dir_block, "get_write_access"); - err = ext4_journal_get_write_access(handle, dir_block); - if (err) - goto out_journal; - - journal = 1; -- de->rec_len = cpu_to_le16(EXT4_DIR_REC_LEN(1)); -+ de->rec_len = cpu_to_le16(EXT4_DIR_REC_LEN(de)); - } - -- len -= EXT4_DIR_REC_LEN(1); -- assert(len == 0 || len >= EXT4_DIR_REC_LEN(2)); -+ len -= EXT4_DIR_REC_LEN(de); -+ data = ext4_dentry_get_data(dir->i_sb, -+ (struct ext4_dentry_param *) dentry->d_fsdata); -+ if (data) -+ dlen = *data + 1; -+ assert(len == 0 || len >= __EXT4_DIR_REC_LEN(2 + dlen)); -+ - de = (struct ext4_dir_entry_2 *) - ((char *) de + le16_to_cpu(de->rec_len)); - if (!journal) { -@@ -1559,10 +1616,15 @@ static int ext4_update_dotdot(handle_t * - if (len > 0) - de->rec_len = cpu_to_le16(len); - else -- assert(le16_to_cpu(de->rec_len) >= EXT4_DIR_REC_LEN(2)); -+ assert(le16_to_cpu(de->rec_len) >= __EXT4_DIR_REC_LEN(2)); - de->name_len = 2; - strcpy (de->name, ".."); -- ext4_set_de_type(dir->i_sb, de, S_IFDIR); -+ if (data != NULL && ext4_get_dirent_data_len(de) >= dlen) { -+ de->name[2] = 0; -+ memcpy(&de->name[2 + 1], data, *data); -+ ext4_set_de_type(dir->i_sb, de, S_IFDIR); -+ de->file_type |= EXT4_DIRENT_LUFID; -+ } - - out_journal: - if (journal) { -@@ -2004,12 +2066,13 @@ retry: - /* Initialize @inode as a subdirectory of @dir, and add the - * "." and ".." entries into the first directory block. */ - int ext4_add_dot_dotdot(handle_t *handle, struct inode * dir, -- struct inode *inode) -+ struct inode *inode, -+ const void *data1, const void *data2) - { - struct buffer_head *dir_block; - struct ext4_dir_entry_2 *de; - unsigned int blocksize = dir->i_sb->s_blocksize; -- int err = 0; -+ int err = 0, dot_reclen; - - if (IS_ERR(handle)) - return PTR_ERR(handle); -@@ -2030,17 +2093,32 @@ int ext4_add_dot_dotdot(handle_t *handle - de = (struct ext4_dir_entry_2 *) dir_block->b_data; - de->inode = cpu_to_le32(inode->i_ino); - de->name_len = 1; -- de->rec_len = ext4_rec_len_to_disk(EXT4_DIR_REC_LEN(de->name_len), -- blocksize); - strcpy(de->name, "."); - ext4_set_de_type(dir->i_sb, de, S_IFDIR); -+ /* get packed fid data */ -+ data1 = ext4_dentry_get_data(dir->i_sb, -+ (struct ext4_dentry_param *) data1); -+ if (data1) { -+ de->name[1] = 0; -+ memcpy(&de->name[2], data1, *(char *) data1); -+ de->file_type |= EXT4_DIRENT_LUFID; -+ } -+ de->rec_len = cpu_to_le16(EXT4_DIR_REC_LEN(de)); -+ dot_reclen = cpu_to_le16(de->rec_len); - de = ext4_next_entry(de, blocksize); - de->inode = cpu_to_le32(dir->i_ino); -- de->rec_len = ext4_rec_len_to_disk(blocksize - EXT4_DIR_REC_LEN(1), -+ de->rec_len = ext4_rec_len_to_disk(blocksize - dot_reclen, - blocksize); - de->name_len = 2; - strcpy(de->name, ".."); - ext4_set_de_type(dir->i_sb, de, S_IFDIR); -+ data2 = ext4_dentry_get_data(dir->i_sb, -+ (struct ext4_dentry_param *) data2); -+ if (data2) { -+ de->name[2] = 0; -+ memcpy(&de->name[3], data2, *(char *) data2); -+ de->file_type |= EXT4_DIRENT_LUFID; -+ } - inode->i_nlink = 2; - BUFFER_TRACE(dir_block, "call ext4_handle_dirty_metadata"); - err = ext4_handle_dirty_metadata(handle, inode, dir_block); -@@ -2080,7 +2158,7 @@ retry: - if (IS_ERR(inode)) - goto out_stop; - -- err = ext4_add_dot_dotdot(handle, dir, inode); -+ err = ext4_add_dot_dotdot(handle, dir, inode, NULL, NULL); - if (err) - goto out_clear_inode; - err = ext4_add_entry(handle, dentry, inode); -@@ -2118,7 +2196,7 @@ static int empty_dir(struct inode *inode - int err = 0; - - sb = inode->i_sb; -- if (inode->i_size < EXT4_DIR_REC_LEN(1) + EXT4_DIR_REC_LEN(2) || -+ if (inode->i_size < __EXT4_DIR_REC_LEN(1) + __EXT4_DIR_REC_LEN(2) || - !(bh = ext4_bread(NULL, inode, 0, 0, &err))) { - if (err) - EXT4_ERROR_INODE(inode, -Index: linux-3.0.101-0.5/fs/ext4/super.c -=================================================================== ---- linux-3.0.101-0.5.orig/fs/ext4/super.c -+++ linux-3.0.101-0.5/fs/ext4/super.c -@@ -1357,6 +1357,7 @@ enum { - Opt_data_err_abort, Opt_data_err_ignore, - Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota, - Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota, -+ Opt_dirdata, - Opt_noquota, Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err, - Opt_resize, Opt_usrquota, Opt_grpquota, Opt_i_version, - Opt_stripe, Opt_delalloc, Opt_nodelalloc, Opt_mblk_io_submit, -@@ -1415,6 +1416,7 @@ static const match_table_t tokens = { - {Opt_noquota, "noquota"}, - {Opt_quota, "quota"}, - {Opt_usrquota, "usrquota"}, -+ {Opt_dirdata, "dirdata"}, - {Opt_barrier, "barrier=%u"}, - {Opt_barrier, "barrier"}, - {Opt_nobarrier, "nobarrier"}, -@@ -1818,6 +1820,9 @@ set_qf_format: - else - clear_opt(sb, BARRIER); - break; -+ case Opt_dirdata: -+ set_opt(sb, DIRDATA); -+ break; - case Opt_ignore: - break; - case Opt_resize: diff --git a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-disable-mb-cache.patch b/ldiskfs/kernel_patches/patches/sles11sp2/ext4-disable-mb-cache.patch deleted file mode 100644 index 385fb75..0000000 --- a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-disable-mb-cache.patch +++ /dev/null @@ -1,154 +0,0 @@ -Index: linux-3.0.101-0.5/fs/ext4/ext4.h -=================================================================== ---- linux-3.0.101-0.5.orig/fs/ext4/ext4.h -+++ linux-3.0.101-0.5/fs/ext4/ext4.h -@@ -893,7 +893,8 @@ struct ext4_inode_info { - /* - * Mount flags - */ --#define EXT4_MOUNT_OLDALLOC 0x00002 /* Don't use the new Orlov allocator */ -+#define EXT4_MOUNT_NO_MBCACHE 0x00001 /* Disable mbcache */ -+#define EXT4_MOUNT_OLDALLOC 0x00002 /* Don't use the new Orlov allocator */ - #define EXT4_MOUNT_GRPID 0x00004 /* Create files with directory's group */ - #define EXT4_MOUNT_DEBUG 0x00008 /* Some debugging messages */ - #define EXT4_MOUNT_ERRORS_CONT 0x00010 /* Continue on errors */ -Index: linux-3.0.101-0.5/fs/ext4/super.c -=================================================================== ---- linux-3.0.101-0.5.orig/fs/ext4/super.c -+++ linux-3.0.101-0.5/fs/ext4/super.c -@@ -1364,6 +1364,7 @@ enum { - Opt_nomblk_io_submit, Opt_block_validity, Opt_noblock_validity, - Opt_inode_readahead_blks, Opt_journal_ioprio, - Opt_dioread_nolock, Opt_dioread_lock, -+ Opt_no_mbcache, - Opt_discard, Opt_nodiscard, Opt_init_itable, Opt_noinit_itable, - }; - -@@ -1436,6 +1437,7 @@ static const match_table_t tokens = { - {Opt_noauto_da_alloc, "noauto_da_alloc"}, - {Opt_dioread_nolock, "dioread_nolock"}, - {Opt_dioread_lock, "dioread_lock"}, -+ {Opt_no_mbcache, "no_mbcache"}, - {Opt_discard, "discard"}, - {Opt_nodiscard, "nodiscard"}, - {Opt_init_itable, "init_itable=%u"}, -@@ -1934,6 +1936,9 @@ set_qf_format: - case Opt_noinit_itable: - clear_opt(sb, INIT_INODE_TABLE); - break; -+ case Opt_no_mbcache: -+ set_opt(sb, NO_MBCACHE); -+ break; - default: - ext4_msg(sb, KERN_ERR, - "Unrecognized mount option \"%s\" " -Index: linux-3.0.101-0.5/fs/ext4/xattr.c -=================================================================== ---- linux-3.0.101-0.5.orig/fs/ext4/xattr.c -+++ linux-3.0.101-0.5/fs/ext4/xattr.c -@@ -86,7 +86,8 @@ - # define ea_bdebug(f...) - #endif - --static void ext4_xattr_cache_insert(struct buffer_head *); -+static void ext4_xattr_cache_insert(struct super_block *, -+ struct buffer_head *); - static struct buffer_head *ext4_xattr_cache_find(struct inode *, - struct ext4_xattr_header *, - struct mb_cache_entry **); -@@ -332,7 +333,7 @@ bad_block: - error = -EIO; - goto cleanup; - } -- ext4_xattr_cache_insert(bh); -+ ext4_xattr_cache_insert(inode->i_sb, bh); - entry = BFIRST(bh); - error = ext4_xattr_find_entry(&entry, name_index, name, bh->b_size, 1, - inode); -@@ -492,7 +493,7 @@ ext4_xattr_block_list(struct dentry *den - error = -EIO; - goto cleanup; - } -- ext4_xattr_cache_insert(bh); -+ ext4_xattr_cache_insert(inode->i_sb, bh); - error = ext4_xattr_list_entries(dentry, BFIRST(bh), buffer, buffer_size); - - cleanup: -@@ -589,7 +590,9 @@ ext4_xattr_release_block(handle_t *handl - struct mb_cache_entry *ce = NULL; - int error = 0; - -- ce = mb_cache_entry_get(ext4_xattr_cache, bh->b_bdev, bh->b_blocknr); -+ if (!test_opt(inode->i_sb, NO_MBCACHE)) -+ ce = mb_cache_entry_get(ext4_xattr_cache, bh->b_bdev, -+ bh->b_blocknr); - error = ext4_journal_get_write_access(handle, bh); - if (error) - goto out; -@@ -992,8 +995,10 @@ ext4_xattr_block_set(handle_t *handle, s - #define header(x) ((struct ext4_xattr_header *)(x)) - - if (s->base) { -- ce = mb_cache_entry_get(ext4_xattr_cache, bs->bh->b_bdev, -- bs->bh->b_blocknr); -+ if (!test_opt(inode->i_sb, NO_MBCACHE)) -+ ce = mb_cache_entry_get(ext4_xattr_cache, -+ bs->bh->b_bdev, -+ bs->bh->b_blocknr); - error = ext4_journal_get_write_access(handle, bs->bh); - if (error) - goto cleanup; -@@ -1010,7 +1015,7 @@ ext4_xattr_block_set(handle_t *handle, s - if (!IS_LAST_ENTRY(s->first)) - ext4_xattr_rehash(header(s->base), - s->here); -- ext4_xattr_cache_insert(bs->bh); -+ ext4_xattr_cache_insert(sb, bs->bh); - } - unlock_buffer(bs->bh); - if (error == -EIO) -@@ -1093,7 +1098,8 @@ inserted: - if (error) - goto cleanup_dquot; - } -- mb_cache_entry_release(ce); -+ if (ce) -+ mb_cache_entry_release(ce); - ce = NULL; - } else if (bs->bh && s->base == bs->bh->b_data) { - /* We were modifying this block in-place. */ -@@ -1144,7 +1150,7 @@ getblk_failed: - memcpy(new_bh->b_data, s->base, new_bh->b_size); - set_buffer_uptodate(new_bh); - unlock_buffer(new_bh); -- ext4_xattr_cache_insert(new_bh); -+ ext4_xattr_cache_insert(sb, new_bh); - error = ext4_handle_dirty_metadata(handle, - inode, new_bh); - if (error) -@@ -1865,12 +1871,15 @@ ext4_xattr_put_super(struct super_block - * Returns 0, or a negative error number on failure. - */ - static void --ext4_xattr_cache_insert(struct buffer_head *bh) -+ext4_xattr_cache_insert(struct super_block *sb, struct buffer_head *bh) - { - __u32 hash = le32_to_cpu(BHDR(bh)->h_hash); - struct mb_cache_entry *ce; - int error; - -+ if (test_opt(sb, NO_MBCACHE)) -+ return; -+ - ce = mb_cache_entry_alloc(ext4_xattr_cache, GFP_NOFS); - if (!ce) { - ea_bdebug(bh, "out of memory"); -@@ -1943,6 +1952,8 @@ ext4_xattr_cache_find(struct inode *inod - __u32 hash = le32_to_cpu(header->h_hash); - struct mb_cache_entry *ce; - -+ if (test_opt(inode->i_sb, NO_MBCACHE)) -+ return NULL; - if (!header->h_hash) - return NULL; /* never share */ - ea_idebug(inode, "looking for cached blocks [%x]", (int)hash); diff --git a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-ext_generation.patch b/ldiskfs/kernel_patches/patches/sles11sp2/ext4-ext_generation.patch deleted file mode 100644 index 10fc3c7..0000000 --- a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-ext_generation.patch +++ /dev/null @@ -1,48 +0,0 @@ ---- - fs/ext4/ext4.h | 1 + - fs/ext4/ext4_extents.h | 5 +++++ - fs/ext4/extents.c | 2 ++ - 3 files changed, 8 insertions(+) - ---- a/fs/ext4/ext4.h -+++ b/fs/ext4/ext4.h -@@ -821,6 +821,7 @@ struct ext4_inode_info { - struct inode vfs_inode; - struct jbd2_inode *jinode; - -+ unsigned long i_ext_generation; - struct ext4_ext_cache i_cached_extent; - /* - * File creation time. Its function is same as that of ---- a/fs/ext4/ext4_extents.h -+++ b/fs/ext4/ext4_extents.h -@@ -193,6 +193,11 @@ static inline unsigned short ext_depth(s - return le16_to_cpu(ext_inode_hdr(inode)->eh_depth); - } - -+static inline void ext4_ext_tree_changed(struct inode *inode) -+{ -+ EXT4_I(inode)->i_ext_generation++; -+} -+ - static inline void - ext4_ext_invalidate_cache(struct inode *inode) - { ---- a/fs/ext4/extents.c -+++ b/fs/ext4/extents.c -@@ -1874,6 +1874,7 @@ cleanup: - ext4_ext_drop_refs(npath); - kfree(npath); - } -+ ext4_ext_tree_changed(inode); - ext4_ext_invalidate_cache(inode); - return err; - } -@@ -2681,6 +2682,7 @@ again: - } - } - out: -+ ext4_ext_tree_changed(inode); - ext4_ext_drop_refs(path); - kfree(path); - if (err == -EAGAIN) diff --git a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-handle-cleanup-after-quota-failure.patch b/ldiskfs/kernel_patches/patches/sles11sp2/ext4-handle-cleanup-after-quota-failure.patch deleted file mode 100644 index 4860d87..0000000 --- a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-handle-cleanup-after-quota-failure.patch +++ /dev/null @@ -1,34 +0,0 @@ -From: Jeff Mahoney -Subject: ext4: cleanup sbi->s_kobj after quota initialization failure - -If ext4_enable_quotas fails, it jumps to failed_mount7, which doesn't -tear down the kobj. If the user tries to mount the file system again, -they'll get big scary WARN_ONs from sysfs. - -Signed-off-by: Jeff Mahoney ---- - fs/ext4/super.c | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - ---- a/fs/ext4/super.c -+++ b/fs/ext4/super.c -@@ -3794,7 +3794,7 @@ no_journal: - !(sb->s_flags & MS_RDONLY)) { - ret = ext4_enable_quotas(sb); - if (ret) -- goto failed_mount7; -+ goto failed_mount8; - } - #endif /* CONFIG_QUOTA */ - -@@ -3813,6 +3813,10 @@ cantfind_ext4: - ext4_msg(sb, KERN_ERR, "VFS: Can't find ext4 filesystem"); - goto failed_mount; - -+failed_mount8: -+ kobject_del(&sbi->s_kobj); -+ kobject_put(&sbi->s_kobj); -+ wait_for_completion(&sbi->s_kobj_unregister); - failed_mount7: - ext4_unregister_li_request(sb); - failed_mount6: diff --git a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-introduce-ext4_kvmalloc-ext4_kzalloc-and-ext4_kvfree.patch b/ldiskfs/kernel_patches/patches/sles11sp2/ext4-introduce-ext4_kvmalloc-ext4_kzalloc-and-ext4_kvfree.patch deleted file mode 100644 index 30cb1e7..0000000 --- a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-introduce-ext4_kvmalloc-ext4_kzalloc-and-ext4_kvfree.patch +++ /dev/null @@ -1,120 +0,0 @@ -From 9933fc0ac1ac14b795819cd63d05ea92112f690a Mon Sep 17 00:00:00 2001 -From: Theodore Ts'o -Date: Mon, 1 Aug 2011 08:45:02 -0400 -Subject: ext4: introduce ext4_kvmalloc(), ext4_kzalloc(), and ext4_kvfree() -Git-commit: 9933fc0a -Patch-mainline: v3.1-rc1 - -Introduce new helper functions which try kmalloc, and then fall back -to vmalloc if necessary, and use them for allocating and deallocating -s_flex_groups. - -Upstream-Signed-off-by: "Theodore Ts'o" -Signed-off-by: Jeff Mahoney ---- - fs/ext4/ext4.h | 3 +++ - fs/ext4/super.c | 54 ++++++++++++++++++++++++++++++++++++------------------ - 2 files changed, 39 insertions(+), 18 deletions(-) - -diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h -index ba2009b..db9fead 100644 ---- a/fs/ext4/ext4.h -+++ b/fs/ext4/ext4.h -@@ -1874,6 +1874,9 @@ extern int ext4_group_extend(struct super_block *sb, - ext4_fsblk_t n_blocks_count); - - /* super.c */ -+extern void *ext4_kvmalloc(size_t size, gfp_t flags); -+extern void *ext4_kvzalloc(size_t size, gfp_t flags); -+extern void ext4_kvfree(void *ptr); - extern void __ext4_error(struct super_block *, const char *, unsigned int, - const char *, ...) - __attribute__ ((format (printf, 4, 5))); -diff --git a/fs/ext4/super.c b/fs/ext4/super.c -index cfe9f39..658f586 100644 ---- a/fs/ext4/super.c -+++ b/fs/ext4/super.c -@@ -110,6 +110,35 @@ static struct file_system_type ext3_fs_type = { - #define IS_EXT3_SB(sb) (0) - #endif - -+void *ext4_kvmalloc(size_t size, gfp_t flags) -+{ -+ void *ret; -+ -+ ret = kmalloc(size, flags | __GFP_NOWARN); -+ if (!ret) -+ ret = __vmalloc(size, flags, PAGE_KERNEL); -+ return ret; -+} -+ -+void *ext4_kvzalloc(size_t size, gfp_t flags) -+{ -+ void *ret; -+ -+ ret = kzalloc(size, flags | __GFP_NOWARN); -+ if (!ret) -+ ret = __vmalloc(size, flags | __GFP_ZERO, PAGE_KERNEL); -+ return ret; -+} -+ -+void ext4_kvfree(void *ptr) -+{ -+ if (is_vmalloc_addr(ptr)) -+ vfree(ptr); -+ else -+ kfree(ptr); -+ -+} -+ - ext4_fsblk_t ext4_block_bitmap(struct super_block *sb, - struct ext4_group_desc *bg) - { -@@ -791,10 +820,7 @@ static void ext4_put_super(struct super_block *sb) - for (i = 0; i < sbi->s_gdb_count; i++) - brelse(sbi->s_group_desc[i]); - kfree(sbi->s_group_desc); -- if (is_vmalloc_addr(sbi->s_flex_groups)) -- vfree(sbi->s_flex_groups); -- else -- kfree(sbi->s_flex_groups); -+ ext4_kvfree(sbi->s_flex_groups); - percpu_counter_destroy(&sbi->s_freeblocks_counter); - percpu_counter_destroy(&sbi->s_freeinodes_counter); - percpu_counter_destroy(&sbi->s_dirs_counter); -@@ -1977,15 +2003,11 @@ static int ext4_fill_flex_info(struct super_block *sb) - ((le16_to_cpu(sbi->s_es->s_reserved_gdt_blocks) + 1) << - EXT4_DESC_PER_BLOCK_BITS(sb))) / groups_per_flex; - size = flex_group_count * sizeof(struct flex_groups); -- sbi->s_flex_groups = kzalloc(size, GFP_KERNEL); -+ sbi->s_flex_groups = ext4_kvzalloc(size, GFP_KERNEL); - if (sbi->s_flex_groups == NULL) { -- sbi->s_flex_groups = vzalloc(size); -- if (sbi->s_flex_groups == NULL) { -- ext4_msg(sb, KERN_ERR, -- "not enough memory for %u flex groups", -- flex_group_count); -- goto failed; -- } -+ ext4_msg(sb, KERN_ERR, "not enough memory for %u flex groups", -+ flex_group_count); -+ goto failed; - } - - for (i = 0; i < sbi->s_groups_count; i++) { -@@ -3750,12 +3772,8 @@ failed_mount_wq: - } - failed_mount3: - del_timer(&sbi->s_err_report); -- if (sbi->s_flex_groups) { -- if (is_vmalloc_addr(sbi->s_flex_groups)) -- vfree(sbi->s_flex_groups); -- else -- kfree(sbi->s_flex_groups); -- } -+ if (sbi->s_flex_groups) -+ ext4_kvfree(sbi->s_flex_groups); - percpu_counter_destroy(&sbi->s_freeblocks_counter); - percpu_counter_destroy(&sbi->s_freeinodes_counter); - percpu_counter_destroy(&sbi->s_dirs_counter); - diff --git a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-journal-callback.patch b/ldiskfs/kernel_patches/patches/sles11sp2/ext4-journal-callback.patch deleted file mode 100644 index 6294be9..0000000 --- a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-journal-callback.patch +++ /dev/null @@ -1,455 +0,0 @@ -From 18aadd47f88464928b5ce57791c2e8f9f2aaece0 Mon Sep 17 00:00:00 2001 -From: Bobi Jam -Date: Mon, 20 Feb 2012 17:53:02 -0500 -Subject: ext4: expand commit callback and -Git-commit: 18aadd47 -Patch-mainline: v3.4-rc1 - -The per-commit callback was used by mballoc code to manage free space -bitmaps after deleted blocks have been released. This patch expands -it to support multiple different callbacks, to allow other things to -be done after the commit has been completed. - -Upstream-Signed-off-by: Bobi Jam -Upstream-Signed-off-by: Andreas Dilger -Upstream-Signed-off-by: "Theodore Ts'o" -Acked-by: Jeff Mahoney ---- - fs/ext4/ext4_jbd2.h | 72 ++++++++++++++++++++++++ - fs/ext4/mballoc.c | 155 ++++++++++++++++++++++++---------------------------- - fs/ext4/mballoc.h | 18 +++--- - fs/ext4/super.c | 18 ++++++ - 4 files changed, 173 insertions(+), 90 deletions(-) - ---- a/fs/ext4/ext4_jbd2.h -+++ b/fs/ext4/ext4_jbd2.h -@@ -104,6 +104,78 @@ - #define EXT4_MAXQUOTAS_INIT_BLOCKS(sb) (MAXQUOTAS*EXT4_QUOTA_INIT_BLOCKS(sb)) - #define EXT4_MAXQUOTAS_DEL_BLOCKS(sb) (MAXQUOTAS*EXT4_QUOTA_DEL_BLOCKS(sb)) - -+/** -+ * struct ext4_journal_cb_entry - Base structure for callback information. -+ * -+ * This struct is a 'seed' structure for a using with your own callback -+ * structs. If you are using callbacks you must allocate one of these -+ * or another struct of your own definition which has this struct -+ * as it's first element and pass it to ext4_journal_callback_add(). -+ */ -+struct ext4_journal_cb_entry { -+ /* list information for other callbacks attached to the same handle */ -+ struct list_head jce_list; -+ -+ /* Function to call with this callback structure */ -+ void (*jce_func)(struct super_block *sb, -+ struct ext4_journal_cb_entry *jce, int error); -+ -+ /* user data goes here */ -+}; -+ -+/** -+ * ext4_journal_callback_add: add a function to call after transaction commit -+ * @handle: active journal transaction handle to register callback on -+ * @func: callback function to call after the transaction has committed: -+ * @sb: superblock of current filesystem for transaction -+ * @jce: returned journal callback data -+ * @rc: journal state at commit (0 = transaction committed properly) -+ * @jce: journal callback data (internal and function private data struct) -+ * -+ * The registered function will be called in the context of the journal thread -+ * after the transaction for which the handle was created has completed. -+ * -+ * No locks are held when the callback function is called, so it is safe to -+ * call blocking functions from within the callback, but the callback should -+ * not block or run for too long, or the filesystem will be blocked waiting for -+ * the next transaction to commit. No journaling functions can be used, or -+ * there is a risk of deadlock. -+ * -+ * There is no guaranteed calling order of multiple registered callbacks on -+ * the same transaction. -+ */ -+static inline void ext4_journal_callback_add(handle_t *handle, -+ void (*func)(struct super_block *sb, -+ struct ext4_journal_cb_entry *jce, -+ int rc), -+ struct ext4_journal_cb_entry *jce) -+{ -+ struct ext4_sb_info *sbi = -+ EXT4_SB(handle->h_transaction->t_journal->j_private); -+ -+ /* Add the jce to transaction's private list */ -+ jce->jce_func = func; -+ spin_lock(&sbi->s_md_lock); -+ list_add(&jce->jce_list, &handle->h_transaction->t_private_list); -+ spin_unlock(&sbi->s_md_lock); -+} -+ -+/** -+ * ext4_journal_callback_del: delete a registered callback -+ * @handle: active journal transaction handle on which callback was registered -+ * @jce: registered journal callback entry to unregister -+ */ -+static inline void ext4_journal_callback_del(handle_t *handle, -+ struct ext4_journal_cb_entry *jce) -+{ -+ struct ext4_sb_info *sbi = -+ EXT4_SB(handle->h_transaction->t_journal->j_private); -+ -+ spin_lock(&sbi->s_md_lock); -+ list_del_init(&jce->jce_list); -+ spin_unlock(&sbi->s_md_lock); -+} -+ - int - ext4_mark_iloc_dirty(handle_t *handle, - struct inode *inode, ---- a/fs/ext4/mballoc.c -+++ b/fs/ext4/mballoc.c -@@ -21,6 +21,7 @@ - * mballoc.c contains the multiblocks allocation routines - */ - -+#include "ext4_jbd2.h" - #include "mballoc.h" - #include - #include -@@ -337,7 +338,7 @@ - */ - static struct kmem_cache *ext4_pspace_cachep; - static struct kmem_cache *ext4_ac_cachep; --static struct kmem_cache *ext4_free_ext_cachep; -+static struct kmem_cache *ext4_free_data_cachep; - - /* We create slab caches for groupinfo data structures based on the - * superblock block size. There will be one per mounted filesystem for -@@ -355,7 +356,8 @@ static void ext4_mb_generate_from_pa(str - ext4_group_t group); - static void ext4_mb_generate_from_freelist(struct super_block *sb, void *bitmap, - ext4_group_t group); --static void release_blocks_on_commit(journal_t *journal, transaction_t *txn); -+static void ext4_free_data_callback(struct super_block *sb, -+ struct ext4_journal_cb_entry *jce, int rc); - - static inline void *mb_correct_addr_and_bit(int *bit, void *addr) - { -@@ -2492,8 +2494,6 @@ int ext4_mb_init(struct super_block *sb, - proc_create_data("mb_groups", S_IRUGO, sbi->s_proc, - &ext4_mb_seq_groups_fops, sb); - -- if (sbi->s_journal) -- sbi->s_journal->j_commit_callback = release_blocks_on_commit; - out: - if (ret) { - kfree(sbi->s_mb_offsets); -@@ -2598,58 +2598,55 @@ static inline int ext4_issue_discard(str - * This function is called by the jbd2 layer once the commit has finished, - * so we know we can free the blocks that were released with that commit. - */ --static void release_blocks_on_commit(journal_t *journal, transaction_t *txn) -+static void ext4_free_data_callback(struct super_block *sb, -+ struct ext4_journal_cb_entry *jce, -+ int rc) - { -- struct super_block *sb = journal->j_private; -+ struct ext4_free_data *entry = (struct ext4_free_data *)jce; - struct ext4_buddy e4b; - struct ext4_group_info *db; - int err, count = 0, count2 = 0; -- struct ext4_free_data *entry; -- struct list_head *l, *ltmp; - -- list_for_each_safe(l, ltmp, &txn->t_private_list) { -- entry = list_entry(l, struct ext4_free_data, list); -+ mb_debug(1, "gonna free %u blocks in group %u (0x%p):", -+ entry->efd_count, entry->efd_group, entry); - -- mb_debug(1, "gonna free %u blocks in group %u (0x%p):", -- entry->count, entry->group, entry); -+ if (test_opt(sb, DISCARD)) -+ ext4_issue_discard(sb, entry->efd_group, -+ entry->efd_start_blk, entry->efd_count); -+ -+ err = ext4_mb_load_buddy(sb, entry->efd_group, &e4b); -+ /* we expect to find existing buddy because it's pinned */ -+ BUG_ON(err != 0); -+ -+ -+ db = e4b.bd_info; -+ /* there are blocks to put in buddy to make them really free */ -+ count += entry->efd_count; -+ count2++; -+ ext4_lock_group(sb, entry->efd_group); -+ /* Take it out of per group rb tree */ -+ rb_erase(&entry->efd_node, &(db->bb_free_root)); -+ mb_free_blocks(NULL, &e4b, entry->efd_start_blk, entry->efd_count); - -- if (test_opt(sb, DISCARD)) -- ext4_issue_discard(sb, entry->group, -- entry->start_blk, entry->count); -- -- err = ext4_mb_load_buddy(sb, entry->group, &e4b); -- /* we expect to find existing buddy because it's pinned */ -- BUG_ON(err != 0); -- -- db = e4b.bd_info; -- /* there are blocks to put in buddy to make them really free */ -- count += entry->count; -- count2++; -- ext4_lock_group(sb, entry->group); -- /* Take it out of per group rb tree */ -- rb_erase(&entry->node, &(db->bb_free_root)); -- mb_free_blocks(NULL, &e4b, entry->start_blk, entry->count); -+ /* -+ * Clear the trimmed flag for the group so that the next -+ * ext4_trim_fs can trim it. -+ * If the volume is mounted with -o discard, online discard -+ * is supported and the free blocks will be trimmed online. -+ */ -+ if (!test_opt(sb, DISCARD)) -+ EXT4_MB_GRP_CLEAR_TRIMMED(db); - -- /* -- * Clear the trimmed flag for the group so that the next -- * ext4_trim_fs can trim it. -- * If the volume is mounted with -o discard, online discard -- * is supported and the free blocks will be trimmed online. -+ if (!db->bb_free_root.rb_node) { -+ /* No more items in the per group rb tree -+ * balance refcounts from ext4_mb_free_metadata() - */ -- if (!test_opt(sb, DISCARD)) -- EXT4_MB_GRP_CLEAR_TRIMMED(db); -- -- if (!db->bb_free_root.rb_node) { -- /* No more items in the per group rb tree -- * balance refcounts from ext4_mb_free_metadata() -- */ -- page_cache_release(e4b.bd_buddy_page); -- page_cache_release(e4b.bd_bitmap_page); -- } -- ext4_unlock_group(sb, entry->group); -- kmem_cache_free(ext4_free_ext_cachep, entry); -- ext4_mb_unload_buddy(&e4b); -+ page_cache_release(e4b.bd_buddy_page); -+ page_cache_release(e4b.bd_bitmap_page); - } -+ ext4_unlock_group(sb, entry->efd_group); -+ kmem_cache_free(ext4_free_data_cachep, entry); -+ ext4_mb_unload_buddy(&e4b); - - mb_debug(1, "freed %u blocks in %u structures\n", count, count2); - } -@@ -2702,9 +2699,9 @@ int __init ext4_init_mballoc(void) - return -ENOMEM; - } - -- ext4_free_ext_cachep = KMEM_CACHE(ext4_free_data, -- SLAB_RECLAIM_ACCOUNT); -- if (ext4_free_ext_cachep == NULL) { -+ ext4_free_data_cachep = KMEM_CACHE(ext4_free_data, -+ SLAB_RECLAIM_ACCOUNT); -+ if (ext4_free_data_cachep == NULL) { - kmem_cache_destroy(ext4_pspace_cachep); - kmem_cache_destroy(ext4_ac_cachep); - return -ENOMEM; -@@ -2722,7 +2719,7 @@ void ext4_exit_mballoc(void) - rcu_barrier(); - kmem_cache_destroy(ext4_pspace_cachep); - kmem_cache_destroy(ext4_ac_cachep); -- kmem_cache_destroy(ext4_free_ext_cachep); -+ kmem_cache_destroy(ext4_free_data_cachep); - ext4_groupinfo_destroy_slabs(); - ext4_remove_debugfs_entry(); - } -@@ -3273,8 +3270,8 @@ static void ext4_mb_generate_from_freeli - n = rb_first(&(grp->bb_free_root)); - - while (n) { -- entry = rb_entry(n, struct ext4_free_data, node); -- mb_set_bits(bitmap, entry->start_blk, entry->count); -+ entry = rb_entry(n, struct ext4_free_data, efd_node); -+ mb_set_bits(bitmap, entry->efd_start_blk, entry->efd_count); - n = rb_next(n); - } - return; -@@ -4369,9 +4366,9 @@ out: - static int can_merge(struct ext4_free_data *entry1, - struct ext4_free_data *entry2) - { -- if ((entry1->t_tid == entry2->t_tid) && -- (entry1->group == entry2->group) && -- ((entry1->start_blk + entry1->count) == entry2->start_blk)) -+ if ((entry1->efd_tid == entry2->efd_tid) && -+ (entry1->efd_group == entry2->efd_group) && -+ ((entry1->efd_start_blk + entry1->efd_count) == entry2->efd_start_blk)) - return 1; - return 0; - } -@@ -4385,7 +4382,6 @@ ext4_mb_free_metadata(handle_t *handle, - struct ext4_free_data *entry; - struct ext4_group_info *db = e4b->bd_info; - struct super_block *sb = e4b->bd_sb; -- struct ext4_sb_info *sbi = EXT4_SB(sb); - struct rb_node **n = &db->bb_free_root.rb_node, *node; - struct rb_node *parent = NULL, *new_node; - -@@ -4393,8 +4389,8 @@ ext4_mb_free_metadata(handle_t *handle, - BUG_ON(e4b->bd_bitmap_page == NULL); - BUG_ON(e4b->bd_buddy_page == NULL); - -- new_node = &new_entry->node; -- block = new_entry->start_blk; -+ new_node = &new_entry->efd_node; -+ block = new_entry->efd_start_blk; - - if (!*n) { - /* first free block exent. We need to -@@ -4407,10 +4403,10 @@ ext4_mb_free_metadata(handle_t *handle, - } - while (*n) { - parent = *n; -- entry = rb_entry(parent, struct ext4_free_data, node); -- if (block < entry->start_blk) -+ entry = rb_entry(parent, struct ext4_free_data, efd_node); -+ if (block < entry->efd_start_blk) - n = &(*n)->rb_left; -- else if (block >= (entry->start_blk + entry->count)) -+ else if (block >= (entry->efd_start_blk + entry->efd_count)) - n = &(*n)->rb_right; - else { - ext4_grp_locked_error(sb, group, 0, -@@ -4426,34 +4422,29 @@ ext4_mb_free_metadata(handle_t *handle, - /* Now try to see the extent can be merged to left and right */ - node = rb_prev(new_node); - if (node) { -- entry = rb_entry(node, struct ext4_free_data, node); -+ entry = rb_entry(node, struct ext4_free_data, efd_node); - if (can_merge(entry, new_entry)) { -- new_entry->start_blk = entry->start_blk; -- new_entry->count += entry->count; -+ new_entry->efd_start_blk = entry->efd_start_blk; -+ new_entry->efd_count += entry->efd_count; - rb_erase(node, &(db->bb_free_root)); -- spin_lock(&sbi->s_md_lock); -- list_del(&entry->list); -- spin_unlock(&sbi->s_md_lock); -- kmem_cache_free(ext4_free_ext_cachep, entry); -+ ext4_journal_callback_del(handle, &entry->efd_jce); -+ kmem_cache_free(ext4_free_data_cachep, entry); - } - } - - node = rb_next(new_node); - if (node) { -- entry = rb_entry(node, struct ext4_free_data, node); -+ entry = rb_entry(node, struct ext4_free_data, efd_node); - if (can_merge(new_entry, entry)) { -- new_entry->count += entry->count; -+ new_entry->efd_count += entry->efd_count; - rb_erase(node, &(db->bb_free_root)); -- spin_lock(&sbi->s_md_lock); -- list_del(&entry->list); -- spin_unlock(&sbi->s_md_lock); -- kmem_cache_free(ext4_free_ext_cachep, entry); -+ ext4_journal_callback_del(handle, &entry->efd_jce); -+ kmem_cache_free(ext4_free_data_cachep, entry); - } - } - /* Add the extent to transaction's private list */ -- spin_lock(&sbi->s_md_lock); -- list_add(&new_entry->list, &handle->h_transaction->t_private_list); -- spin_unlock(&sbi->s_md_lock); -+ ext4_journal_callback_add(handle, ext4_free_data_callback, -+ &new_entry->efd_jce); - return 0; - } - -@@ -4596,16 +4587,16 @@ do_more: - * blocks being freed are metadata. these blocks shouldn't - * be used until this transaction is committed - */ -- new_entry = kmem_cache_alloc(ext4_free_ext_cachep, GFP_NOFS); -+ new_entry = kmem_cache_alloc(ext4_free_data_cachep, GFP_NOFS); - if (!new_entry) { - ext4_mb_unload_buddy(&e4b); - err = -ENOMEM; - goto error_return; - } -- new_entry->start_blk = bit; -- new_entry->group = block_group; -- new_entry->count = count; -- new_entry->t_tid = handle->h_transaction->t_tid; -+ new_entry->efd_start_blk = bit; -+ new_entry->efd_group = block_group; -+ new_entry->efd_count = count; -+ new_entry->efd_tid = handle->h_transaction->t_tid; - - ext4_lock_group(sb, block_group); - mb_clear_bits(bitmap_bh->b_data, bit, count); ---- a/fs/ext4/mballoc.h -+++ b/fs/ext4/mballoc.h -@@ -96,21 +96,23 @@ extern u8 mb_enable_debug; - - - struct ext4_free_data { -- /* this links the free block information from group_info */ -- struct rb_node node; -+ /* MUST be the first member */ -+ struct ext4_journal_cb_entry efd_jce; -+ -+ /* ext4_free_data private data starts from here */ - -- /* this links the free block information from ext4_sb_info */ -- struct list_head list; -+ /* this links the free block information from group_info */ -+ struct rb_node efd_node; - - /* group which free block extent belongs */ -- ext4_group_t group; -+ ext4_group_t efd_group; - - /* free block extent */ -- ext4_grpblk_t start_blk; -- ext4_grpblk_t count; -+ ext4_grpblk_t efd_start_blk; -+ ext4_grpblk_t efd_count; - - /* transaction which freed this extent */ -- tid_t t_tid; -+ tid_t efd_tid; - }; - - struct ext4_prealloc_space { ---- a/fs/ext4/super.c -+++ b/fs/ext4/super.c -@@ -413,6 +413,22 @@ static void save_error_info(struct super - ext4_commit_super(sb, 1); - } - -+static void ext4_journal_commit_callback(journal_t *journal, transaction_t *txn) -+{ -+ struct super_block *sb = journal->j_private; -+ struct ext4_sb_info *sbi = EXT4_SB(sb); -+ int error = is_journal_aborted(journal); -+ struct ext4_journal_cb_entry *jce, *tmp; -+ -+ spin_lock(&sbi->s_md_lock); -+ list_for_each_entry_safe(jce, tmp, &txn->t_private_list, jce_list) { -+ list_del_init(&jce->jce_list); -+ spin_unlock(&sbi->s_md_lock); -+ jce->jce_func(sb, jce, error); -+ spin_lock(&sbi->s_md_lock); -+ } -+ spin_unlock(&sbi->s_md_lock); -+} - - /* Deal with the reporting of failure conditions on a filesystem such as - * inconsistencies detected or read IO failures. -@@ -3600,6 +3616,8 @@ static int ext4_fill_super(struct super_ - } - set_task_ioprio(sbi->s_journal->j_task, journal_ioprio); - -+ sbi->s_journal->j_commit_callback = ext4_journal_commit_callback; -+ - /* - * The journal may have updated the bg summary counts, so we - * need to update the global counters. diff --git a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-kill-dx_root.patch b/ldiskfs/kernel_patches/patches/sles11sp2/ext4-kill-dx_root.patch deleted file mode 100644 index 61905e6..0000000 --- a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-kill-dx_root.patch +++ /dev/null @@ -1,229 +0,0 @@ -diff -r -u linux-stage.orig/fs/ext4/namei.c linux-stage/fs/ext4/namei.c ---- linux-stage.orig/fs/ext4/namei.c 2012-12-31 15:03:28.000000000 -0500 -+++ linux-stage/fs/ext4/namei.c 2012-12-31 15:06:16.000000000 -0500 -@@ -115,22 +115,13 @@ - * hash version mod 4 should never be 0. Sincerely, the paranoia department. - */ - --struct dx_root -+struct dx_root_info - { -- struct fake_dirent dot; -- char dot_name[4]; -- struct fake_dirent dotdot; -- char dotdot_name[4]; -- struct dx_root_info -- { -- __le32 reserved_zero; -- u8 hash_version; -- u8 info_length; /* 8 */ -- u8 indirect_levels; -- u8 unused_flags; -- } -- info; -- struct dx_entry entries[0]; -+ __le32 reserved_zero; -+ u8 hash_version; -+ u8 info_length; /* 8 */ -+ u8 indirect_levels; -+ u8 unused_flags; - }; - - struct dx_node -@@ -220,6 +211,16 @@ - * Future: use high four bits of block for coalesce-on-delete flags - * Mask them off for now. - */ -+struct dx_root_info * dx_get_dx_info(struct ext4_dir_entry_2 *de) -+{ -+ /* get dotdot first */ -+ de = (struct ext4_dir_entry_2 *)((char *)de + EXT4_DIR_REC_LEN(1)); -+ -+ /* dx root info is after dotdot entry */ -+ de = (struct ext4_dir_entry_2 *)((char *)de + EXT4_DIR_REC_LEN(2)); -+ -+ return (struct dx_root_info *) de; -+} - - static inline ext4_lblk_t dx_get_block(struct dx_entry *entry) - { -@@ -374,7 +375,7 @@ - { - unsigned count, indirect; - struct dx_entry *at, *entries, *p, *q, *m; -- struct dx_root *root; -+ struct dx_root_info * info; - struct buffer_head *bh; - struct dx_frame *frame = frame_in; - u32 hash; -@@ -382,17 +383,18 @@ - frame->bh = NULL; - if (!(bh = ext4_bread (NULL,dir, 0, 0, err))) - goto fail; -- root = (struct dx_root *) bh->b_data; -- if (root->info.hash_version != DX_HASH_TEA && -- root->info.hash_version != DX_HASH_HALF_MD4 && -- root->info.hash_version != DX_HASH_LEGACY) { -+ -+ info = dx_get_dx_info((struct ext4_dir_entry_2*)bh->b_data); -+ if (info->hash_version != DX_HASH_TEA && -+ info->hash_version != DX_HASH_HALF_MD4 && -+ info->hash_version != DX_HASH_LEGACY) { - ext4_warning(dir->i_sb, "Unrecognised inode hash code %d for directory " -- "#%lu", root->info.hash_version, dir->i_ino); -+ "#%lu", info->hash_version, dir->i_ino); - brelse(bh); - *err = ERR_BAD_DX_DIR; - goto fail; - } -- hinfo->hash_version = root->info.hash_version; -+ hinfo->hash_version = info->hash_version; - if (hinfo->hash_version <= DX_HASH_TEA) - hinfo->hash_version += EXT4_SB(dir->i_sb)->s_hash_unsigned; - hinfo->seed = EXT4_SB(dir->i_sb)->s_hash_seed; -@@ -400,27 +402,26 @@ - ext4fs_dirhash(d_name->name, d_name->len, hinfo); - hash = hinfo->hash; - -- if (root->info.unused_flags & 1) { -+ if (info->unused_flags & 1) { - ext4_warning(dir->i_sb, "Unimplemented inode hash flags: %#06x", -- root->info.unused_flags); -+ info->unused_flags); - brelse(bh); - *err = ERR_BAD_DX_DIR; - goto fail; - } - -- if ((indirect = root->info.indirect_levels) > 1) { -+ if ((indirect = info->indirect_levels) > 1) { - ext4_warning(dir->i_sb, "Unimplemented inode hash depth: %#06x", -- root->info.indirect_levels); -+ info->indirect_levels); - brelse(bh); - *err = ERR_BAD_DX_DIR; - goto fail; - } - -- entries = (struct dx_entry *) (((char *)&root->info) + -- root->info.info_length); -+ entries = (struct dx_entry *) (((char *)info) + info->info_length); - - if (dx_get_limit(entries) != dx_root_limit(dir, -- root->info.info_length)) { -+ info->info_length)) { - ext4_warning(dir->i_sb, "dx entry: limit != root limit"); - brelse(bh); - *err = ERR_BAD_DX_DIR; -@@ -501,10 +502,12 @@ - - static void dx_release (struct dx_frame *frames) - { -+ struct dx_root_info *info; - if (frames[0].bh == NULL) - return; - -- if (((struct dx_root *) frames[0].bh->b_data)->info.indirect_levels) -+ info = dx_get_dx_info((struct ext4_dir_entry_2*)frames[0].bh->b_data); -+ if (info->indirect_levels) - brelse(frames[1].bh); - brelse(frames[0].bh); - } -@@ -1400,17 +1403,16 @@ - const char *name = dentry->d_name.name; - int namelen = dentry->d_name.len; - struct buffer_head *bh2; -- struct dx_root *root; - struct dx_frame frames[2], *frame; - struct dx_entry *entries; -- struct ext4_dir_entry_2 *de, *de2; -+ struct ext4_dir_entry_2 *de, *de2, *dot_de, *dotdot_de; - char *data1, *top; - unsigned len; - int retval; - unsigned blocksize; - struct dx_hash_info hinfo; - ext4_lblk_t block; -- struct fake_dirent *fde; -+ struct dx_root_info *dx_info; - - blocksize = dir->i_sb->s_blocksize; - dxtrace(printk(KERN_DEBUG "Creating index: inode %lu\n", dir->i_ino)); -@@ -1420,18 +1422,19 @@ - brelse(bh); - return retval; - } -- root = (struct dx_root *) bh->b_data; -+ -+ dot_de = (struct ext4_dir_entry_2 *) bh->b_data; -+ dotdot_de = ext4_next_entry(dot_de, blocksize); - - /* The 0th block becomes the root, move the dirents out */ -- fde = &root->dotdot; -- de = (struct ext4_dir_entry_2 *)((char *)fde + -- ext4_rec_len_from_disk(fde->rec_len, blocksize)); -- if ((char *) de >= (((char *) root) + blocksize)) { -+ de = (struct ext4_dir_entry_2 *)((char *)dotdot_de + -+ ext4_rec_len_from_disk(dotdot_de->rec_len, blocksize)); -+ if ((char *) de >= (((char *) dot_de) + blocksize)) { - EXT4_ERROR_INODE(dir, "invalid rec_len for '..'"); - brelse(bh); - return -EIO; - } -- len = ((char *) root) + blocksize - (char *) de; -+ len = ((char *) dot_de) + blocksize - (char *) de; - - /* Allocate new block for the 0th block's dirents */ - bh2 = ext4_append(handle, dir, &block, &retval); -@@ -1450,19 +1453,23 @@ - de->rec_len = ext4_rec_len_to_disk(data1 + blocksize - (char *) de, - blocksize); - /* Initialize the root; the dot dirents already exist */ -- de = (struct ext4_dir_entry_2 *) (&root->dotdot); -- de->rec_len = ext4_rec_len_to_disk(blocksize - EXT4_DIR_REC_LEN(2), -- blocksize); -- memset (&root->info, 0, sizeof(root->info)); -- root->info.info_length = sizeof(root->info); -- root->info.hash_version = EXT4_SB(dir->i_sb)->s_def_hash_version; -- entries = root->entries; -+ dotdot_de->rec_len = ext4_rec_len_to_disk(blocksize - -+ le16_to_cpu(dot_de->rec_len), blocksize); -+ -+ /* initialize hashing info */ -+ dx_info = dx_get_dx_info(dot_de); -+ memset (dx_info, 0, sizeof(*dx_info)); -+ dx_info->info_length = sizeof(*dx_info); -+ dx_info->hash_version = EXT4_SB(dir->i_sb)->s_def_hash_version; -+ -+ entries = (void *)dx_info + sizeof(*dx_info); -+ - dx_set_block(entries, 1); - dx_set_count(entries, 1); -- dx_set_limit(entries, dx_root_limit(dir, sizeof(root->info))); -+ dx_set_limit(entries, dx_root_limit(dir, sizeof(*dx_info))); - - /* Initialize as for dx_probe */ -- hinfo.hash_version = root->info.hash_version; -+ hinfo.hash_version = dx_info->hash_version; - if (hinfo.hash_version <= DX_HASH_TEA) - hinfo.hash_version += EXT4_SB(dir->i_sb)->s_hash_unsigned; - hinfo.seed = EXT4_SB(dir->i_sb)->s_hash_seed; -@@ -1723,6 +1730,7 @@ - goto journal_error; - brelse (bh2); - } else { -+ struct dx_root_info * info; - dxtrace(printk(KERN_DEBUG - "Creating second level index...\n")); - memcpy((char *) entries2, (char *) entries, -@@ -1732,7 +1740,9 @@ - /* Set up root */ - dx_set_count(entries, 1); - dx_set_block(entries + 0, newblock); -- ((struct dx_root *) frames[0].bh->b_data)->info.indirect_levels = 1; -+ info = dx_get_dx_info((struct ext4_dir_entry_2*) -+ frames[0].bh->b_data); -+ info->indirect_levels = 1; - - /* Add new access path frame */ - frame = frames + 1; diff --git a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-large-dir.patch b/ldiskfs/kernel_patches/patches/sles11sp2/ext4-large-dir.patch deleted file mode 100644 index 3ef66c1..0000000 --- a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-large-dir.patch +++ /dev/null @@ -1,364 +0,0 @@ -This INCOMPAT_LARGEDIR feature allows larger directories -to be created in ldiskfs, both with directory sizes over -2GB and and a maximum htree depth of 3 instead of the -current limit of 2. These features are needed in order -to exceed the current limit of approximately 10M entries -in a single directory. - -Index: linux-2.6.32-504.3.3.el6.x86_64/fs/ext4/ext4.h -=================================================================== ---- linux-2.6.32-504.3.3.el6.x86_64.orig/fs/ext4/ext4.h -+++ linux-2.6.32-504.3.3.el6.x86_64/fs/ext4/ext4.h -@@ -1344,6 +1344,7 @@ EXT4_INODE_BIT_FNS(state, state_flags) - #define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200 - #define EXT4_FEATURE_INCOMPAT_EA_INODE 0x0400 - #define EXT4_FEATURE_INCOMPAT_DIRDATA 0x1000 /* data in dirent */ -+#define EXT4_FEATURE_INCOMPAT_LARGEDIR 0x4000 - - #define EXT4_FEATURE_COMPAT_SUPP EXT2_FEATURE_COMPAT_EXT_ATTR - #define EXT4_FEATURE_INCOMPAT_SUPP (EXT4_FEATURE_INCOMPAT_FILETYPE| \ -@@ -1354,7 +1355,8 @@ EXT4_INODE_BIT_FNS(state, state_flags) - EXT4_FEATURE_INCOMPAT_FLEX_BG| \ - EXT4_FEATURE_INCOMPAT_EA_INODE| \ - EXT4_FEATURE_INCOMPAT_MMP| \ -- EXT4_FEATURE_INCOMPAT_DIRDATA) -+ EXT4_FEATURE_INCOMPAT_DIRDATA| \ -+ EXT4_FEATURE_INCOMPAT_LARGEDIR) - - #define EXT4_FEATURE_RO_COMPAT_SUPP (EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER| \ - EXT4_FEATURE_RO_COMPAT_LARGE_FILE| \ -@@ -1612,6 +1614,17 @@ ext4_group_first_block_no(struct super_b - */ - #define ERR_BAD_DX_DIR -75000 - -+/* htree levels for ext4 */ -+#define EXT4_HTREE_LEVEL_COMPAT 2 -+#define EXT4_HTREE_LEVEL 3 -+ -+static inline int -+ext4_dir_htree_level(struct super_block *sb) -+{ -+ return EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_LARGEDIR) ? -+ EXT4_HTREE_LEVEL : EXT4_HTREE_LEVEL_COMPAT; -+} -+ - void ext4_get_group_no_and_offset(struct super_block *sb, ext4_fsblk_t blocknr, - ext4_group_t *blockgrpp, ext4_grpblk_t *offsetp); - -@@ -2005,13 +2018,15 @@ static inline void ext4_r_blocks_count_s - es->s_r_blocks_count_hi = cpu_to_le32(blk >> 32); - } - --static inline loff_t ext4_isize(struct ext4_inode *raw_inode) -+static inline loff_t ext4_isize(struct super_block *sb, -+ struct ext4_inode *raw_inode) - { -- if (S_ISREG(le16_to_cpu(raw_inode->i_mode))) -+ if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_LARGEDIR) || -+ S_ISREG(le16_to_cpu(raw_inode->i_mode))) - return ((loff_t)le32_to_cpu(raw_inode->i_size_high) << 32) | - le32_to_cpu(raw_inode->i_size_lo); -- else -- return (loff_t) le32_to_cpu(raw_inode->i_size_lo); -+ -+ return (loff_t) le32_to_cpu(raw_inode->i_size_lo); - } - - static inline void ext4_isize_set(struct ext4_inode *raw_inode, loff_t i_size) -Index: linux-2.6.32-504.3.3.el6.x86_64/fs/ext4/inode.c -=================================================================== ---- linux-2.6.32-504.3.3.el6.x86_64.orig/fs/ext4/inode.c -+++ linux-2.6.32-504.3.3.el6.x86_64/fs/ext4/inode.c -@@ -5470,7 +5470,7 @@ struct inode *ext4_iget(struct super_blo - if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_64BIT)) - ei->i_file_acl |= - ((__u64)le16_to_cpu(raw_inode->i_file_acl_high)) << 32; -- inode->i_size = ext4_isize(raw_inode); -+ inode->i_size = ext4_isize(sb, raw_inode); - ei->i_disksize = inode->i_size; - #ifdef CONFIG_QUOTA - ei->i_reserved_quota = 0; -@@ -5654,7 +5654,7 @@ static int ext4_do_update_inode(handle_t - raw_inode->i_file_acl_high = - cpu_to_le16(ei->i_file_acl >> 32); - raw_inode->i_file_acl_lo = cpu_to_le32(ei->i_file_acl); -- if (ei->i_disksize != ext4_isize(raw_inode)) { -+ if (ei->i_disksize != ext4_isize(inode->i_sb, raw_inode)) { - ext4_isize_set(raw_inode, ei->i_disksize); - need_datasync = 1; - } -Index: linux-2.6.32-504.3.3.el6.x86_64/fs/ext4/namei.c -=================================================================== ---- linux-2.6.32-504.3.3.el6.x86_64.orig/fs/ext4/namei.c -+++ linux-2.6.32-504.3.3.el6.x86_64/fs/ext4/namei.c -@@ -225,7 +225,7 @@ struct dx_root_info * dx_get_dx_info(str - - static inline ext4_lblk_t dx_get_block(struct dx_entry *entry) - { -- return le32_to_cpu(entry->block) & 0x00ffffff; -+ return le32_to_cpu(entry->block) & 0x0fffffff; - } - - static inline void dx_set_block(struct dx_entry *entry, ext4_lblk_t value) -@@ -388,7 +388,7 @@ dx_probe(const struct qstr *d_name, stru - struct dx_frame *frame = frame_in; - u32 hash; - -- frame->bh = NULL; -+ memset(frame_in, 0, EXT4_HTREE_LEVEL * sizeof(frame_in[0])); - if (!(bh = ext4_bread (NULL,dir, 0, 0, err))) - goto fail; - -@@ -418,9 +418,16 @@ dx_probe(const struct qstr *d_name, stru - goto fail; - } - -- if ((indirect = info->indirect_levels) > 1) { -- ext4_warning(dir->i_sb, "Unimplemented inode hash depth: %#06x", -- info->indirect_levels); -+ indirect = info->indirect_levels; -+ if (indirect >= ext4_dir_htree_level(dir->i_sb)) { -+ ext4_warning(dir->i_sb, -+ "Directory (ino: %lu) htree depth %#06x exceed " -+ "supported value", dir->i_ino, -+ ext4_dir_htree_level(dir->i_sb)); -+ if (ext4_dir_htree_level(dir->i_sb) < EXT4_HTREE_LEVEL) { -+ ext4_warning(dir->i_sb, "Enable large directory " -+ "feature to access it"); -+ } - brelse(bh); - *err = ERR_BAD_DX_DIR; - goto fail; -@@ -512,13 +519,18 @@ fail: - static void dx_release (struct dx_frame *frames) - { - struct dx_root_info *info; -+ int i; -+ - if (frames[0].bh == NULL) - return; - - info = dx_get_dx_info((struct ext4_dir_entry_2*)frames[0].bh->b_data); -- if (info->indirect_levels) -- brelse(frames[1].bh); -- brelse(frames[0].bh); -+ for (i = 0; i <= info->indirect_levels; i++) { -+ if (frames[i].bh == NULL) -+ break; -+ brelse(frames[i].bh); -+ frames[i].bh = NULL; -+ } - } - - /* -@@ -661,7 +673,7 @@ int ext4_htree_fill_tree(struct file *di - { - struct dx_hash_info hinfo; - struct ext4_dir_entry_2 *de; -- struct dx_frame frames[2], *frame; -+ struct dx_frame frames[EXT4_HTREE_LEVEL], *frame; - struct inode *dir; - ext4_lblk_t block; - int count = 0; -@@ -1003,7 +1015,7 @@ static struct buffer_head * ext4_dx_find - struct super_block * sb; - struct dx_hash_info hinfo; - u32 hash; -- struct dx_frame frames[2], *frame; -+ struct dx_frame frames[EXT4_HTREE_LEVEL], *frame; - struct buffer_head *bh; - ext4_lblk_t block; - struct ext4_dir_entry_2 *de, *top; -@@ -1443,7 +1455,7 @@ static int add_dirent_to_buf(handle_t *h - */ - dir->i_mtime = dir->i_ctime = ext4_current_time(dir); - ext4_update_dx_flag(dir); -- dir->i_version++; -+ inode_inc_iversion(dir); - ext4_mark_inode_dirty(handle, dir); - BUFFER_TRACE(bh, "call ext4_handle_dirty_metadata"); - err = ext4_handle_dirty_metadata(handle, dir, bh); -@@ -1463,7 +1475,7 @@ static int make_indexed_dir(handle_t *ha - const char *name = dentry->d_name.name; - int namelen = dentry->d_name.len; - struct buffer_head *bh2; -- struct dx_frame frames[2], *frame; -+ struct dx_frame frames[EXT4_HTREE_LEVEL], *frame; - struct dx_entry *entries; - struct ext4_dir_entry_2 *de, *de2, *dot_de, *dotdot_de; - char *data1, *top; -@@ -1712,15 +1724,18 @@ static int ext4_add_entry(handle_t *hand - static int ext4_dx_add_entry(handle_t *handle, struct dentry *dentry, - struct inode *inode) - { -- struct dx_frame frames[2], *frame; -+ struct dx_frame frames[EXT4_HTREE_LEVEL], *frame; - struct dx_entry *entries, *at; - struct dx_hash_info hinfo; - struct buffer_head *bh; - struct inode *dir = dentry->d_parent->d_inode; - struct super_block *sb = dir->i_sb; - struct ext4_dir_entry_2 *de; -+ int restart; - int err; - -+again: -+ restart = 0; - frame = dx_probe(&dentry->d_name, dir, &hinfo, frames, &err); - if (!frame) - return err; -@@ -1730,33 +1745,48 @@ static int ext4_dx_add_entry(handle_t *h - if (!(bh = ext4_bread(handle,dir, dx_get_block(frame->at), 0, &err))) - goto cleanup; - -- BUFFER_TRACE(bh, "get_write_access"); -- err = ext4_journal_get_write_access(handle, bh); -- if (err) -- goto journal_error; -- - err = add_dirent_to_buf(handle, dentry, inode, NULL, bh); - if (err != -ENOSPC) - goto cleanup; - -+ err = 0; - /* Block full, should compress but for now just split */ - dxtrace(printk(KERN_DEBUG "using %u of %u node entries\n", - dx_get_count(entries), dx_get_limit(entries))); - /* Need to split index? */ - if (dx_get_count(entries) == dx_get_limit(entries)) { - ext4_lblk_t newblock; -- unsigned icount = dx_get_count(entries); -- int levels = frame - frames; -+ int levels = frame - frames + 1; -+ unsigned icount; -+ int add_level = 1; - struct dx_entry *entries2; - struct dx_node *node2; - struct buffer_head *bh2; - -- if (levels && (dx_get_count(frames->entries) == -- dx_get_limit(frames->entries))) { -- ext4_warning(sb, "Directory index full!"); -+ while (frame > frames) { -+ if (dx_get_count((frame - 1)->entries) < -+ dx_get_limit((frame - 1)->entries)) { -+ add_level = 0; -+ break; -+ } -+ frame--; /* split higher index block */ -+ at = frame->at; -+ entries = frame->entries; -+ restart = 1; -+ } -+ if (add_level && levels == ext4_dir_htree_level(sb)) { -+ ext4_warning(sb, "Directory (ino: %lu) index full, " -+ "reach max htree level :%d", -+ dir->i_ino, levels); -+ if (ext4_dir_htree_level(sb) < EXT4_HTREE_LEVEL) { -+ ext4_warning(sb, "Large directory feature is" -+ "not enabled on this " -+ "filesystem"); -+ } - err = -ENOSPC; - goto cleanup; - } -+ icount = dx_get_count(entries); - bh2 = ext4_append (handle, dir, &newblock, &err); - if (!(bh2)) - goto cleanup; -@@ -1769,7 +1799,7 @@ static int ext4_dx_add_entry(handle_t *h - err = ext4_journal_get_write_access(handle, frame->bh); - if (err) - goto journal_error; -- if (levels) { -+ if (!add_level) { - unsigned icount1 = icount/2, icount2 = icount - icount1; - unsigned hash2 = dx_get_hash(entries + icount1); - dxtrace(printk(KERN_DEBUG "Split index %i/%i\n", -@@ -1777,7 +1807,7 @@ static int ext4_dx_add_entry(handle_t *h - - BUFFER_TRACE(frame->bh, "get_write_access"); /* index root */ - err = ext4_journal_get_write_access(handle, -- frames[0].bh); -+ (frame - 1)->bh); - if (err) - goto journal_error; - -@@ -1793,18 +1823,24 @@ static int ext4_dx_add_entry(handle_t *h - frame->entries = entries = entries2; - swap(frame->bh, bh2); - } -- dx_insert_block(frames + 0, hash2, newblock); -- dxtrace(dx_show_index("node", frames[1].entries)); -+ dx_insert_block((frame - 1), hash2, newblock); -+ dxtrace(dx_show_index("node", frame->entries)); - dxtrace(dx_show_index("node", - ((struct dx_node *) bh2->b_data)->entries)); - err = ext4_handle_dirty_metadata(handle, dir, bh2); - if (err) - goto journal_error; - brelse (bh2); -+ ext4_handle_dirty_metadata(handle, dir, -+ (frame - 1)->bh); -+ if (restart) { -+ ext4_handle_dirty_metadata(handle, dir, -+ frame->bh); -+ goto cleanup; -+ } - } else { - struct dx_root_info * info; -- dxtrace(printk(KERN_DEBUG -- "Creating second level index...\n")); -+ - memcpy((char *) entries2, (char *) entries, - icount * sizeof(struct dx_entry)); - dx_set_limit(entries2, dx_node_limit(dir)); -@@ -1814,19 +1850,16 @@ static int ext4_dx_add_entry(handle_t *h - dx_set_block(entries + 0, newblock); - info = dx_get_dx_info((struct ext4_dir_entry_2*) - frames[0].bh->b_data); -- info->indirect_levels = 1; -- -- /* Add new access path frame */ -- frame = frames + 1; -- frame->at = at = at - entries + entries2; -- frame->entries = entries = entries2; -- frame->bh = bh2; -- err = ext4_journal_get_write_access(handle, -- frame->bh); -- if (err) -- goto journal_error; -+ info->indirect_levels += 1; -+ dxtrace(printk(KERN_DEBUG -+ "Creating %d level index...\n", -+ info->indirect_levels)); -+ ext4_handle_dirty_metadata(handle, dir, frame->bh); -+ ext4_handle_dirty_metadata(handle, dir, bh2); -+ brelse(bh2); -+ restart = 1; -+ goto cleanup; - } -- err = ext4_handle_dirty_metadata(handle, dir, frames[0].bh); - if (err) { - ext4_std_error(inode->i_sb, err); - goto cleanup; -@@ -1840,6 +1873,10 @@ cleanup: - if (bh) - brelse(bh); - dx_release(frames); -+ /* @restart is true means htree-path has been changed, we need to -+ * repeat dx_probe() to find out valid htree-path */ -+ if (restart && err == 0) -+ goto again; - return err; - } - -@@ -1874,7 +1911,7 @@ int ext4_delete_entry(handle_t *handle, - blocksize); - else - de->inode = 0; -- dir->i_version++; -+ inode_inc_iversion(dir); - BUFFER_TRACE(bh, "call ext4_handle_dirty_metadata"); - ext4_handle_dirty_metadata(handle, dir, bh); - return 0; diff --git a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-large-eas.patch b/ldiskfs/kernel_patches/patches/sles11sp2/ext4-large-eas.patch deleted file mode 100644 index 38e5ff5..0000000 --- a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-large-eas.patch +++ /dev/null @@ -1,1040 +0,0 @@ -This patch implements the large EA support in ext4. If the size of -an EA value is larger than the blocksize, then the EA value would -not be saved in the external EA block, instead it would be saved -in an external EA inode. So, the patch also helps support a larger -number of EAs. - -Index: linux-stage/fs/ext4/ext4.h -=================================================================== ---- linux-stage.orig/fs/ext4/ext4.h -+++ linux-stage/fs/ext4/ext4.h -@@ -1408,6 +1408,7 @@ static inline void ext4_clear_state_flag - EXT4_FEATURE_INCOMPAT_EXTENTS| \ - EXT4_FEATURE_INCOMPAT_64BIT| \ - EXT4_FEATURE_INCOMPAT_FLEX_BG| \ -+ EXT4_FEATURE_INCOMPAT_EA_INODE| \ - EXT4_FEATURE_INCOMPAT_MMP| \ - EXT4_FEATURE_INCOMPAT_DIRDATA) - -@@ -1775,6 +1782,10 @@ struct mmpd_data { - # define ATTRIB_NORET __attribute__((noreturn)) - # define NORET_AND noreturn, - -+struct ext4_xattr_ino_array { -+ unsigned int xia_count; /* # of used item in the array */ -+ unsigned int xia_inodes[0]; -+}; - /* bitmap.c */ - extern unsigned int ext4_count_free(char *bitmap, unsigned numchars); - -@@ -1893,6 +1904,7 @@ extern void ext4_set_inode_flags(struct - extern void ext4_get_inode_flags(struct ext4_inode_info *); - extern int ext4_alloc_da_blocks(struct inode *inode); - extern void ext4_set_aops(struct inode *inode); -+extern int ext4_meta_trans_blocks(struct inode *, int nrblocks, int chunk); - extern int ext4_writepage_trans_blocks(struct inode *); - extern int ext4_chunk_trans_blocks(struct inode *, int nrblocks); - extern int ext4_block_truncate_page(handle_t *handle, -Index: linux-stage/fs/ext4/inode.c -=================================================================== ---- linux-stage.orig/fs/ext4/inode.c -+++ linux-stage/fs/ext4/inode.c -@@ -187,6 +187,8 @@ void ext4_evict_inode(struct inode *inod - { - handle_t *handle; - int err; -+ int extra_credits = 3; -+ struct ext4_xattr_ino_array *lea_ino_array = NULL; - - trace_ext4_evict_inode(inode); - -@@ -207,7 +209,10 @@ void ext4_evict_inode(struct inode *inod - if (is_bad_inode(inode)) - goto no_delete; - -- handle = ext4_journal_start(inode, blocks_for_truncate(inode)+3); -+ /* -+ * Delete xattr inode before deleting the main inode. -+ */ -+ handle = ext4_journal_start(inode, extra_credits); - if (IS_ERR(handle)) { - ext4_std_error(inode->i_sb, PTR_ERR(handle)); - /* -@@ -218,9 +223,33 @@ void ext4_evict_inode(struct inode *inod - ext4_orphan_del(NULL, inode); - goto no_delete; - } -- - if (IS_SYNC(inode)) - ext4_handle_sync(handle); -+ -+ err = ext4_xattr_delete_inode(handle, inode, &lea_ino_array); -+ if (err) { -+ ext4_warning(inode->i_sb, -+ "couldn't delete inode's xattr (err %d)", err); -+ goto stop_handle; -+ } -+ -+ if (!IS_NOQUOTA(inode)) -+ extra_credits += 2 * EXT4_QUOTA_DEL_BLOCKS(inode->i_sb); -+ -+ if (!ext4_handle_has_enough_credits(handle, -+ blocks_for_truncate(inode) + extra_credits)) { -+ err = ext4_journal_extend(handle, -+ blocks_for_truncate(inode) + extra_credits); -+ if (err > 0) -+ err = ext4_journal_restart(handle, -+ blocks_for_truncate(inode) + extra_credits); -+ if (err != 0) { -+ ext4_warning(inode->i_sb, -+ "couldn't extend journal (err %d)", err); -+ goto stop_handle; -+ } -+ } -+ - inode->i_size = 0; - err = ext4_mark_inode_dirty(handle, inode); - if (err) { -@@ -237,10 +266,10 @@ void ext4_evict_inode(struct inode *inod - * enough credits left in the handle to remove the inode from - * the orphan list and set the dtime field. - */ -- if (!ext4_handle_has_enough_credits(handle, 3)) { -- err = ext4_journal_extend(handle, 3); -+ if (!ext4_handle_has_enough_credits(handle, extra_credits)) { -+ err = ext4_journal_extend(handle, extra_credits); - if (err > 0) -- err = ext4_journal_restart(handle, 3); -+ err = ext4_journal_restart(handle, extra_credits); - if (err != 0) { - ext4_warning(inode->i_sb, - "couldn't extend journal (err %d)", err); -@@ -274,7 +303,11 @@ void ext4_evict_inode(struct inode *inod - ext4_clear_inode(inode); - else - ext4_free_inode(handle, inode); -+ - ext4_journal_stop(handle); -+ -+ if (lea_ino_array != NULL) -+ ext4_xattr_inode_array_free(inode, lea_ino_array); - return; - no_delete: - ext4_clear_inode(inode); /* We must guarantee clearing of inode... */ -@@ -5552,7 +5585,7 @@ static int ext4_index_trans_blocks(struc - * - * Also account for superblock, inode, quota and xattr blocks - */ --static int ext4_meta_trans_blocks(struct inode *inode, int nrblocks, int chunk) -+int ext4_meta_trans_blocks(struct inode *inode, int nrblocks, int chunk) - { - ext4_group_t groups, ngroups = ext4_get_groups_count(inode->i_sb); - int gdpblocks; -Index: linux-stage/fs/ext4/xattr.c -=================================================================== ---- linux-stage.orig/fs/ext4/xattr.c -+++ linux-stage/fs/ext4/xattr.c -@@ -168,19 +168,26 @@ ext4_xattr_check_block(struct buffer_hea - } - - static inline int --ext4_xattr_check_entry(struct ext4_xattr_entry *entry, size_t size) -+ext4_xattr_check_entry(struct ext4_xattr_entry *entry, size_t size, -+ struct inode *inode) - { - size_t value_size = le32_to_cpu(entry->e_value_size); - -- if (entry->e_value_block != 0 || value_size > size || -+ if (!entry->e_value_inum && - le16_to_cpu(entry->e_value_offs) + value_size > size) -+ return -EIO; -+ if (entry->e_value_inum && -+ (le32_to_cpu(entry->e_value_inum) < EXT4_FIRST_INO(inode->i_sb) || -+ le32_to_cpu(entry->e_value_inum) > -+ le32_to_cpu(EXT4_SB(inode->i_sb)->s_es->s_inodes_count))) - return -EIO; - return 0; - } - - static int - ext4_xattr_find_entry(struct ext4_xattr_entry **pentry, int name_index, -- const char *name, size_t size, int sorted) -+ const char *name, size_t size, int sorted, -+ struct inode *inode) - { - struct ext4_xattr_entry *entry; - size_t name_len; -@@ -200,11 +207,104 @@ ext4_xattr_find_entry(struct ext4_xattr_ - break; - } - *pentry = entry; -- if (!cmp && ext4_xattr_check_entry(entry, size)) -+ if (!cmp && ext4_xattr_check_entry(entry, size, inode)) - return -EIO; - return cmp ? -ENODATA : 0; - } - -+/* -+ * Read the EA value from an inode. -+ */ -+static int -+ext4_xattr_inode_read(struct inode *ea_inode, void *buf, size_t *size) -+{ -+ unsigned long block = 0; -+ struct buffer_head *bh = NULL; -+ int err, blocksize; -+ size_t csize, ret_size = 0; -+ -+ if (*size == 0) -+ return 0; -+ -+ blocksize = ea_inode->i_sb->s_blocksize; -+ -+ while (ret_size < *size) { -+ csize = (*size - ret_size) > blocksize ? blocksize : -+ *size - ret_size; -+ bh = ext4_bread(NULL, ea_inode, block, 0, &err); -+ if (!bh) { -+ *size = ret_size; -+ return err; -+ } -+ memcpy(buf, bh->b_data, csize); -+ brelse(bh); -+ -+ buf += csize; -+ block += 1; -+ ret_size += csize; -+ } -+ -+ *size = ret_size; -+ -+ return err; -+} -+ -+struct inode *ext4_xattr_inode_iget(struct inode *parent, unsigned long ea_ino, int *err) -+{ -+ struct inode *ea_inode = NULL; -+ -+ ea_inode = ext4_iget(parent->i_sb, ea_ino); -+ if (IS_ERR(ea_inode) || is_bad_inode(ea_inode)) { -+ int rc = IS_ERR(ea_inode) ? PTR_ERR(ea_inode) : 0; -+ ext4_error(parent->i_sb, "error while reading EA inode %lu " -+ "/ %d %d", ea_ino, rc, is_bad_inode(ea_inode)); -+ *err = rc != 0 ? rc : -EIO; -+ return NULL; -+ } -+ -+ if (EXT4_XATTR_INODE_GET_PARENT(ea_inode) != parent->i_ino || -+ ea_inode->i_generation != parent->i_generation) { -+ ext4_error(parent->i_sb, "Backpointer from EA inode %lu " -+ "to parent invalid.", ea_ino); -+ *err = -EINVAL; -+ goto error; -+ } -+ -+ if (!(EXT4_I(ea_inode)->i_flags & EXT4_EA_INODE_FL)) { -+ ext4_error(parent->i_sb, "EA inode %lu does not have " -+ "EXT4_EA_INODE_FL flag set.\n", ea_ino); -+ *err = -EINVAL; -+ goto error; -+ } -+ -+ *err = 0; -+ return ea_inode; -+ -+error: -+ iput(ea_inode); -+ return NULL; -+} -+ -+/* -+ * Read the value from the EA inode. -+ */ -+static int -+ext4_xattr_inode_get(struct inode *inode, unsigned long ea_ino, void *buffer, -+ size_t *size) -+{ -+ struct inode *ea_inode = NULL; -+ int err; -+ -+ ea_inode = ext4_xattr_inode_iget(inode, ea_ino, &err); -+ if (err) -+ return err; -+ -+ err = ext4_xattr_inode_read(ea_inode, buffer, size); -+ iput(ea_inode); -+ -+ return err; -+} -+ - static int - ext4_xattr_block_get(struct inode *inode, int name_index, const char *name, - void *buffer, size_t buffer_size) -@@ -235,7 +334,8 @@ bad_block: - } - ext4_xattr_cache_insert(bh); - entry = BFIRST(bh); -- error = ext4_xattr_find_entry(&entry, name_index, name, bh->b_size, 1); -+ error = ext4_xattr_find_entry(&entry, name_index, name, bh->b_size, 1, -+ inode); - if (error == -EIO) - goto bad_block; - if (error) -@@ -245,8 +345,16 @@ bad_block: - error = -ERANGE; - if (size > buffer_size) - goto cleanup; -- memcpy(buffer, bh->b_data + le16_to_cpu(entry->e_value_offs), -- size); -+ if (entry->e_value_inum) { -+ error = ext4_xattr_inode_get(inode, -+ le32_to_cpu(entry->e_value_inum), -+ buffer, &size); -+ if (error) -+ goto cleanup; -+ } else { -+ memcpy(buffer, bh->b_data + -+ le16_to_cpu(entry->e_value_offs), size); -+ } - } - error = size; - -@@ -280,7 +388,7 @@ ext4_xattr_ibody_get(struct inode *inode - if (error) - goto cleanup; - error = ext4_xattr_find_entry(&entry, name_index, name, -- end - (void *)entry, 0); -+ end - (void *)entry, 0, inode); - if (error) - goto cleanup; - size = le32_to_cpu(entry->e_value_size); -@@ -288,8 +396,16 @@ ext4_xattr_ibody_get(struct inode *inode - error = -ERANGE; - if (size > buffer_size) - goto cleanup; -- memcpy(buffer, (void *)IFIRST(header) + -- le16_to_cpu(entry->e_value_offs), size); -+ if (entry->e_value_inum) { -+ error = ext4_xattr_inode_get(inode, -+ le32_to_cpu(entry->e_value_inum), -+ buffer, &size); -+ if (error) -+ goto cleanup; -+ } else { -+ memcpy(buffer, (void *)IFIRST(header) + -+ le16_to_cpu(entry->e_value_offs), size); -+ } - } - error = size; - -@@ -514,7 +630,7 @@ static size_t ext4_xattr_free_space(stru - { - for (; !IS_LAST_ENTRY(last); last = EXT4_XATTR_NEXT(last)) { - *total += EXT4_XATTR_LEN(last->e_name_len); -- if (!last->e_value_block && last->e_value_size) { -+ if (!last->e_value_inum && last->e_value_size) { - size_t offs = le16_to_cpu(last->e_value_offs); - if (offs < *min_offs) - *min_offs = offs; -@@ -523,11 +639,162 @@ static size_t ext4_xattr_free_space(stru - return (*min_offs - ((void *)last - base) - sizeof(__u32)); - } - -+/* -+ * Write the value of the EA in an inode. -+ */ -+static int -+ext4_xattr_inode_write(handle_t *handle, struct inode *ea_inode, -+ const void *buf, int bufsize) -+{ -+ struct buffer_head *bh = NULL; -+ struct ext4_map_blocks map; -+ unsigned long block = 0; -+ unsigned blocksize = ea_inode->i_sb->s_blocksize; -+ unsigned max_blocks = (bufsize + blocksize - 1) >> ea_inode->i_blkbits; -+ int csize, wsize = 0; -+ int ret = 0; -+ int retries = 0; -+ -+retry: -+ while (ret >= 0 && ret < max_blocks) { -+ block += ret; -+ max_blocks -= ret; -+ -+ map.m_lblk = block; -+ map.m_len = max_blocks; -+ ret = ext4_map_blocks(handle, ea_inode, &map, -+ EXT4_GET_BLOCKS_CREATE); -+ if (ret <= 0) { -+ ext4_mark_inode_dirty(handle, ea_inode); -+ if (ret == -ENOSPC && -+ ext4_should_retry_alloc(ea_inode->i_sb, &retries)) { -+ ret = 0; -+ goto retry; -+ } -+ break; -+ } -+ } -+ -+ if (ret < 0) -+ return ret; -+ -+ block = 0; -+ while (wsize < bufsize) { -+ if (bh != NULL) -+ brelse(bh); -+ csize = (bufsize - wsize) > blocksize ? blocksize : -+ bufsize - wsize; -+ bh = ext4_getblk(handle, ea_inode, block, 0, &ret); -+ if (!bh) -+ goto out; -+ ret = ext4_journal_get_write_access(handle, bh); -+ if (ret) -+ goto out; -+ -+ memcpy(bh->b_data, buf, csize); -+ set_buffer_uptodate(bh); -+ ext4_handle_dirty_metadata(handle, ea_inode, bh); -+ -+ buf += csize; -+ wsize += csize; -+ block += 1; -+ } -+ -+ i_size_write(ea_inode, wsize); -+ ext4_update_i_disksize(ea_inode, wsize); -+ -+ ext4_mark_inode_dirty(handle, ea_inode); -+ -+out: -+ brelse(bh); -+ -+ return ret; -+} -+ -+/* -+ * Create an inode to store the value of a large EA. -+ */ -+static struct inode * -+ext4_xattr_inode_create(handle_t *handle, struct inode *inode) -+{ -+ struct inode *ea_inode = NULL; -+ -+ /* -+ * Let the next inode be the goal, so we try and allocate the EA inode -+ * in the same group, or nearby one. -+ */ -+ ea_inode = ext4_new_inode(handle, inode->i_sb->s_root->d_inode, -+ S_IFREG|0600, NULL, inode->i_ino + 1); -+ -+ if (!IS_ERR(ea_inode)) { -+ ea_inode->i_op = &ext4_file_inode_operations; -+ ea_inode->i_fop = &ext4_file_operations; -+ ext4_set_aops(ea_inode); -+ ea_inode->i_generation = inode->i_generation; -+ EXT4_I(ea_inode)->i_flags |= EXT4_EA_INODE_FL; -+ -+ /* -+ * A back-pointer from EA inode to parent inode will be useful -+ * for e2fsck. -+ */ -+ EXT4_XATTR_INODE_SET_PARENT(ea_inode, inode->i_ino); -+ unlock_new_inode(ea_inode); -+ } -+ -+ return ea_inode; -+} -+ -+/* -+ * Unlink the inode storing the value of the EA. -+ */ -+int -+ext4_xattr_inode_unlink(struct inode *inode, unsigned long ea_ino) -+{ -+ struct inode *ea_inode = NULL; -+ int err; -+ -+ ea_inode = ext4_xattr_inode_iget(inode, ea_ino, &err); -+ if (err) -+ return err; -+ -+ ea_inode->i_nlink = 0; -+ iput(ea_inode); -+ -+ return 0; -+} -+ -+/* -+ * Add value of the EA in an inode. -+ */ -+static int -+ext4_xattr_inode_set(handle_t *handle, struct inode *inode, unsigned long *ea_ino, -+ const void *value, size_t value_len) -+{ -+ struct inode *ea_inode = NULL; -+ int err; -+ -+ /* Create an inode for the EA value */ -+ ea_inode = ext4_xattr_inode_create(handle, inode); -+ if (IS_ERR(ea_inode)) -+ return -1; -+ -+ err = ext4_xattr_inode_write(handle, ea_inode, value, value_len); -+ if (err) -+ ea_inode->i_nlink = 0; -+ else -+ *ea_ino = ea_inode->i_ino; -+ -+ iput(ea_inode); -+ -+ return err; -+} -+ - struct ext4_xattr_info { -- int name_index; - const char *name; - const void *value; - size_t value_len; -+ int name_index; -+ int in_inode; - }; - - struct ext4_xattr_search { -@@ -539,15 +806,23 @@ struct ext4_xattr_search { - }; - - static int --ext4_xattr_set_entry(struct ext4_xattr_info *i, struct ext4_xattr_search *s) -+ext4_xattr_set_entry(struct ext4_xattr_info *i, struct ext4_xattr_search *s, -+ handle_t *handle, struct inode *inode) - { - struct ext4_xattr_entry *last; - size_t free, min_offs = s->end - s->base, name_len = strlen(i->name); -+ int in_inode = i->in_inode; -+ -+ if (EXT4_HAS_INCOMPAT_FEATURE(inode->i_sb, -+ EXT4_FEATURE_INCOMPAT_EA_INODE) && -+ (EXT4_XATTR_SIZE(i->value_len) > -+ EXT4_XATTR_MIN_LARGE_EA_SIZE(inode->i_sb->s_blocksize))) -+ in_inode = 1; - - /* Compute min_offs and last. */ - last = s->first; - for (; !IS_LAST_ENTRY(last); last = EXT4_XATTR_NEXT(last)) { -- if (!last->e_value_block && last->e_value_size) { -+ if (!last->e_value_inum && last->e_value_size) { - size_t offs = le16_to_cpu(last->e_value_offs); - if (offs < min_offs) - min_offs = offs; -@@ -555,16 +830,21 @@ ext4_xattr_set_entry(struct ext4_xattr_i - } - free = min_offs - ((void *)last - s->base) - sizeof(__u32); - if (!s->not_found) { -- if (!s->here->e_value_block && s->here->e_value_size) { -+ if (!in_inode && -+ !s->here->e_value_inum && s->here->e_value_size) { - size_t size = le32_to_cpu(s->here->e_value_size); - free += EXT4_XATTR_SIZE(size); - } - free += EXT4_XATTR_LEN(name_len); - } - if (i->value) { -- if (free < EXT4_XATTR_SIZE(i->value_len) || -- free < EXT4_XATTR_LEN(name_len) + -- EXT4_XATTR_SIZE(i->value_len)) -+ size_t value_len = EXT4_XATTR_SIZE(i->value_len); -+ -+ if (in_inode) -+ value_len = 0; -+ -+ if (free < value_len || -+ free < EXT4_XATTR_LEN(name_len) + value_len) - return -ENOSPC; - } - -@@ -578,7 +858,8 @@ ext4_xattr_set_entry(struct ext4_xattr_i - s->here->e_name_len = name_len; - memcpy(s->here->e_name, i->name, name_len); - } else { -- if (!s->here->e_value_block && s->here->e_value_size) { -+ if (!s->here->e_value_inum && s->here->e_value_size && -+ s->here->e_value_offs > 0) { - void *first_val = s->base + min_offs; - size_t offs = le16_to_cpu(s->here->e_value_offs); - void *val = s->base + offs; -@@ -607,13 +888,18 @@ ext4_xattr_set_entry(struct ext4_xattr_i - last = s->first; - while (!IS_LAST_ENTRY(last)) { - size_t o = le16_to_cpu(last->e_value_offs); -- if (!last->e_value_block && -+ if (!last->e_value_inum && - last->e_value_size && o < offs) - last->e_value_offs = - cpu_to_le16(o + size); - last = EXT4_XATTR_NEXT(last); - } - } -+ if (s->here->e_value_inum) { -+ ext4_xattr_inode_unlink(inode, -+ le32_to_cpu(s->here->e_value_inum)); -+ s->here->e_value_inum = 0; -+ } - if (!i->value) { - /* Remove the old name. */ - size_t size = EXT4_XATTR_LEN(name_len); -@@ -627,10 +912,17 @@ ext4_xattr_set_entry(struct ext4_xattr_i - if (i->value) { - /* Insert the new value. */ - s->here->e_value_size = cpu_to_le32(i->value_len); -- if (i->value_len) { -+ if (in_inode) { -+ unsigned long ea_ino = le32_to_cpu(s->here->e_value_inum); -+ ext4_xattr_inode_set(handle, inode, &ea_ino, i->value, -+ i->value_len); -+ s->here->e_value_inum = cpu_to_le32(ea_ino); -+ s->here->e_value_offs = 0; -+ } else if (i->value_len) { - size_t size = EXT4_XATTR_SIZE(i->value_len); - void *val = s->base + min_offs - size; - s->here->e_value_offs = cpu_to_le16(min_offs - size); -+ s->here->e_value_inum = 0; - memset(val + size - EXT4_XATTR_PAD, 0, - EXT4_XATTR_PAD); /* Clear the pad bytes. */ - memcpy(val, i->value, i->value_len); -@@ -675,7 +967,7 @@ ext4_xattr_block_find(struct inode *inod - bs->s.end = bs->bh->b_data + bs->bh->b_size; - bs->s.here = bs->s.first; - error = ext4_xattr_find_entry(&bs->s.here, i->name_index, -- i->name, bs->bh->b_size, 1); -+ i->name, bs->bh->b_size, 1, inode); - if (error && error != -ENODATA) - goto cleanup; - bs->s.not_found = error; -@@ -699,8 +991,6 @@ ext4_xattr_block_set(handle_t *handle, s - - #define header(x) ((struct ext4_xattr_header *)(x)) - -- if (i->value && i->value_len > sb->s_blocksize) -- return -ENOSPC; - if (s->base) { - ce = mb_cache_entry_get(ext4_xattr_cache, bs->bh->b_bdev, - bs->bh->b_blocknr); -@@ -715,7 +1005,7 @@ ext4_xattr_block_set(handle_t *handle, s - ce = NULL; - } - ea_bdebug(bs->bh, "modifying in-place"); -- error = ext4_xattr_set_entry(i, s); -+ error = ext4_xattr_set_entry(i, s, handle, inode); - if (!error) { - if (!IS_LAST_ENTRY(s->first)) - ext4_xattr_rehash(header(s->base), -@@ -767,7 +1057,7 @@ ext4_xattr_block_set(handle_t *handle, s - s->end = s->base + sb->s_blocksize; - } - -- error = ext4_xattr_set_entry(i, s); -+ error = ext4_xattr_set_entry(i, s, handle, inode); - if (error == -EIO) - goto bad_block; - if (error) -@@ -918,7 +1208,7 @@ ext4_xattr_ibody_find(struct inode *inod - /* Find the named attribute. */ - error = ext4_xattr_find_entry(&is->s.here, i->name_index, - i->name, is->s.end - -- (void *)is->s.base, 0); -+ (void *)is->s.base, 0, inode); - if (error && error != -ENODATA) - return error; - is->s.not_found = error; -@@ -937,7 +1227,7 @@ ext4_xattr_ibody_set(handle_t *handle, s - - if (EXT4_I(inode)->i_extra_isize == 0) - return -ENOSPC; -- error = ext4_xattr_set_entry(i, s); -+ error = ext4_xattr_set_entry(i, s, handle, inode); - if (error) - return error; - header = IHDR(inode, ext4_raw_inode(&is->iloc)); -@@ -973,7 +1263,7 @@ ext4_xattr_set_handle(handle_t *handle, - .name = name, - .value = value, - .value_len = value_len, -- -+ .in_inode = 0, - }; - struct ext4_xattr_ibody_find is = { - .s = { .not_found = -ENODATA, }, -@@ -1042,6 +1332,15 @@ ext4_xattr_set_handle(handle_t *handle, - goto cleanup; - } - error = ext4_xattr_block_set(handle, inode, &i, &bs); -+ if (EXT4_HAS_INCOMPAT_FEATURE(inode->i_sb, -+ EXT4_FEATURE_INCOMPAT_EA_INODE) && -+ error == -ENOSPC) { -+ /* xattr not fit to block, store at external -+ * inode */ -+ i.in_inode = 1; -+ error = ext4_xattr_ibody_set(handle, inode, -+ &i, &is); -+ } - if (error) - goto cleanup; - if (!is.s.not_found) { -@@ -1088,10 +1387,25 @@ ext4_xattr_set(struct inode *inode, int - const void *value, size_t value_len, int flags) - { - handle_t *handle; -+ struct super_block *sb = inode->i_sb; -+ int buffer_credits; - int error, retries = 0; - -+ buffer_credits = EXT4_DATA_TRANS_BLOCKS(sb); -+ if ((value_len >= EXT4_XATTR_MIN_LARGE_EA_SIZE(sb->s_blocksize)) && -+ EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EA_INODE)) { -+ int nrblocks = (value_len + sb->s_blocksize - 1) >> -+ sb->s_blocksize_bits; -+ -+ /* For new inode */ -+ buffer_credits += EXT4_SINGLEDATA_TRANS_BLOCKS(sb) + 3; -+ -+ /* For data blocks of EA inode */ -+ buffer_credits += ext4_meta_trans_blocks(inode, nrblocks, 0); -+ } -+ - retry: -- handle = ext4_journal_start(inode, EXT4_DATA_TRANS_BLOCKS(inode->i_sb)); -+ handle = ext4_journal_start(inode, buffer_credits); - if (IS_ERR(handle)) { - error = PTR_ERR(handle); - } else { -@@ -1101,7 +1415,7 @@ retry: - value, value_len, flags); - error2 = ext4_journal_stop(handle); - if (error == -ENOSPC && -- ext4_should_retry_alloc(inode->i_sb, &retries)) -+ ext4_should_retry_alloc(sb, &retries)) - goto retry; - if (error == 0) - error = error2; -@@ -1123,7 +1437,7 @@ static void ext4_xattr_shift_entries(str - - /* Adjust the value offsets of the entries */ - for (; !IS_LAST_ENTRY(last); last = EXT4_XATTR_NEXT(last)) { -- if (!last->e_value_block && last->e_value_size) { -+ if (!last->e_value_inum && last->e_value_size) { - new_offs = le16_to_cpu(last->e_value_offs) + - value_offs_shift; - BUG_ON(new_offs + le32_to_cpu(last->e_value_size) -@@ -1358,22 +1672,135 @@ cleanup: - return error; - } - -+#define EIA_INCR 16 /* must be 2^n */ -+#define EIA_MASK (EIA_INCR - 1) -+/* Add the large xattr @ino into @lea_ino_array for later deletion. -+ * If @lea_ino_array is new or full it will be grown and the old -+ * contents copied over. -+ */ -+static int -+ext4_expand_ino_array(struct ext4_xattr_ino_array **lea_ino_array, __u32 ino) -+{ -+ if (*lea_ino_array == NULL) { -+ /* -+ * Start with 15 inodes, so it fits into a powr-of-two size. -+ * If *lea_ino_array is NULL, this is essentially offsetof() -+ */ -+ (*lea_ino_array) = -+ kmalloc(offsetof(struct ext4_xattr_ino_array, -+ xia_inodes[EIA_MASK]), -+ GFP_NOFS); -+ if (*lea_ino_array == NULL) -+ return -ENOMEM; -+ (*lea_ino_array)->xia_count = 0; -+ } else if (((*lea_ino_array)->xia_count & EIA_MASK) == EIA_MASK) { -+ /* expand the array once all 15 + n * 16 slots are full */ -+ struct ext4_xattr_ino_array *new_array = NULL; -+ int count = (*lea_ino_array)->xia_count; -+ -+ /* if new_array is NULL, this is essentially offsetof() */ -+ new_array = kmalloc( -+ offsetof(struct ext4_xattr_ino_array, -+ xia_inodes[count + EIA_INCR]), -+ GFP_NOFS); -+ if (new_array == NULL) -+ return -ENOMEM; -+ memcpy(new_array, *lea_ino_array, -+ offsetof(struct ext4_xattr_ino_array, -+ xia_inodes[count])); -+ kfree(*lea_ino_array); -+ *lea_ino_array = new_array; -+ } -+ (*lea_ino_array)->xia_inodes[(*lea_ino_array)->xia_count++] = ino; -+ return 0; -+} -+ -+/** -+ * Add xattr inode to orphan list -+ */ -+static int -+ext4_xattr_inode_orphan_add(handle_t *handle, struct inode *inode, -+ int credits, struct ext4_xattr_ino_array *lea_ino_array) -+{ -+ struct inode *ea_inode = NULL; -+ int idx = 0, error = 0; -+ -+ if (lea_ino_array == NULL) -+ return 0; - -+ for (; idx < lea_ino_array->xia_count; ++idx) { -+ if (!ext4_handle_has_enough_credits(handle, credits)) { -+ error = ext4_journal_extend(handle, credits); -+ if (error > 0) -+ error = ext4_journal_restart(handle, credits); -+ -+ if (error != 0) { -+ ext4_warning(inode->i_sb, -+ "couldn't extend journal " -+ "(err %d)", error); -+ return error; -+ } -+ } -+ ea_inode = ext4_xattr_inode_iget(inode, -+ lea_ino_array->xia_inodes[idx], &error); -+ if (error) -+ continue; -+ ext4_orphan_add(handle, ea_inode); -+ /* the inode's i_count will be released by caller */ -+ } -+ -+ return 0; -+} - - /* - * ext4_xattr_delete_inode() - * -- * Free extended attribute resources associated with this inode. This -+ * Free extended attribute resources associated with this inode. Traverse -+ * all entries and unlink any xattr inodes associated with this inode. This - * is called immediately before an inode is freed. We have exclusive -- * access to the inode. -+ * access to the inode. If an orphan inode is deleted it will also delete any -+ * xattr block and all xattr inodes. They are checked by ext4_xattr_inode_iget() -+ * to ensure they belong to the parent inode and were not deleted already. - */ --void --ext4_xattr_delete_inode(handle_t *handle, struct inode *inode) -+int -+ext4_xattr_delete_inode(handle_t *handle, struct inode *inode, -+ struct ext4_xattr_ino_array **lea_ino_array) - { - struct buffer_head *bh = NULL; -+ struct ext4_xattr_ibody_header *header; -+ struct ext4_inode *raw_inode; -+ struct ext4_iloc iloc; -+ struct ext4_xattr_entry *entry; -+ int credits = 3, error = 0; - -- if (!EXT4_I(inode)->i_file_acl) -+ if (!ext4_test_inode_state(inode, EXT4_STATE_XATTR)) -+ goto delete_external_ea; -+ -+ error = ext4_get_inode_loc(inode, &iloc); -+ if (error) - goto cleanup; -+ raw_inode = ext4_raw_inode(&iloc); -+ header = IHDR(inode, raw_inode); -+ for (entry = IFIRST(header); !IS_LAST_ENTRY(entry); -+ entry = EXT4_XATTR_NEXT(entry)) { -+ if (!entry->e_value_inum) -+ continue; -+ if (ext4_expand_ino_array(lea_ino_array, -+ entry->e_value_inum) != 0) { -+ brelse(iloc.bh); -+ goto cleanup; -+ } -+ entry->e_value_inum = 0; -+ } -+ brelse(iloc.bh); -+ -+delete_external_ea: -+ if (!EXT4_I(inode)->i_file_acl) { -+ /* add xattr inode to orphan list */ -+ ext4_xattr_inode_orphan_add(handle, inode, credits, -+ *lea_ino_array); -+ goto cleanup; -+ } - bh = sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl); - if (!bh) { - EXT4_ERROR_INODE(inode, "block %llu read error", -@@ -1386,11 +1813,69 @@ ext4_xattr_delete_inode(handle_t *handle - EXT4_I(inode)->i_file_acl); - goto cleanup; - } -+ -+ for (entry = BFIRST(bh); !IS_LAST_ENTRY(entry); -+ entry = EXT4_XATTR_NEXT(entry)) { -+ if (!entry->e_value_inum) -+ continue; -+ if (ext4_expand_ino_array(lea_ino_array, -+ entry->e_value_inum) != 0) -+ goto cleanup; -+ entry->e_value_inum = 0; -+ } -+ -+ /* adding xattr inode to orphan list */ -+ error = ext4_xattr_inode_orphan_add(handle, inode, credits, -+ *lea_ino_array); -+ if (error != 0) -+ goto cleanup; -+ -+ if (!IS_NOQUOTA(inode)) -+ credits += 2 * EXT4_QUOTA_DEL_BLOCKS(inode->i_sb); -+ -+ if (!ext4_handle_has_enough_credits(handle, credits)) { -+ error = ext4_journal_extend(handle, credits); -+ if (error > 0) -+ error = ext4_journal_restart(handle, credits); -+ if (error != 0) { -+ ext4_warning(inode->i_sb, -+ "couldn't extend journal (err %d)", error); -+ goto cleanup; -+ } -+ } -+ - ext4_xattr_release_block(handle, inode, bh); - EXT4_I(inode)->i_file_acl = 0; - - cleanup: - brelse(bh); -+ -+ return error; -+} -+ -+void -+ext4_xattr_inode_array_free(struct inode *inode, -+ struct ext4_xattr_ino_array *lea_ino_array) -+{ -+ struct inode *ea_inode = NULL; -+ int idx = 0; -+ int err; -+ -+ if (lea_ino_array == NULL) -+ return; -+ -+ for (; idx < lea_ino_array->xia_count; ++idx) { -+ ea_inode = ext4_xattr_inode_iget(inode, -+ lea_ino_array->xia_inodes[idx], &err); -+ if (err) -+ continue; -+ /* for inode's i_count get from ext4_xattr_delete_inode */ -+ if (!list_empty(&EXT4_I(ea_inode)->i_orphan)) -+ iput(ea_inode); -+ ea_inode->i_nlink = 0; -+ iput(ea_inode); -+ } -+ kfree(lea_ino_array); - } - - /* -@@ -1460,10 +1945,9 @@ ext4_xattr_cmp(struct ext4_xattr_header - entry1->e_name_index != entry2->e_name_index || - entry1->e_name_len != entry2->e_name_len || - entry1->e_value_size != entry2->e_value_size || -+ entry1->e_value_inum != entry2->e_value_inum || - memcmp(entry1->e_name, entry2->e_name, entry1->e_name_len)) - return 1; -- if (entry1->e_value_block != 0 || entry2->e_value_block != 0) -- return -EIO; - if (memcmp((char *)header1 + le16_to_cpu(entry1->e_value_offs), - (char *)header2 + le16_to_cpu(entry2->e_value_offs), - le32_to_cpu(entry1->e_value_size))) -@@ -1547,7 +2031,7 @@ static inline void ext4_xattr_hash_entry - *name++; - } - -- if (entry->e_value_block == 0 && entry->e_value_size != 0) { -+ if (!entry->e_value_inum && entry->e_value_size) { - __le32 *value = (__le32 *)((char *)header + - le16_to_cpu(entry->e_value_offs)); - for (n = (le32_to_cpu(entry->e_value_size) + -Index: linux-stage/fs/ext4/xattr.h -=================================================================== ---- linux-stage.orig/fs/ext4/xattr.h -+++ linux-stage/fs/ext4/xattr.h -@@ -38,7 +38,7 @@ struct ext4_xattr_entry { - __u8 e_name_len; /* length of name */ - __u8 e_name_index; /* attribute name index */ - __le16 e_value_offs; /* offset in disk block of value */ -- __le32 e_value_block; /* disk block attribute is stored on (n/i) */ -+ __le32 e_value_inum; /* inode in which the value is stored */ - __le32 e_value_size; /* size of attribute value */ - __le32 e_hash; /* hash value of name and value */ - char e_name[0]; /* attribute name */ -@@ -63,6 +63,26 @@ struct ext4_xattr_entry { - EXT4_I(inode)->i_extra_isize)) - #define IFIRST(hdr) ((struct ext4_xattr_entry *)((hdr)+1)) - -+/* -+ * Link EA inode back to parent one using i_mtime field. -+ * Extra integer type conversion added to ignore higher -+ * bits in i_mtime.tv_sec which might be set by ext4_get() -+ */ -+#define EXT4_XATTR_INODE_SET_PARENT(inode, inum) \ -+do { \ -+ (inode)->i_mtime.tv_sec = inum; \ -+} while(0) -+ -+#define EXT4_XATTR_INODE_GET_PARENT(inode) \ -+((__u32)(inode)->i_mtime.tv_sec) -+ -+/* -+ * The minimum size of EA value when you start storing it in an external inode -+ * size of block - size of header - size of 1 entry - 4 null bytes -+*/ -+#define EXT4_XATTR_MIN_LARGE_EA_SIZE(b) \ -+ ((b) - EXT4_XATTR_LEN(3) - sizeof(struct ext4_xattr_header) - 4) -+ - # ifdef CONFIG_EXT4_FS_XATTR - - extern const struct xattr_handler ext4_xattr_user_handler; -@@ -77,7 +86,13 @@ extern int ext4_xattr_get(struct inode * - extern int ext4_xattr_set(struct inode *, int, const char *, const void *, size_t, int); - extern int ext4_xattr_set_handle(handle_t *, struct inode *, int, const char *, const void *, size_t, int); - --extern void ext4_xattr_delete_inode(handle_t *, struct inode *); -+extern struct inode *ext4_xattr_inode_iget(struct inode *parent, unsigned long ea_ino, -+ int *err); -+extern int ext4_xattr_inode_unlink(struct inode *inode, unsigned long ea_ino); -+extern int ext4_xattr_delete_inode(handle_t *handle, struct inode *inode, -+ struct ext4_xattr_ino_array **array); -+extern void ext4_xattr_inode_array_free(struct inode *inode, -+ struct ext4_xattr_ino_array *array); - extern void ext4_xattr_put_super(struct super_block *); - - extern int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize, -@@ -111,9 +126,11 @@ ext4_xattr_set_handle(handle_t *handle, - return -EOPNOTSUPP; - } - --static inline void --ext4_xattr_delete_inode(handle_t *handle, struct inode *inode) -+inline int -+ext4_xattr_delete_inode(handle_t *handle, struct inode *inode, -+ struct ext4_xattr_ino_array *array) - { -+ return -EOPNOTSUPP; - } - - static inline void -Index: linux-stage/fs/ext4/ialloc.c -=================================================================== ---- linux-stage.orig/fs/ext4/ialloc.c -+++ linux-stage/fs/ext4/ialloc.c -@@ -221,7 +221,6 @@ void ext4_free_inode(handle_t *handle, s - * as writing the quota to disk may need the lock as well. - */ - dquot_initialize(inode); -- ext4_xattr_delete_inode(handle, inode); - dquot_free_inode(inode); - dquot_drop(inode); - diff --git a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-lookup-dotdot.patch b/ldiskfs/kernel_patches/patches/sles11sp2/ext4-lookup-dotdot.patch deleted file mode 100644 index 84ead51..0000000 --- a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-lookup-dotdot.patch +++ /dev/null @@ -1,62 +0,0 @@ ---- - fs/ext4/namei.c | 42 ++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 42 insertions(+) - ---- a/fs/ext4/namei.c -+++ b/fs/ext4/namei.c -@@ -1031,6 +1031,16 @@ errout: - return NULL; - } - -+static inline int -+is_dot_or_dot_dot(const struct qstr *name) -+{ -+ if (name->name[0] != '.') -+ return 0; -+ if (name->len == 1 || (name->len == 2 && name->name[1] == '.')) -+ return 1; -+ return 0; -+} -+ - static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd) - { - struct inode *inode; -@@ -1061,6 +1071,38 @@ static struct dentry *ext4_lookup(struct - } - } - } -+ -+ /* ".." shouldn't go into dcache to preserve dcache hierarchy -+ * otherwise we'll get parent being a child of actual child. -+ * see bug 10458 for details -bzzz */ -+ if (inode && is_dot_or_dot_dot(&dentry->d_name)) { -+ struct dentry *tmp, *goal = NULL; -+ struct list_head *lp; -+ -+ /* first, look for an existing dentry - any one is good */ -+ spin_lock(&inode->i_lock); -+ list_for_each(lp, &inode->i_dentry) { -+ tmp = list_entry(lp, struct dentry, d_alias); -+ goal = tmp; -+ dget(goal); -+ break; -+ } -+ if (goal == NULL) { -+ /* there is no alias, we need to make current dentry: -+ * a) inaccessible for __d_lookup() -+ * b) inaccessible for iopen */ -+ J_ASSERT(list_empty(&dentry->d_alias)); -+ dentry->d_flags |= DCACHE_NFSFS_RENAMED; -+ /* this is d_instantiate() ... */ -+ list_add(&dentry->d_alias, &inode->i_dentry); -+ dentry->d_inode = inode; -+ } -+ spin_unlock(&inode->i_lock); -+ if (goal) -+ iput(inode); -+ return goal; -+ } -+ - return d_splice_alias(inode, dentry); - } - diff --git a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-make-quota-as-first-class-supported-feature.patch b/ldiskfs/kernel_patches/patches/sles11sp2/ext4-make-quota-as-first-class-supported-feature.patch deleted file mode 100644 index 5221378..0000000 --- a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-make-quota-as-first-class-supported-feature.patch +++ /dev/null @@ -1,322 +0,0 @@ -From 7c319d328505b7781b65238ae9f53293b5ee0ca8 Mon Sep 17 00:00:00 2001 -From: Aditya Kali -Date: Sun, 22 Jul 2012 20:21:31 -0400 -Subject: ext4: make quota as first class supported feature -Git-commit: 7c319d32, 281b5995 -Patch-mainline: v3.6-rc1 - -This patch adds support for quotas as a first class feature in ext4; -which is to say, the quota files are stored in hidden inodes as file -system metadata, instead of as separate files visible in the file system -directory hierarchy. - -It is based on the proposal at: -https://ext4.wiki.kernel.org/index.php/Design_For_1st_Class_Quota_in_Ext4 - -This patch introduces a new feature - EXT4_FEATURE_RO_COMPAT_QUOTA -which, when turned on, enables quota accounting at mount time -iteself. Also, the quota inodes are stored in two additional superblock -fields. Some changes introduced by this patch that should be pointed -out are: - -1) Two new ext4-superblock fields - s_usr_quota_inum and - s_grp_quota_inum for storing the quota inodes in use. -2) Default quota inodes are: inode#3 for tracking userquota and inode#4 - for tracking group quota. The superblock fields can be set to use - other inodes as well. -3) If the QUOTA feature and corresponding quota inodes are set in - superblock, the quota usage tracking is turned on at mount time. On - 'quotaon' ioctl, the quota limits enforcement is turned - on. 'quotaoff' ioctl turns off only the limits enforcement in this - case. -4) When QUOTA feature is in use, the quota mount options 'quota', - 'usrquota', 'grpquota' are ignored by the kernel. -5) mke2fs or tune2fs can be used to set the QUOTA feature and initialize - quota inodes. The default reserved inodes will not be visible to user - as regular files. -6) The quota-tools will need to be modified to support hidden quota - files on ext4. E2fsprogs will also include support for creating and - fixing quota files. -7) Support is only for the new V2 quota file format. - -Tested-by: Jan Kara -Reviewed-by: Jan Kara -Reviewed-by: Johann Lombardi -Signed-off-by: Aditya Kali -Signed-off-by: "Theodore Ts'o" -Acked-by: Jeff Mahoney ---- - fs/ext4/ext4.h | 10 +++ - fs/ext4/ext4_jbd2.h | 16 ++++-- - fs/ext4/super.c | 137 ++++++++++++++++++++++++++++++++++++++++++++++++++-- - 3 files changed, 153 insertions(+), 10 deletions(-) - ---- a/fs/ext4/ext4.h -+++ b/fs/ext4/ext4.h -@@ -1063,7 +1063,10 @@ struct ext4_super_block { - __u8 s_last_error_func[32]; /* function where the error happened */ - #define EXT4_S_ERR_END offsetof(struct ext4_super_block, s_mount_opts) - __u8 s_mount_opts[64]; -- __le32 s_reserved[112]; /* Padding to the end of the block */ -+ __le32 s_usr_quota_inum; /* inode for tracking user quota */ -+ __le32 s_grp_quota_inum; /* inode for tracking group quota */ -+ __le32 s_overhead_clusters; /* overhead blocks/clusters in fs */ -+ __le32 s_reserved[109]; /* Padding to the end of the block */ - }; - - #define EXT4_S_ERR_LEN (EXT4_S_ERR_END - EXT4_S_ERR_START) -@@ -1238,6 +1241,8 @@ static inline struct timespec ext4_curre - static inline int ext4_valid_inum(struct super_block *sb, unsigned long ino) - { - return ino == EXT4_ROOT_INO || -+ ino == EXT4_USR_QUOTA_INO || -+ ino == EXT4_GRP_QUOTA_INO || - ino == EXT4_JOURNAL_INO || - ino == EXT4_RESIZE_INO || - (ino >= EXT4_FIRST_INO(sb) && -@@ -1398,7 +1403,8 @@ static inline void ext4_clear_state_flag - EXT4_FEATURE_RO_COMPAT_DIR_NLINK | \ - EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE | \ - EXT4_FEATURE_RO_COMPAT_BTREE_DIR |\ -- EXT4_FEATURE_RO_COMPAT_HUGE_FILE) -+ EXT4_FEATURE_RO_COMPAT_HUGE_FILE |\ -+ EXT4_FEATURE_RO_COMPAT_QUOTA) - - /* - * Default values for user and/or group using reserved blocks ---- a/fs/ext4/ext4_jbd2.h -+++ b/fs/ext4/ext4_jbd2.h -@@ -87,14 +87,20 @@ - #ifdef CONFIG_QUOTA - /* Amount of blocks needed for quota update - we know that the structure was - * allocated so we need to update only data block */ --#define EXT4_QUOTA_TRANS_BLOCKS(sb) (test_opt(sb, QUOTA) ? 1 : 0) -+#define EXT4_QUOTA_TRANS_BLOCKS(sb) ((test_opt(sb, QUOTA) ||\ -+ EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_QUOTA)) ?\ -+ 1 : 0) - /* Amount of blocks needed for quota insert/delete - we do some block writes - * but inode, sb and group updates are done only once */ --#define EXT4_QUOTA_INIT_BLOCKS(sb) (test_opt(sb, QUOTA) ? (DQUOT_INIT_ALLOC*\ -- (EXT4_SINGLEDATA_TRANS_BLOCKS(sb)-3)+3+DQUOT_INIT_REWRITE) : 0) -+#define EXT4_QUOTA_INIT_BLOCKS(sb) ((test_opt(sb, QUOTA) ||\ -+ EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_QUOTA)) ?\ -+ (DQUOT_INIT_ALLOC*(EXT4_SINGLEDATA_TRANS_BLOCKS(sb)-3)\ -+ +3+DQUOT_INIT_REWRITE) : 0) - --#define EXT4_QUOTA_DEL_BLOCKS(sb) (test_opt(sb, QUOTA) ? (DQUOT_DEL_ALLOC*\ -- (EXT4_SINGLEDATA_TRANS_BLOCKS(sb)-3)+3+DQUOT_DEL_REWRITE) : 0) -+#define EXT4_QUOTA_DEL_BLOCKS(sb) ((test_opt(sb, QUOTA) ||\ -+ EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_QUOTA)) ?\ -+ (DQUOT_DEL_ALLOC*(EXT4_SINGLEDATA_TRANS_BLOCKS(sb)-3)\ -+ +3+DQUOT_DEL_REWRITE) : 0) - #else - #define EXT4_QUOTA_TRANS_BLOCKS(sb) 0 - #define EXT4_QUOTA_INIT_BLOCKS(sb) 0 ---- a/fs/ext4/super.c -+++ b/fs/ext4/super.c -@@ -1241,12 +1241,18 @@ static int ext4_mark_dquot_dirty(struct - static int ext4_write_info(struct super_block *sb, int type); - static int ext4_quota_on(struct super_block *sb, int type, int format_id, - struct path *path); -+static int ext4_quota_on_sysfile(struct super_block *sb, int type, -+ int format_id); - static int ext4_quota_off(struct super_block *sb, int type); -+static int ext4_quota_off_sysfile(struct super_block *sb, int type); - static int ext4_quota_on_mount(struct super_block *sb, int type); - static ssize_t ext4_quota_read(struct super_block *sb, int type, char *data, - size_t len, loff_t off); - static ssize_t ext4_quota_write(struct super_block *sb, int type, - const char *data, size_t len, loff_t off); -+static int ext4_quota_enable(struct super_block *sb, int type, int format_id, -+ unsigned int flags); -+static int ext4_enable_quotas(struct super_block *sb); - - static const struct dquot_operations ext4_quota_operations = { - .get_reserved_space = ext4_get_reserved_space, -@@ -1268,6 +1274,16 @@ static const struct quotactl_ops ext4_qc - .get_dqblk = dquot_get_dqblk, - .set_dqblk = dquot_set_dqblk - }; -+ -+static const struct quotactl_ops ext4_qctl_sysfile_operations = { -+ .quota_on_meta = ext4_quota_on_sysfile, -+ .quota_off = ext4_quota_off_sysfile, -+ .quota_sync = dquot_quota_sync, -+ .get_info = dquot_get_dqinfo, -+ .set_info = dquot_set_dqinfo, -+ .get_dqblk = dquot_get_dqblk, -+ .set_dqblk = dquot_set_dqblk -+}; - #endif - - static const struct super_operations ext4_sops = { -@@ -2689,6 +2705,16 @@ static int ext4_feature_set_ok(struct su - return 0; - } - } -+ -+#ifndef CONFIG_QUOTA -+ if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_QUOTA) && -+ !readonly) { -+ ext4_msg(sb, KERN_ERR, -+ "Filesystem with quota feature cannot be mounted RDWR " -+ "without CONFIG_QUOTA"); -+ return 0; -+ } -+#endif /* CONFIG_QUOTA */ - return 1; - } - -@@ -3528,6 +3554,11 @@ static int ext4_fill_super(struct super_ - #ifdef CONFIG_QUOTA - sb->s_qcop = &ext4_qctl_operations; - sb->dq_op = &ext4_quota_operations; -+ -+ if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_QUOTA)) { -+ /* Use qctl operations for hidden quota files. */ -+ sb->s_qcop = &ext4_qctl_sysfile_operations; -+ } - #endif - memcpy(sb->s_uuid, es->s_uuid, sizeof(es->s_uuid)); - -@@ -3755,6 +3786,16 @@ no_journal: - } else - descr = "out journal"; - -+#ifdef CONFIG_QUOTA -+ /* Enable quota usage during mount. */ -+ if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_QUOTA) && -+ !(sb->s_flags & MS_RDONLY)) { -+ ret = ext4_enable_quotas(sb); -+ if (ret) -+ goto failed_mount7; -+ } -+#endif /* CONFIG_QUOTA */ -+ - ext4_msg(sb, KERN_INFO, "mounted filesystem with%s. " - "Opts: %s%s%s", descr, sbi->s_es->s_mount_opts, - *sbi->s_es->s_mount_opts ? "; " : "", orig_data); -@@ -4493,16 +4534,26 @@ static int ext4_remount(struct super_blo - if (sbi->s_journal == NULL) - ext4_commit_super(sb, 1); - -+ unlock_super(sb); - #ifdef CONFIG_QUOTA - /* Release old quota file names */ - for (i = 0; i < MAXQUOTAS; i++) - if (old_opts.s_qf_names[i] && - old_opts.s_qf_names[i] != sbi->s_qf_names[i]) - kfree(old_opts.s_qf_names[i]); -+ if (enable_quota) { -+ if (sb_any_quota_suspended(sb)) -+ dquot_resume(sb, -1); -+ else if (EXT4_HAS_RO_COMPAT_FEATURE(sb, -+ EXT4_FEATURE_RO_COMPAT_QUOTA)) { -+ err = ext4_enable_quotas(sb); -+ if (err) { -+ lock_super(sb); -+ goto restore_opts; -+ } -+ } -+ } - #endif -- unlock_super(sb); -- if (enable_quota) -- dquot_resume(sb, -1); - - ext4_msg(sb, KERN_INFO, "re-mounted. Opts: %s", orig_data); - kfree(orig_data); -@@ -4750,6 +4801,74 @@ static int ext4_quota_on(struct super_bl - return dquot_quota_on(sb, type, format_id, path); - } - -+static int ext4_quota_enable(struct super_block *sb, int type, int format_id, -+ unsigned int flags) -+{ -+ int err; -+ struct inode *qf_inode; -+ unsigned long qf_inums[MAXQUOTAS] = { -+ le32_to_cpu(EXT4_SB(sb)->s_es->s_usr_quota_inum), -+ le32_to_cpu(EXT4_SB(sb)->s_es->s_grp_quota_inum) -+ }; -+ -+ BUG_ON(!EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_QUOTA)); -+ -+ if (!qf_inums[type]) -+ return -EPERM; -+ -+ qf_inode = ext4_iget(sb, qf_inums[type]); -+ if (IS_ERR(qf_inode)) { -+ ext4_error(sb, "Bad quota inode # %lu", qf_inums[type]); -+ return PTR_ERR(qf_inode); -+ } -+ -+ err = dquot_enable(qf_inode, type, format_id, flags); -+ iput(qf_inode); -+ -+ return err; -+} -+ -+/* Enable usage tracking for all quota types. */ -+static int ext4_enable_quotas(struct super_block *sb) -+{ -+ int type, err = 0; -+ unsigned long qf_inums[MAXQUOTAS] = { -+ le32_to_cpu(EXT4_SB(sb)->s_es->s_usr_quota_inum), -+ le32_to_cpu(EXT4_SB(sb)->s_es->s_grp_quota_inum) -+ }; -+ -+ sb_dqopt(sb)->flags |= DQUOT_QUOTA_SYS_FILE; -+ for (type = 0; type < MAXQUOTAS; type++) { -+ if (qf_inums[type]) { -+ err = ext4_quota_enable(sb, type, QFMT_VFS_V1, -+ DQUOT_USAGE_ENABLED); -+ if (err) { -+ ext4_warning(sb, -+ "Failed to enable quota (type=%d) " -+ "tracking. Please run e2fsck to fix.", -+ type); -+ return err; -+ } -+ } -+ } -+ return 0; -+} -+ -+/* -+ * quota_on function that is used when QUOTA feature is set. -+ */ -+static int ext4_quota_on_sysfile(struct super_block *sb, int type, -+ int format_id) -+{ -+ if (!EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_QUOTA)) -+ return -EINVAL; -+ -+ /* -+ * USAGE was enabled at mount time. Only need to enable LIMITS now. -+ */ -+ return ext4_quota_enable(sb, type, format_id, DQUOT_LIMITS_ENABLED); -+} -+ - static int ext4_quota_off(struct super_block *sb, int type) - { - struct inode *inode = sb_dqopt(sb)->files[type]; -@@ -4776,6 +4895,18 @@ out: - return dquot_quota_off(sb, type); - } - -+/* -+ * quota_off function that is used when QUOTA feature is set. -+ */ -+static int ext4_quota_off_sysfile(struct super_block *sb, int type) -+{ -+ if (!EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_QUOTA)) -+ return -EINVAL; -+ -+ /* Disable only the limits. */ -+ return dquot_disable(sb, type, DQUOT_LIMITS_ENABLED); -+} -+ - /* Read data from quotafile - avoid pagecache and such because we cannot afford - * acquiring the locks... As quota files are never truncated and quota code - * itself serializes the operations (and no one else should touch the files) diff --git a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-map_inode_page-3.0.patch b/ldiskfs/kernel_patches/patches/sles11sp2/ext4-map_inode_page-3.0.patch deleted file mode 100644 index a044252..0000000 --- a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-map_inode_page-3.0.patch +++ /dev/null @@ -1,85 +0,0 @@ ---- - fs/ext4/ext4.h | 3 ++ - fs/ext4/inode.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 71 insertions(+) - ---- a/fs/ext4/ext4.h -+++ b/fs/ext4/ext4.h -@@ -1838,6 +1838,9 @@ extern int ext4_page_mkwrite(struct vm_a - extern qsize_t *ext4_get_reserved_space(struct inode *inode); - extern void ext4_da_update_reserve_space(struct inode *inode, - int used, int quota_claim); -+extern int ext4_map_inode_page(struct inode *inode, struct page *page, -+ sector_t *blocks, int created); -+ - /* ioctl.c */ - extern long ext4_ioctl(struct file *, unsigned int, unsigned long); - extern long ext4_compat_ioctl(struct file *, unsigned int, unsigned long); ---- a/fs/ext4/inode.c -+++ b/fs/ext4/inode.c -@@ -5968,3 +5968,65 @@ out_unlock: - up_read(&inode->i_alloc_sem); - return ret; - } -+ -+int ext4_map_inode_page(struct inode *inode, struct page *page, -+ sector_t *blocks, int create) -+{ -+ unsigned int blocksize, blocks_per_page; -+ unsigned long iblock; -+ struct ext4_map_blocks map; -+ void *handle; -+ int i, rc = 0, failed = 0, needed_blocks; -+ -+ blocksize = inode->i_sb->s_blocksize; -+ blocks_per_page = PAGE_SIZE >> inode->i_sb->s_blocksize_bits; -+ iblock = page->index * blocks_per_page; -+ -+ for (i = 0; i < blocks_per_page; i++, iblock++) { -+ blocks[i] = ext4_bmap(inode->i_mapping, iblock); -+ if (blocks[i] == 0) { -+ failed++; -+ } -+ } -+ -+ if (failed == 0 || create == 0) -+ return 0; -+ -+ needed_blocks = ext4_writepage_trans_blocks(inode); -+ handle = ext4_journal_start(inode, needed_blocks); -+ if (IS_ERR(handle)) -+ return PTR_ERR(handle); -+ -+ iblock = page->index * blocks_per_page; -+ for (i = 0; i < blocks_per_page; i++, iblock++) { -+ if (blocks[i] != 0) -+ continue; -+ -+ map.m_lblk = iblock; -+ map.m_len = 1; -+ map.m_flags = 0; -+ rc = ext4_ind_map_blocks(handle, inode, &map, -+ EXT4_GET_BLOCKS_CREATE); -+ if (rc < 0) { -+ printk(KERN_INFO "ext4_map_inode_page: error reading " -+ "block %ld\n", iblock); -+ goto out; -+ } else { -+ if (rc > 1) -+ WARN_ON(1); -+ rc = 0; -+ } -+ /* Unmap any metadata buffers from the block mapping, to avoid -+ * data corruption due to direct-write from Lustre being -+ * clobbered by a later flush of the blockdev metadata buffer.*/ -+ if (map.m_flags & EXT4_MAP_NEW) -+ unmap_underlying_metadata(inode->i_sb->s_bdev, -+ map.m_pblk); -+ blocks[i] = map.m_pblk; -+ } -+ -+out: -+ ext4_journal_stop(handle); -+ return rc; -+} -+EXPORT_SYMBOL(ext4_map_inode_page); diff --git a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-max-dir-size-options.patch b/ldiskfs/kernel_patches/patches/sles11sp2/ext4-max-dir-size-options.patch deleted file mode 100644 index f2c7e5a..0000000 --- a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-max-dir-size-options.patch +++ /dev/null @@ -1,33 +0,0 @@ -diff -urpN linux-stage.orig/fs/ext4/super.c linux-stage/fs/ext4/super.c ---- linux-stage.orig/fs/ext4/super.c 2013-05-13 11:04:01.000000000 -0400 -+++ linux-stage/fs/ext4/super.c 2013-05-13 11:05:23.000000000 -0400 -@@ -1369,6 +1369,7 @@ enum { - Opt_extents, Opt_noextents, - Opt_no_mbcache, - Opt_discard, Opt_nodiscard, Opt_init_itable, Opt_noinit_itable, -+ Opt_max_dir_size_kb, - }; - - static const match_table_t tokens = { -@@ -1453,6 +1454,7 @@ static const match_table_t tokens = { - {Opt_init_itable, "init_itable=%u"}, - {Opt_init_itable, "init_itable"}, - {Opt_noinit_itable, "noinit_itable"}, -+ {Opt_max_dir_size_kb, "max_dir_size_kb=%u"}, - {Opt_err, NULL}, - }; - -@@ -1871,6 +1873,13 @@ set_qf_format: - case Opt_nomblk_io_submit: - clear_opt(sb, MBLK_IO_SUBMIT); - break; -+ case Opt_max_dir_size_kb: -+ if (match_int(&args[0], &option)) -+ return 0; -+ if (option < 0) -+ return 0; -+ sbi->s_max_dir_size = option * 1024; -+ break; - case Opt_stripe: - if (match_int(&args[0], &option)) - return 0; diff --git a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-mballoc-extra-checks.patch b/ldiskfs/kernel_patches/patches/sles11sp2/ext4-mballoc-extra-checks.patch deleted file mode 100644 index 06029db..0000000 --- a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-mballoc-extra-checks.patch +++ /dev/null @@ -1,321 +0,0 @@ ---- - fs/ext4/ext4.h | 1 - fs/ext4/mballoc.c | 109 ++++++++++++++++++++++++++++++++++++++++++++++-------- - fs/ext4/mballoc.h | 2 - - 3 files changed, 96 insertions(+), 16 deletions(-) - ---- a/fs/ext4/ext4.h -+++ b/fs/ext4/ext4.h -@@ -2098,6 +2098,7 @@ struct ext4_group_info { - ext4_grpblk_t bb_fragments; /* nr of freespace fragments */ - ext4_grpblk_t bb_largest_free_order;/* order of largest frag in BG */ - struct list_head bb_prealloc_list; -+ unsigned long bb_prealloc_nr; - #ifdef DOUBLE_CHECK - void *bb_bitmap; - #endif ---- a/fs/ext4/mballoc.c -+++ b/fs/ext4/mballoc.c -@@ -352,7 +352,7 @@ static const char *ext4_groupinfo_slab_n - "ext4_groupinfo_64k", "ext4_groupinfo_128k" - }; - --static void ext4_mb_generate_from_pa(struct super_block *sb, void *bitmap, -+static int ext4_mb_generate_from_pa(struct super_block *sb, void *bitmap, - ext4_group_t group); - static void ext4_mb_generate_from_freelist(struct super_block *sb, void *bitmap, - ext4_group_t group); -@@ -702,7 +702,7 @@ mb_set_largest_free_order(struct super_b - } - - static noinline_for_stack --void ext4_mb_generate_buddy(struct super_block *sb, -+int ext4_mb_generate_buddy(struct super_block *sb, - void *buddy, void *bitmap, ext4_group_t group) - { - struct ext4_group_info *grp = ext4_get_group_info(sb, group); -@@ -734,14 +734,19 @@ void ext4_mb_generate_buddy(struct super - grp->bb_fragments = fragments; - - if (free != grp->bb_free) { -+ struct ext4_group_desc *gdp; -+ gdp = ext4_get_group_desc (sb, group, NULL); - ext4_grp_locked_error(sb, group, 0, 0, -- "%u blocks in bitmap, %u in gd", -- free, grp->bb_free); -+ "%u blocks in bitmap, %u in bb, %u in gd", -+ free, grp->bb_free, -+ ext4_free_blks_count(sb, gdp)); -+ - /* - * If we intent to continue, we consider group descritor - * corrupt and update bb_free using bitmap value - */ - grp->bb_free = free; -+ return -EIO; - } - mb_set_largest_free_order(sb, grp); - -@@ -752,6 +757,8 @@ void ext4_mb_generate_buddy(struct super - EXT4_SB(sb)->s_mb_buddies_generated++; - EXT4_SB(sb)->s_mb_generation_time += period; - spin_unlock(&EXT4_SB(sb)->s_bal_lock); -+ -+ return 0; - } - - /* The buddy information is attached the buddy cache inode -@@ -898,7 +905,7 @@ static int ext4_mb_init_cache(struct pag - - err = 0; - first_block = page->index * blocks_per_page; -- for (i = 0; i < blocks_per_page; i++) { -+ for (i = 0; i < blocks_per_page && err == 0; i++) { - int group; - - group = (first_block + i) >> 1; -@@ -939,7 +946,7 @@ static int ext4_mb_init_cache(struct pag - ext4_lock_group(sb, group); - /* init the buddy */ - memset(data, 0xff, blocksize); -- ext4_mb_generate_buddy(sb, data, incore, group); -+ err = ext4_mb_generate_buddy(sb, data, incore, group); - ext4_unlock_group(sb, group); - incore = NULL; - } else { -@@ -954,7 +961,7 @@ static int ext4_mb_init_cache(struct pag - memcpy(data, bitmap, blocksize); - - /* mark all preallocated blks used in in-core bitmap */ -- ext4_mb_generate_from_pa(sb, data, group); -+ err = ext4_mb_generate_from_pa(sb, data, group); - ext4_mb_generate_from_freelist(sb, data, group); - ext4_unlock_group(sb, group); - -@@ -964,7 +971,8 @@ static int ext4_mb_init_cache(struct pag - incore = data; - } - } -- SetPageUptodate(page); -+ if (likely(err == 0)) -+ SetPageUptodate(page); - - out: - if (bh) { -@@ -2148,9 +2156,11 @@ static void *ext4_mb_seq_groups_next(str - static int ext4_mb_seq_groups_show(struct seq_file *seq, void *v) - { - struct super_block *sb = seq->private; -+ struct ext4_group_desc *gdp; - ext4_group_t group = (ext4_group_t) ((unsigned long) v); - int i; - int err; -+ int free = 0; - struct ext4_buddy e4b; - struct sg { - struct ext4_group_info info; -@@ -2159,10 +2169,10 @@ static int ext4_mb_seq_groups_show(struc - - group--; - if (group == 0) -- seq_printf(seq, "#%-5s: %-5s %-5s %-5s " -+ seq_printf(seq, "#%-5s: %-5s %-5s %-5s %-5s %-5s" - "[ %-5s %-5s %-5s %-5s %-5s %-5s %-5s " - "%-5s %-5s %-5s %-5s %-5s %-5s %-5s ]\n", -- "group", "free", "frags", "first", -+ "group", "free", "free", "frags", "first", "pa", - "2^0", "2^1", "2^2", "2^3", "2^4", "2^5", "2^6", - "2^7", "2^8", "2^9", "2^10", "2^11", "2^12", "2^13"); - -@@ -2173,13 +2183,20 @@ static int ext4_mb_seq_groups_show(struc - seq_printf(seq, "#%-5u: I/O error\n", group); - return 0; - } -+ -+ gdp = ext4_get_group_desc(sb, group, NULL); -+ if (gdp != NULL) -+ free = ext4_free_blks_count(sb, gdp); -+ - ext4_lock_group(sb, group); - memcpy(&sg, ext4_get_group_info(sb, group), i); - ext4_unlock_group(sb, group); - ext4_mb_unload_buddy(&e4b); - -- seq_printf(seq, "#%-5u: %-5u %-5u %-5u [", group, sg.info.bb_free, -- sg.info.bb_fragments, sg.info.bb_first_free); -+ seq_printf(seq, "#%-5lu: %-5u %-5u %-5u %-5u %-5lu [", -+ (long unsigned int)group, sg.info.bb_free, free, -+ sg.info.bb_fragments, sg.info.bb_first_free, -+ sg.info.bb_prealloc_nr); - for (i = 0; i <= 13; i++) - seq_printf(seq, " %-5u", i <= sb->s_blocksize_bits + 1 ? - sg.info.bb_counters[i] : 0); -@@ -3417,23 +3434,72 @@ static void ext4_mb_generate_from_freeli - } - - /* -+ * check free blocks in bitmap match free block in group descriptor -+ * do this before taking preallocated blocks into account to be able -+ * to detect on-disk corruptions. The group lock should be hold by the -+ * caller. -+ */ -+int ext4_mb_check_ondisk_bitmap(struct super_block *sb, void *bitmap, -+ struct ext4_group_desc *gdp, int group) -+{ -+ unsigned short max = EXT4_BLOCKS_PER_GROUP(sb); -+ unsigned short i, first, free = 0; -+ unsigned short free_in_gdp = ext4_free_blks_count(sb, gdp); -+ -+ if (gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) -+ return 0; -+ -+ i = mb_find_next_zero_bit(bitmap, max, 0); -+ -+ while (i < max) { -+ first = i; -+ i = mb_find_next_bit(bitmap, max, i); -+ if (i > max) -+ i = max; -+ free += i - first; -+ if (i < max) -+ i = mb_find_next_zero_bit(bitmap, max, i); -+ } -+ -+ if (free != free_in_gdp) { -+ ext4_error(sb, "on-disk bitmap for group %d" -+ "corrupted: %u blocks free in bitmap, %u - in gd\n", -+ group, free, free_in_gdp); -+ return -EIO; -+ } -+ return 0; -+} -+ -+/* - * the function goes through all preallocation in this group and marks them - * used in in-core bitmap. buddy must be generated from this bitmap - * Need to be called with ext4 group lock held - */ - static noinline_for_stack --void ext4_mb_generate_from_pa(struct super_block *sb, void *bitmap, -+int ext4_mb_generate_from_pa(struct super_block *sb, void *bitmap, - ext4_group_t group) - { - struct ext4_group_info *grp = ext4_get_group_info(sb, group); - struct ext4_prealloc_space *pa; -+ struct ext4_group_desc *gdp; - struct list_head *cur; - ext4_group_t groupnr; - ext4_grpblk_t start; - int preallocated = 0; - int count = 0; -+ int skip = 0; -+ int err; - int len; - -+ gdp = ext4_get_group_desc (sb, group, NULL); -+ if (gdp == NULL) -+ return -EIO; -+ -+ /* before applying preallocations, check bitmap consistency */ -+ err = ext4_mb_check_ondisk_bitmap(sb, bitmap, gdp, group); -+ if (err) -+ return err; -+ - /* all form of preallocation discards first load group, - * so the only competing code is preallocation use. - * we don't need any locking here -@@ -3449,14 +3511,23 @@ void ext4_mb_generate_from_pa(struct sup - &groupnr, &start); - len = pa->pa_len; - spin_unlock(&pa->pa_lock); -- if (unlikely(len == 0)) -+ if (unlikely(len == 0)) { -+ skip++; - continue; -+ } - BUG_ON(groupnr != group); - mb_set_bits(bitmap, start, len); - preallocated += len; - count++; - } -+ if (count + skip != grp->bb_prealloc_nr) { -+ ext4_error(sb, "lost preallocations: " -+ "count %d, bb_prealloc_nr %lu, skip %d\n", -+ count, grp->bb_prealloc_nr, skip); -+ return -EIO; -+ } - mb_debug(1, "prellocated %u for group %u\n", preallocated, group); -+ return 0; - } - - static void ext4_mb_pa_callback(struct rcu_head *head) -@@ -3515,6 +3586,7 @@ static void ext4_mb_put_pa(struct ext4_a - */ - ext4_lock_group(sb, grp); - list_del(&pa->pa_group_list); -+ ext4_get_group_info(sb, grp)->bb_prealloc_nr--; - ext4_unlock_group(sb, grp); - - spin_lock(pa->pa_obj_lock); -@@ -3606,6 +3678,7 @@ ext4_mb_new_inode_pa(struct ext4_allocat - - ext4_lock_group(sb, ac->ac_b_ex.fe_group); - list_add(&pa->pa_group_list, &grp->bb_prealloc_list); -+ grp->bb_prealloc_nr++; - ext4_unlock_group(sb, ac->ac_b_ex.fe_group); - - spin_lock(pa->pa_obj_lock); -@@ -3667,6 +3740,7 @@ ext4_mb_new_group_pa(struct ext4_allocat - - ext4_lock_group(sb, ac->ac_b_ex.fe_group); - list_add(&pa->pa_group_list, &grp->bb_prealloc_list); -+ grp->bb_prealloc_nr++; - ext4_unlock_group(sb, ac->ac_b_ex.fe_group); - - /* -@@ -3835,6 +3909,8 @@ repeat: - - spin_unlock(&pa->pa_lock); - -+ BUG_ON(grp->bb_prealloc_nr == 0); -+ grp->bb_prealloc_nr--; - list_del(&pa->pa_group_list); - list_add(&pa->u.pa_tmp_list, &list); - } -@@ -3968,7 +4044,7 @@ repeat: - if (err) { - ext4_error(sb, "Error loading buddy information for %u", - group); -- continue; -+ return; - } - - bitmap_bh = ext4_read_block_bitmap(sb, group); -@@ -3980,6 +4056,8 @@ repeat: - } - - ext4_lock_group(sb, group); -+ BUG_ON(e4b.bd_info->bb_prealloc_nr == 0); -+ e4b.bd_info->bb_prealloc_nr--; - list_del(&pa->pa_group_list); - ext4_mb_release_inode_pa(&e4b, bitmap_bh, pa); - ext4_unlock_group(sb, group); -@@ -4240,6 +4318,7 @@ ext4_mb_discard_lg_preallocations(struct - } - ext4_lock_group(sb, group); - list_del(&pa->pa_group_list); -+ ext4_get_group_info(sb, group)->bb_prealloc_nr--; - ext4_mb_release_group_pa(&e4b, pa); - ext4_unlock_group(sb, group); - ---- a/fs/ext4/mballoc.h -+++ b/fs/ext4/mballoc.h -@@ -87,7 +87,7 @@ extern u8 mb_enable_debug; - /* - * for which requests use 2^N search using buddies - */ --#define MB_DEFAULT_ORDER2_REQS 2 -+#define MB_DEFAULT_ORDER2_REQS 8 - - /* - * default group prealloc size 512 blocks diff --git a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-mballoc-pa_free-mismatch.patch b/ldiskfs/kernel_patches/patches/sles11sp2/ext4-mballoc-pa_free-mismatch.patch deleted file mode 100644 index c21573e..0000000 --- a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-mballoc-pa_free-mismatch.patch +++ /dev/null @@ -1,109 +0,0 @@ -diff -r -u linux-stage.orig/fs/ext4/mballoc.c linux-stage/fs/ext4/mballoc.c ---- linux-stage.orig/fs/ext4/mballoc.c 2012-12-31 15:18:15.000000000 -0500 -+++ linux-stage/fs/ext4/mballoc.c 2012-12-31 15:23:38.000000000 -0500 -@@ -3643,6 +3643,7 @@ - INIT_LIST_HEAD(&pa->pa_group_list); - pa->pa_deleted = 0; - pa->pa_type = MB_INODE_PA; -+ pa->pa_error = 0; - - mb_debug(1, "new inode pa %p: %llu/%u for %u\n", pa, - pa->pa_pstart, pa->pa_len, pa->pa_lstart); -@@ -3704,6 +3705,7 @@ - INIT_LIST_HEAD(&pa->pa_group_list); - pa->pa_deleted = 0; - pa->pa_type = MB_GROUP_PA; -+ pa->pa_error = 0; - - mb_debug(1, "new group pa %p: %llu/%u for %u\n", pa, - pa->pa_pstart, pa->pa_len, pa->pa_lstart); -@@ -3764,7 +3766,9 @@ - int err = 0; - int free = 0; - -+ assert_spin_locked(ext4_group_lock_ptr(sb, e4b->bd_group)); - BUG_ON(pa->pa_deleted == 0); -+ BUG_ON(pa->pa_inode == NULL); - ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit); - grp_blk_start = pa->pa_pstart - bit; - BUG_ON(group != e4b->bd_group && pa->pa_len != 0); -@@ -3786,19 +3790,27 @@ - mb_free_blocks(pa->pa_inode, e4b, bit, next - bit); - bit = next + 1; - } -- if (free != pa->pa_free) { -- ext4_msg(e4b->bd_sb, KERN_CRIT, -- "pa %p: logic %lu, phys. %lu, len %lu", -- pa, (unsigned long) pa->pa_lstart, -- (unsigned long) pa->pa_pstart, -- (unsigned long) pa->pa_len); -- ext4_grp_locked_error(sb, group, 0, 0, "free %u, pa_free %u", -+ -+ /* "free < pa->pa_free" means we maybe double alloc the same blocks, -+ * otherwise maybe leave some free blocks unavailable, no need to BUG.*/ -+ if ((free > pa->pa_free && !pa->pa_error) || (free < pa->pa_free)) { -+ ext4_error(sb, "pa free mismatch: [pa %p] " -+ "[phy %lu] [logic %lu] [len %u] [free %u] " -+ "[error %u] [inode %lu] [freed %u]", pa, -+ (unsigned long)pa->pa_pstart, -+ (unsigned long)pa->pa_lstart, -+ (unsigned)pa->pa_len, (unsigned)pa->pa_free, -+ (unsigned)pa->pa_error, pa->pa_inode->i_ino, -+ free); -+ ext4_grp_locked_error(sb, group, 0, 0, -+ "free %u, pa_free %u", - free, pa->pa_free); - /* - * pa is already deleted so we use the value obtained - * from the bitmap and continue. - */ - } -+ BUG_ON(pa->pa_free != free); - atomic_add(free, &sbi->s_mb_discarded); - - return err; -@@ -4542,6 +4555,25 @@ - ac->ac_b_ex.fe_len = 0; - ar->len = 0; - ext4_mb_show_ac(ac); -+ if (ac->ac_pa) { -+ struct ext4_prealloc_space *pa = ac->ac_pa; -+ -+ /* We can not make sure whether the bitmap has -+ * been updated or not when fail case. So can -+ * not revert pa_free back, just mark pa_error*/ -+ pa->pa_error++; -+ ext4_error(sb, -+ "Updating bitmap error: [err %d] " -+ "[pa %p] [phy %lu] [logic %lu] " -+ "[len %u] [free %u] [error %u] " -+ "[inode %lu]", *errp, pa, -+ (unsigned long)pa->pa_pstart, -+ (unsigned long)pa->pa_lstart, -+ (unsigned)pa->pa_len, -+ (unsigned)pa->pa_free, -+ (unsigned)pa->pa_error, -+ pa->pa_inode ? pa->pa_inode->i_ino : 0); -+ } - } - ext4_mb_release_context(ac); - out: -diff -r -u linux-stage.orig/fs/ext4/mballoc.h linux-stage/fs/ext4/mballoc.h ---- linux-stage.orig/fs/ext4/mballoc.h 2012-12-31 15:18:15.000000000 -0500 -+++ linux-stage/fs/ext4/mballoc.h 2012-12-31 15:19:22.000000000 -0500 -@@ -19,6 +19,7 @@ - #include - #include - #include -+#include - #include "ext4_jbd2.h" - #include "ext4.h" - -@@ -129,6 +130,7 @@ - ext4_grpblk_t pa_free; /* how many blocks are free */ - unsigned short pa_type; /* pa type. inode or group */ - spinlock_t *pa_obj_lock; -+ unsigned short pa_error; - struct inode *pa_inode; /* hack, for history only */ - }; - diff --git a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-misc.patch b/ldiskfs/kernel_patches/patches/sles11sp2/ext4-misc.patch deleted file mode 100644 index d950bc0..0000000 --- a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-misc.patch +++ /dev/null @@ -1,122 +0,0 @@ ---- - fs/ext4/ext4.h | 6 +++++ - fs/ext4/ext4_extents.h | 10 +++++++++ - fs/ext4/ext4_jbd2.h | 3 ++ - fs/ext4/extents.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ - fs/ext4/super.c | 12 +++++++++++ - 5 files changed, 81 insertions(+) - ---- a/fs/ext4/ext4.h -+++ b/fs/ext4/ext4.h -@@ -1826,6 +1829,9 @@ extern void ext4_add_groupblocks(handle_ - ext4_fsblk_t block, unsigned long count); - extern int ext4_trim_fs(struct super_block *, struct fstrim_range *); - -+extern void ext4_mb_discard_inode_preallocations(struct inode *); -+ -+ - /* inode.c */ - struct buffer_head *ext4_getblk(handle_t *, struct inode *, - ext4_lblk_t, int, int *); ---- a/fs/ext4/ext4_extents.h -+++ b/fs/ext4/ext4_extents.h -@@ -58,6 +58,13 @@ - */ - #define EXT_STATS_ - -+/* -+ * define EXT4_ALLOC_NEEDED to 0 since block bitmap, group desc. and sb -+ * are now accounted in ext4_ext_calc_credits_for_insert() -+ */ -+#define EXT4_ALLOC_NEEDED 0 -+#define HAVE_EXT_PREPARE_CB_EXTENT -+#define HAVE_EXT4_EXT_PBLOCK - - /* - * ext4_inode has i_block array (60 bytes total). -@@ -241,6 +248,7 @@ static inline ext4_fsblk_t ext4_ext_pblo - block |= ((ext4_fsblk_t) le16_to_cpu(ex->ee_start_hi) << 31) << 1; - return block; - } -+#define ext_pblock(ex) ext4_ext_pblock(ex) - - /* - * ext4_idx_pblock: -@@ -287,6 +295,8 @@ extern int ext4_extent_tree_init(handle_ - extern int ext4_ext_calc_credits_for_single_extent(struct inode *inode, - int num, - struct ext4_ext_path *path); -+extern int ext4_ext_calc_credits_for_insert(struct inode *, -+ struct ext4_ext_path *); - extern int ext4_can_extents_be_merged(struct inode *inode, - struct ext4_extent *ex1, - struct ext4_extent *ex2); ---- a/fs/ext4/ext4_jbd2.h -+++ b/fs/ext4/ext4_jbd2.h -@@ -175,6 +177,7 @@ static inline void ext4_journal_callback - list_del_init(&jce->jce_list); - spin_unlock(&sbi->s_md_lock); - } -+#define HAVE_EXT4_JOURNAL_CALLBACK_ADD - - int - ext4_mark_iloc_dirty(handle_t *handle, ---- a/fs/ext4/extents.c -+++ b/fs/ext4/extents.c -@@ -2205,6 +2205,56 @@ int ext4_ext_calc_credits_for_single_ext - } - - /* -+ * This routine returns max. credits extent tree can consume. -+ * It should be OK for low-performance paths like ->writepage() -+ * To allow many writing process to fit a single transaction, -+ * caller should calculate credits under truncate_mutex and -+ * pass actual path. -+ */ -+int ext4_ext_calc_credits_for_insert(struct inode *inode, -+ struct ext4_ext_path *path) -+{ -+ int depth, needed; -+ -+ if (path) { -+ /* probably there is space in leaf? */ -+ depth = path->p_depth; -+ if (le16_to_cpu(path[depth].p_hdr->eh_entries) -+ < le16_to_cpu(path[depth].p_hdr->eh_max)) -+ return 1; -+ } -+ -+ /* -+ * given 32bit logical block (4294967296 blocks), max. tree -+ * can be 4 levels in depth -- 4 * 340^4 == 53453440000. -+ * let's also add one more level for imbalance. -+ */ -+ depth = 5; -+ -+ /* allocation of new data block(s) */ -+ needed = 2; -+ -+ /* -+ * tree can be full, so it'd need to grow in depth: -+ * we need one credit to modify old root, credits for -+ * new root will be added in split accounting -+ */ -+ needed += 1; -+ /* -+ * Index split can happen, we'd need: -+ * allocate intermediate indexes (bitmap + group) -+ * + change two blocks at each level, but root (already included) -+ */ -+ needed += (depth * 2) + (depth * 2); -+ -+ /* any allocation modifies superblock */ -+ needed += 1; -+ -+ return needed; -+} -+EXPORT_SYMBOL(ext4_ext_calc_credits_for_insert); -+ -+/* - * How many index/leaf blocks need to change/allocate to modify nrblocks? - * - * if nrblocks are fit in a single extent (chunk flag is 1), then diff --git a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-mmp-dont-mark-bh-dirty.patch b/ldiskfs/kernel_patches/patches/sles11sp2/ext4-mmp-dont-mark-bh-dirty.patch deleted file mode 100644 index 3ddedd2..0000000 --- a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-mmp-dont-mark-bh-dirty.patch +++ /dev/null @@ -1,35 +0,0 @@ -From fe18d649891d813964d3aaeebad873f281627fbc Mon Sep 17 00:00:00 2001 -From: Li Dongyang -Date: Sat, 15 Sep 2018 17:11:25 -0400 -Subject: [PATCH] ext4: don't mark mmp buffer head dirty - -Marking mmp bh dirty before writing it will make writeback -pick up mmp block later and submit a write, we don't want the -duplicate write as kmmpd thread should have full control of -reading and writing the mmp block. -Another reason is we will also have random I/O error on -the writeback request when blk integrity is enabled, because -kmmpd could modify the content of the mmp block(e.g. setting -new seq and time) while the mmp block is under I/O requested -by writeback. - -Signed-off-by: Li Dongyang -Signed-off-by: Theodore Ts'o -Reviewed-by: Andreas Dilger -Cc: stable@vger.kernel.org ---- - fs/ext4/mmp.c | 1 - - 1 file changed, 1 deletion(-) - -Index: linux-stage/fs/ext4/mmp.c -=================================================================== ---- linux-stage.orig/fs/ext4/mmp.c -+++ linux-stage/fs/ext4/mmp.c -@@ -12,7 +12,6 @@ - */ - static int write_mmp_block(struct buffer_head *bh) - { -- mark_buffer_dirty(bh); - lock_buffer(bh); - bh->b_end_io = end_buffer_write_sync; - get_bh(bh); diff --git a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-osd-iop-common.patch b/ldiskfs/kernel_patches/patches/sles11sp2/ext4-osd-iop-common.patch deleted file mode 100644 index 2a4c05e..0000000 --- a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-osd-iop-common.patch +++ /dev/null @@ -1,216 +0,0 @@ -diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h -index 986e058..344ed3a 100644 ---- a/fs/ext4/ext4.h -+++ b/fs/ext4/ext4.h -@@ -1879,6 +1879,14 @@ extern int ext4_orphan_add(handle_t *, struct inode *); - extern int ext4_orphan_del(handle_t *, struct inode *); - extern int ext4_htree_fill_tree(struct file *dir_file, __u32 start_hash, - __u32 start_minor_hash, __u32 *next_hash); -+extern struct inode *ext4_create_inode(handle_t *handle, -+ struct inode * dir, int mode, -+ uid_t *owner); -+extern int ext4_delete_entry(handle_t *handle, struct inode * dir, -+ struct ext4_dir_entry_2 * de_del, -+ struct buffer_head * bh); -+extern int ext4_add_dot_dotdot(handle_t *handle, struct inode *dir, -+ struct inode *inode); - - /* resize.c */ - extern int ext4_group_add(struct super_block *sb, -diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c -index cb049fe..2071f02 100644 ---- a/fs/ext4/namei.c -+++ b/fs/ext4/namei.c -@@ -24,6 +24,7 @@ - * Theodore Ts'o, 2002 - */ - -+#include - #include - #include - #include -@@ -1688,10 +1689,10 @@ cleanup: - * ext4_delete_entry deletes a directory entry by merging it with the - * previous entry - */ --static int ext4_delete_entry(handle_t *handle, -- struct inode *dir, -- struct ext4_dir_entry_2 *de_del, -- struct buffer_head *bh) -+int ext4_delete_entry(handle_t *handle, -+ struct inode *dir, -+ struct ext4_dir_entry_2 *de_del, -+ struct buffer_head *bh) - { - struct ext4_dir_entry_2 *de, *pde; - unsigned int blocksize = dir->i_sb->s_blocksize; -@@ -1734,7 +1735,7 @@ static int ext4_delete_entry(handle_t *handle, - } - return -ENOENT; - } -- -+EXPORT_SYMBOL(ext4_delete_entry); - /* - * DIR_NLINK feature is set if 1) nlinks > EXT4_LINK_MAX or 2) nlinks == 2, - * since this indicates that nlinks count was previously 1. -@@ -1781,6 +1782,30 @@ static int ext4_add_nondir(handle_t *handle, - return err; - } - -+ /* Return locked inode, then the caller can modify the inode's states/flags -+ * before others finding it. The caller should unlock the inode by itself. */ -+struct inode *ext4_create_inode(handle_t *handle, struct inode *dir, int mode, -+ uid_t *owner) -+{ -+ struct inode *inode; -+ -+ inode = ext4_new_inode(handle, dir, mode, NULL, -+ EXT4_SB(dir->i_sb)->s_inode_goal); -+ if (!IS_ERR(inode)) { -+ if (S_ISCHR(mode) || S_ISBLK(mode) || S_ISFIFO(mode)) { -+#ifdef CONFIG_EXT4_FS_XATTR -+ inode->i_op = &ext4_special_inode_operations; -+#endif -+ } else { -+ inode->i_op = &ext4_file_inode_operations; -+ inode->i_fop = &ext4_file_operations; -+ ext4_set_aops(inode); -+ } -+ } -+ return inode; -+} -+EXPORT_SYMBOL(ext4_create_inode); -+ - /* - * By the time this is called, we already have created - * the directory cache entry for the new file, but it -@@ -1857,46 +1882,32 @@ retry: - return err; - } - --static int ext4_mkdir(struct inode *dir, struct dentry *dentry, int mode) -+/* Initialize @inode as a subdirectory of @dir, and add the -+ * "." and ".." entries into the first directory block. */ -+int ext4_add_dot_dotdot(handle_t *handle, struct inode * dir, -+ struct inode *inode) - { -- handle_t *handle; -- struct inode *inode; -- struct buffer_head *dir_block = NULL; -+ struct buffer_head *dir_block; - struct ext4_dir_entry_2 *de; - unsigned int blocksize = dir->i_sb->s_blocksize; -- int err, retries = 0; -- -- if (EXT4_DIR_LINK_MAX(dir)) -- return -EMLINK; -- -- dquot_initialize(dir); -+ int err = 0; - --retry: -- handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + -- EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 + -- EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb)); - if (IS_ERR(handle)) - return PTR_ERR(handle); - - if (IS_DIRSYNC(dir)) - ext4_handle_sync(handle); - -- inode = ext4_new_inode(handle, dir, S_IFDIR | mode, -- &dentry->d_name, 0); -- err = PTR_ERR(inode); -- if (IS_ERR(inode)) -- goto out_stop; -- - inode->i_op = &ext4_dir_inode_operations; - inode->i_fop = &ext4_dir_operations; - inode->i_size = EXT4_I(inode)->i_disksize = inode->i_sb->s_blocksize; - dir_block = ext4_bread(handle, inode, 0, 1, &err); - if (!dir_block) -- goto out_clear_inode; -+ goto get_out; - BUFFER_TRACE(dir_block, "get_write_access"); - err = ext4_journal_get_write_access(handle, dir_block); - if (err) -- goto out_clear_inode; -+ goto get_out; - de = (struct ext4_dir_entry_2 *) dir_block->b_data; - de->inode = cpu_to_le32(inode->i_ino); - de->name_len = 1; -@@ -1915,18 +1926,46 @@ retry: - BUFFER_TRACE(dir_block, "call ext4_handle_dirty_metadata"); - err = ext4_handle_dirty_metadata(handle, inode, dir_block); - if (err) -- goto out_clear_inode; -+ goto get_out; - err = ext4_mark_inode_dirty(handle, inode); -- if (!err) -- err = ext4_add_entry(handle, dentry, inode); -- if (err) { --out_clear_inode: -- clear_nlink(inode); -- unlock_new_inode(inode); -- ext4_mark_inode_dirty(handle, inode); -- iput(inode); -+get_out: -+ brelse(dir_block); -+ return err; -+} -+EXPORT_SYMBOL(ext4_add_dot_dotdot); -+ -+static int ext4_mkdir(struct inode *dir, struct dentry *dentry, int mode) -+{ -+ handle_t *handle; -+ struct inode *inode; -+ int err, retries = 0; -+ -+ if (EXT4_DIR_LINK_MAX(dir)) -+ return -EMLINK; -+ -+ dquot_initialize(dir); -+ -+retry: -+ handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + -+ EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 + -+ EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb)); -+ if (IS_ERR(handle)) -+ return PTR_ERR(handle); -+ -+ if (IS_DIRSYNC(dir)) -+ ext4_handle_sync(handle); -+ -+ inode = ext4_new_inode(handle, dir, S_IFDIR | mode, &dentry->d_name, 0); -+ err = PTR_ERR(inode); -+ if (IS_ERR(inode)) - goto out_stop; -- } -+ -+ err = ext4_add_dot_dotdot(handle, dir, inode); -+ if (err) -+ goto out_clear_inode; -+ err = ext4_add_entry(handle, dentry, inode); -+ if (err) -+ goto out_clear_inode; - ext4_inc_count(handle, dir); - ext4_update_dx_flag(dir); - err = ext4_mark_inode_dirty(handle, dir); -@@ -1935,11 +1974,16 @@ out_clear_inode: - d_instantiate(dentry, inode); - unlock_new_inode(inode); - out_stop: -- brelse(dir_block); - ext4_journal_stop(handle); - if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries)) - goto retry; - return err; -+out_clear_inode: -+ clear_nlink(inode); -+ unlock_new_inode(inode); -+ ext4_mark_inode_dirty(handle, inode); -+ iput(inode); -+ goto out_stop; - } - - /* diff --git a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-prealloc.patch b/ldiskfs/kernel_patches/patches/sles11sp2/ext4-prealloc.patch deleted file mode 100644 index 1b180ac..0000000 --- a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-prealloc.patch +++ /dev/null @@ -1,391 +0,0 @@ -Index: linux-stage/fs/ext4/ext4.h -=================================================================== ---- linux-stage.orig/fs/ext4/ext4.h -+++ linux-stage/fs/ext4/ext4.h -@@ -1173,11 +1173,14 @@ struct ext4_sb_info { - - /* tunables */ - unsigned long s_stripe; -- unsigned int s_mb_stream_request; -+ unsigned long s_mb_small_req; -+ unsigned long s_mb_large_req; - unsigned int s_mb_max_to_scan; - unsigned int s_mb_min_to_scan; - unsigned int s_mb_stats; - unsigned int s_mb_order2_reqs; -+ unsigned long *s_mb_prealloc_table; -+ unsigned long s_mb_prealloc_table_size; - unsigned int s_mb_group_prealloc; - unsigned int s_max_writeback_mb_bump; - /* where last allocation was done - for stream allocation */ -Index: linux-stage/fs/ext4/inode.c -=================================================================== ---- linux-stage.orig/fs/ext4/inode.c -+++ linux-stage/fs/ext4/inode.c -@@ -2948,6 +2948,11 @@ static int ext4_da_writepages(struct add - if (unlikely(sbi->s_mount_flags & EXT4_MF_FS_ABORTED)) - return -EROFS; - -+ if (wbc->nr_to_write < sbi->s_mb_small_req) { -+ nr_to_writebump = sbi->s_mb_small_req - wbc->nr_to_write; -+ wbc->nr_to_write = sbi->s_mb_small_req; -+ } -+ - if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX) - range_whole = 1; - -Index: linux-stage/fs/ext4/mballoc.c -=================================================================== ---- linux-stage.orig/fs/ext4/mballoc.c -+++ linux-stage/fs/ext4/mballoc.c -@@ -1802,6 +1802,26 @@ void ext4_mb_simple_scan_group(struct ex - } - } - -+static int ext4_mb_prealloc_table_add(struct ext4_sb_info *sbi, int value) -+{ -+ int i; -+ -+ if (value > (sbi->s_blocks_per_group - 1 - 1 - sbi->s_itb_per_group)) -+ return -1; -+ -+ for (i = 0; i < sbi->s_mb_prealloc_table_size; i++) { -+ if (sbi->s_mb_prealloc_table[i] == 0) { -+ sbi->s_mb_prealloc_table[i] = value; -+ return 0; -+ } -+ -+ /* they should add values in order */ -+ if (value <= sbi->s_mb_prealloc_table[i]) -+ return -1; -+ } -+ return -1; -+} -+ - /* - * The routine scans the group and measures all found extents. - * In order to optimize scanning, caller must pass number of -@@ -2179,6 +2199,82 @@ static const struct seq_operations ext4_ - .show = ext4_mb_seq_groups_show, - }; - -+#define EXT4_MB_PREALLOC_TABLE "prealloc_table" -+ -+static int ext4_mb_prealloc_table_proc_read(char *page, char **start, off_t off, -+ int count, int *eof, void *data) -+{ -+ struct ext4_sb_info *sbi = data; -+ int len = 0; -+ int i; -+ -+ *eof = 1; -+ if (off != 0) -+ return 0; -+ -+ for (i = 0; i < sbi->s_mb_prealloc_table_size; i++) -+ len += sprintf(page + len, "%ld ", -+ sbi->s_mb_prealloc_table[i]); -+ len += sprintf(page + len, "\n"); -+ -+ *start = page; -+ return len; -+} -+ -+static int ext4_mb_prealloc_table_proc_write(struct file *file, -+ const char __user *buf, -+ unsigned long cnt, void *data) -+{ -+ struct ext4_sb_info *sbi = data; -+ unsigned long value; -+ unsigned long prev = 0; -+ char str[128]; -+ char *cur; -+ char *end; -+ unsigned long *new_table; -+ int num = 0; -+ int i = 0; -+ -+ if (cnt >= sizeof(str)) -+ return -EINVAL; -+ if (copy_from_user(str, buf, cnt)) -+ return -EFAULT; -+ -+ num = 0; -+ cur = str; -+ end = str + cnt; -+ while (cur < end) { -+ while ((cur < end) && (*cur == ' ')) cur++; -+ value = simple_strtol(cur, &cur, 0); -+ if (value == 0) -+ break; -+ if (value <= prev) -+ return -EINVAL; -+ prev = value; -+ num++; -+ } -+ -+ new_table = kmalloc(num * sizeof(*new_table), GFP_KERNEL); -+ if (new_table == NULL) -+ return -ENOMEM; -+ kfree(sbi->s_mb_prealloc_table); -+ memset(new_table, 0, num * sizeof(*new_table)); -+ sbi->s_mb_prealloc_table = new_table; -+ sbi->s_mb_prealloc_table_size = num; -+ cur = str; -+ end = str + cnt; -+ while (cur < end && i < num) { -+ while ((cur < end) && (*cur == ' ')) cur++; -+ value = simple_strtol(cur, &cur, 0); -+ if (ext4_mb_prealloc_table_add(sbi, value) == 0) -+ i++; -+ } -+ if (i != num) -+ sbi->s_mb_prealloc_table_size = i; -+ -+ return cnt; -+} -+ - static int ext4_mb_seq_groups_open(struct inode *inode, struct file *file) - { - struct super_block *sb = PDE(inode)->data; -@@ -2425,7 +2521,7 @@ static int ext4_groupinfo_create_slab(si - int ext4_mb_init(struct super_block *sb, int needs_recovery) - { - struct ext4_sb_info *sbi = EXT4_SB(sb); -- unsigned i, j; -+ unsigned i, j, k, l; - unsigned offset; - unsigned max; - int ret; -@@ -2476,9 +2572,51 @@ int ext4_mb_init(struct super_block *sb, - sbi->s_mb_max_to_scan = MB_DEFAULT_MAX_TO_SCAN; - sbi->s_mb_min_to_scan = MB_DEFAULT_MIN_TO_SCAN; - sbi->s_mb_stats = MB_DEFAULT_STATS; -- sbi->s_mb_stream_request = MB_DEFAULT_STREAM_THRESHOLD; - sbi->s_mb_order2_reqs = MB_DEFAULT_ORDER2_REQS; -- sbi->s_mb_group_prealloc = MB_DEFAULT_GROUP_PREALLOC; -+ -+ if (sbi->s_stripe == 0) { -+ sbi->s_mb_prealloc_table_size = 10; -+ i = sbi->s_mb_prealloc_table_size * sizeof(unsigned long); -+ sbi->s_mb_prealloc_table = kmalloc(i, GFP_NOFS); -+ if (sbi->s_mb_prealloc_table == NULL) { -+ kfree(sbi->s_mb_offsets); -+ kfree(sbi->s_mb_maxs); -+ return -ENOMEM; -+ } -+ memset(sbi->s_mb_prealloc_table, 0, i); -+ -+ for (k = 0, l = 4; k <= 9; ++k, l *= 2) { -+ if (ext4_mb_prealloc_table_add(sbi, l) < 0) { -+ sbi->s_mb_prealloc_table_size = k; -+ break; -+ } -+ } -+ -+ sbi->s_mb_small_req = 256; -+ sbi->s_mb_large_req = 1024; -+ sbi->s_mb_group_prealloc = 512; -+ } else { -+ sbi->s_mb_prealloc_table_size = 3; -+ i = sbi->s_mb_prealloc_table_size * sizeof(unsigned long); -+ sbi->s_mb_prealloc_table = kmalloc(i, GFP_NOFS); -+ if (sbi->s_mb_prealloc_table == NULL) { -+ kfree(sbi->s_mb_offsets); -+ kfree(sbi->s_mb_maxs); -+ return -ENOMEM; -+ } -+ memset(sbi->s_mb_prealloc_table, 0, i); -+ -+ for (k = 0, l = sbi->s_stripe; k <= 2; ++k, l *= 2) { -+ if (ext4_mb_prealloc_table_add(sbi, l) < 0) { -+ sbi->s_mb_prealloc_table_size = k; -+ break; -+ } -+ } -+ -+ sbi->s_mb_small_req = sbi->s_stripe; -+ sbi->s_mb_large_req = sbi->s_stripe * 8; -+ sbi->s_mb_group_prealloc = sbi->s_stripe * 4; -+ } - - sbi->s_locality_groups = alloc_percpu(struct ext4_locality_group); - if (sbi->s_locality_groups == NULL) { -@@ -2494,12 +2632,22 @@ int ext4_mb_init(struct super_block *sb, - spin_lock_init(&lg->lg_prealloc_lock); - } - -- if (sbi->s_proc) -+ if (sbi->s_proc) { -+ struct proc_dir_entry *p; - proc_create_data("mb_groups", S_IRUGO, sbi->s_proc, - &ext4_mb_seq_groups_fops, sb); -+ p = create_proc_entry(EXT4_MB_PREALLOC_TABLE, S_IFREG | -+ S_IRUGO | S_IWUSR, sbi->s_proc); -+ if (p) { -+ p->data = sbi; -+ p->read_proc = ext4_mb_prealloc_table_proc_read; -+ p->write_proc = ext4_mb_prealloc_table_proc_write; -+ } -+ } - - out: - if (ret) { -+ kfree(sbi->s_mb_prealloc_table); - kfree(sbi->s_mb_offsets); - kfree(sbi->s_mb_maxs); - } -@@ -2533,8 +2681,10 @@ int ext4_mb_release(struct super_block * - struct ext4_sb_info *sbi = EXT4_SB(sb); - struct kmem_cache *cachep = get_groupinfo_cache(sb->s_blocksize_bits); - -- if (sbi->s_proc) -+ if (sbi->s_proc) { - remove_proc_entry("mb_groups", sbi->s_proc); -+ remove_proc_entry(EXT4_MB_PREALLOC_TABLE, sbi->s_proc); -+ } - - if (sbi->s_group_info) { - for (i = 0; i < ngroups; i++) { -@@ -2870,11 +3020,12 @@ static noinline_for_stack void - ext4_mb_normalize_request(struct ext4_allocation_context *ac, - struct ext4_allocation_request *ar) - { -- int bsbits, max; -+ int bsbits, i, wind; - ext4_lblk_t end; -- loff_t size, orig_size, start_off; -+ loff_t size, orig_size; - ext4_lblk_t start; - struct ext4_inode_info *ei = EXT4_I(ac->ac_inode); -+ struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb); - struct ext4_prealloc_space *pa; - - /* do normalize only data requests, metadata requests -@@ -2905,49 +3056,34 @@ ext4_mb_normalize_request(struct ext4_al - if (size < i_size_read(ac->ac_inode)) - size = i_size_read(ac->ac_inode); - orig_size = size; -+ size = (size + ac->ac_sb->s_blocksize - 1) >> bsbits; - -- /* max size of free chunks */ -- max = 2 << bsbits; -+ start = wind = 0; - --#define NRL_CHECK_SIZE(req, size, max, chunk_size) \ -- (req <= (size) || max <= (chunk_size)) -+ /* let's choose preallocation window depending on file size */ -+ for (i = 0; i < sbi->s_mb_prealloc_table_size; i++) { -+ if (size <= sbi->s_mb_prealloc_table[i]) { -+ wind = sbi->s_mb_prealloc_table[i]; -+ break; -+ } -+ } -+ size = wind; - -- /* first, try to predict filesize */ -- /* XXX: should this table be tunable? */ -- start_off = 0; -- if (size <= 16 * 1024) { -- size = 16 * 1024; -- } else if (size <= 32 * 1024) { -- size = 32 * 1024; -- } else if (size <= 64 * 1024) { -- size = 64 * 1024; -- } else if (size <= 128 * 1024) { -- size = 128 * 1024; -- } else if (size <= 256 * 1024) { -- size = 256 * 1024; -- } else if (size <= 512 * 1024) { -- size = 512 * 1024; -- } else if (size <= 1024 * 1024) { -- size = 1024 * 1024; -- } else if (NRL_CHECK_SIZE(size, 4 * 1024 * 1024, max, 2 * 1024)) { -- start_off = ((loff_t)ac->ac_o_ex.fe_logical >> -- (21 - bsbits)) << 21; -- size = 2 * 1024 * 1024; -- } else if (NRL_CHECK_SIZE(size, 8 * 1024 * 1024, max, 4 * 1024)) { -- start_off = ((loff_t)ac->ac_o_ex.fe_logical >> -- (22 - bsbits)) << 22; -- size = 4 * 1024 * 1024; -- } else if (NRL_CHECK_SIZE(ac->ac_o_ex.fe_len, -- (8<<20)>>bsbits, max, 8 * 1024)) { -- start_off = ((loff_t)ac->ac_o_ex.fe_logical >> -- (23 - bsbits)) << 23; -- size = 8 * 1024 * 1024; -- } else { -- start_off = (loff_t)ac->ac_o_ex.fe_logical << bsbits; -- size = ac->ac_o_ex.fe_len << bsbits; -+ if (wind == 0) { -+ __u64 tstart, tend; -+ /* file is quite large, we now preallocate with -+ * the biggest configured window with regart to -+ * logical offset */ -+ wind = sbi->s_mb_prealloc_table[i - 1]; -+ tstart = ac->ac_o_ex.fe_logical; -+ do_div(tstart, wind); -+ start = tstart * wind; -+ tend = ac->ac_o_ex.fe_logical + ac->ac_o_ex.fe_len - 1; -+ do_div(tend, wind); -+ tend = tend * wind + wind; -+ size = tend - start; - } -- size = size >> bsbits; -- start = start_off >> bsbits; -+ orig_size = size; - - /* don't cover already allocated blocks in selected range */ - if (ar->pleft && start <= ar->lleft) { -@@ -3020,7 +3156,6 @@ ext4_mb_normalize_request(struct ext4_al - } - BUG_ON(start + size <= ac->ac_o_ex.fe_logical && - start > ac->ac_o_ex.fe_logical); -- BUG_ON(size <= 0 || size > EXT4_BLOCKS_PER_GROUP(ac->ac_sb)); - - /* now prepare goal request */ - -@@ -3956,11 +4091,19 @@ static void ext4_mb_group_or_file(struct - - /* don't use group allocation for large files */ - size = max(size, isize); -- if (size > sbi->s_mb_stream_request) { -+ if ((ac->ac_o_ex.fe_len >= sbi->s_mb_small_req) || -+ (size >= sbi->s_mb_large_req)) { - ac->ac_flags |= EXT4_MB_STREAM_ALLOC; - return; - } - -+ /* -+ * request is so large that we don't care about -+ * streaming - it overweights any possible seek -+ */ -+ if (ac->ac_o_ex.fe_len >= sbi->s_mb_large_req) -+ return; -+ - BUG_ON(ac->ac_lg != NULL); - /* - * locality group prealloc space are per cpu. The reason for having -Index: linux-stage/fs/ext4/super.c -=================================================================== ---- linux-stage.orig/fs/ext4/super.c -+++ linux-stage/fs/ext4/super.c -@@ -2595,7 +2595,8 @@ EXT4_RW_ATTR_SBI_UI(mb_stats, s_mb_stats - EXT4_RW_ATTR_SBI_UI(mb_max_to_scan, s_mb_max_to_scan); - EXT4_RW_ATTR_SBI_UI(mb_min_to_scan, s_mb_min_to_scan); - EXT4_RW_ATTR_SBI_UI(mb_order2_req, s_mb_order2_reqs); --EXT4_RW_ATTR_SBI_UI(mb_stream_req, s_mb_stream_request); -+EXT4_RW_ATTR_SBI_UI(mb_small_req, s_mb_small_req); -+EXT4_RW_ATTR_SBI_UI(mb_large_req, s_mb_large_req); - EXT4_RW_ATTR_SBI_UI(mb_group_prealloc, s_mb_group_prealloc); - EXT4_RW_ATTR_SBI_UI(max_writeback_mb_bump, s_max_writeback_mb_bump); - -@@ -2611,7 +2612,8 @@ static struct attribute *ext4_attrs[] = - ATTR_LIST(mb_max_to_scan), - ATTR_LIST(mb_min_to_scan), - ATTR_LIST(mb_order2_req), -- ATTR_LIST(mb_stream_req), -+ ATTR_LIST(mb_small_req), -+ ATTR_LIST(mb_large_req), - ATTR_LIST(mb_group_prealloc), - ATTR_LIST(max_writeback_mb_bump), - NULL, diff --git a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-speed-up-fitrim-by-recording-flags-in-ext4_group_info.patch b/ldiskfs/kernel_patches/patches/sles11sp2/ext4-speed-up-fitrim-by-recording-flags-in-ext4_group_info.patch deleted file mode 100644 index 7e5a6b4..0000000 --- a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-speed-up-fitrim-by-recording-flags-in-ext4_group_info.patch +++ /dev/null @@ -1,159 +0,0 @@ -From 3d56b8d2c74cc3f375ce332b3ac3519e009d79ee Mon Sep 17 00:00:00 2001 -From: Tao Ma -Date: Mon, 11 Jul 2011 00:03:38 -0400 -Subject: ext4: Speed up FITRIM by recording flags in ext4_group_info -Git-commit: 3d56b8d2 -Patch-mainline: v3.1-rc1 - -In ext4, when FITRIM is called every time, we iterate all the -groups and do trim one by one. It is a bit time wasting if the -group has been trimmed and there is no change since the last -trim. - -So this patch adds a new flag in ext4_group_info->bb_state to -indicate that the group has been trimmed, and it will be cleared -if some blocks is freed(in release_blocks_on_commit). Another -trim_minlen is added in ext4_sb_info to record the last minlen -we use to trim the volume, so that if the caller provide a small -one, we will go on the trim regardless of the bb_state. - -A simple test with my intel x25m ssd: -df -h shows: -/dev/sdb1 40G 21G 17G 56% /mnt/ext4 -Block size: 4096 - -run the FITRIM with the following parameter: -range.start = 0; -range.len = UINT64_MAX; -range.minlen = 1048576; - -without the patch: -[root@boyu-tm linux-2.6]# time ./ftrim /mnt/ext4/a -real 0m5.505s -user 0m0.000s -sys 0m1.224s -[root@boyu-tm linux-2.6]# time ./ftrim /mnt/ext4/a -real 0m5.359s -user 0m0.000s -sys 0m1.178s -[root@boyu-tm linux-2.6]# time ./ftrim /mnt/ext4/a -real 0m5.228s -user 0m0.000s -sys 0m1.151s - -with the patch: -[root@boyu-tm linux-2.6]# time ./ftrim /mnt/ext4/a -real 0m5.625s -user 0m0.000s -sys 0m1.269s -[root@boyu-tm linux-2.6]# time ./ftrim /mnt/ext4/a -real 0m0.002s -user 0m0.000s -sys 0m0.001s -[root@boyu-tm linux-2.6]# time ./ftrim /mnt/ext4/a -real 0m0.002s -user 0m0.000s -sys 0m0.001s - -A big improvement for the 2nd and 3rd run. - -Even after I delete some big image files, it is still much -faster than iterating the whole disk. - -[root@boyu-tm test]# time ./ftrim /mnt/ext4/a -real 0m1.217s -user 0m0.000s -sys 0m0.196s - -Upstream-Cc: Lukas Czerner -Upstream-Reviewed-by: Andreas Dilger -Upstream-Signed-off-by: Tao Ma -Upstream-Signed-off-by: "Theodore Ts'o" -Signed-off-by: Jeff Mahoney ---- - fs/ext4/ext4.h | 13 ++++++++++++- - fs/ext4/mballoc.c | 20 ++++++++++++++++++++ - 2 files changed, 32 insertions(+), 1 deletion(-) - ---- a/fs/ext4/ext4.h -+++ b/fs/ext4/ext4.h -@@ -1215,6 +1215,9 @@ struct ext4_sb_info { - - /* Kernel thread for multiple mount protection */ - struct task_struct *s_mmp_tsk; -+ -+ /* record the last minlen when FITRIM is called. */ -+ atomic_t s_last_trim_minblks; - }; - - static inline struct ext4_sb_info *EXT4_SB(struct super_block *sb) -@@ -2071,11 +2074,19 @@ struct ext4_group_info { - * 5 free 8-block regions. */ - }; - --#define EXT4_GROUP_INFO_NEED_INIT_BIT 0 -+#define EXT4_GROUP_INFO_NEED_INIT_BIT 0 -+#define EXT4_GROUP_INFO_WAS_TRIMMED_BIT 1 - - #define EXT4_MB_GRP_NEED_INIT(grp) \ - (test_bit(EXT4_GROUP_INFO_NEED_INIT_BIT, &((grp)->bb_state))) - -+#define EXT4_MB_GRP_WAS_TRIMMED(grp) \ -+ (test_bit(EXT4_GROUP_INFO_WAS_TRIMMED_BIT, &((grp)->bb_state))) -+#define EXT4_MB_GRP_SET_TRIMMED(grp) \ -+ (set_bit(EXT4_GROUP_INFO_WAS_TRIMMED_BIT, &((grp)->bb_state))) -+#define EXT4_MB_GRP_CLEAR_TRIMMED(grp) \ -+ (clear_bit(EXT4_GROUP_INFO_WAS_TRIMMED_BIT, &((grp)->bb_state))) -+ - #define EXT4_MAX_CONTENTION 8 - #define EXT4_CONTENTION_THRESHOLD 2 - ---- a/fs/ext4/mballoc.c -+++ b/fs/ext4/mballoc.c -@@ -2629,6 +2629,15 @@ static void release_blocks_on_commit(jou - rb_erase(&entry->node, &(db->bb_free_root)); - mb_free_blocks(NULL, &e4b, entry->start_blk, entry->count); - -+ /* -+ * Clear the trimmed flag for the group so that the next -+ * ext4_trim_fs can trim it. -+ * If the volume is mounted with -o discard, online discard -+ * is supported and the free blocks will be trimmed online. -+ */ -+ if (!test_opt(sb, DISCARD)) -+ EXT4_MB_GRP_CLEAR_TRIMMED(db); -+ - if (!db->bb_free_root.rb_node) { - /* No more items in the per group rb tree - * balance refcounts from ext4_mb_free_metadata() -@@ -4838,6 +4847,10 @@ ext4_trim_all_free(struct super_block *s - bitmap = e4b.bd_bitmap; - - ext4_lock_group(sb, group); -+ if (EXT4_MB_GRP_WAS_TRIMMED(e4b.bd_info) && -+ minblocks >= atomic_read(&EXT4_SB(sb)->s_last_trim_minblks)) -+ goto out; -+ - start = (e4b.bd_info->bb_first_free > start) ? - e4b.bd_info->bb_first_free : start; - -@@ -4868,6 +4881,10 @@ ext4_trim_all_free(struct super_block *s - if ((e4b.bd_info->bb_free - count) < minblocks) - break; - } -+ -+ if (!ret) -+ EXT4_MB_GRP_SET_TRIMMED(e4b.bd_info); -+out: - ext4_unlock_group(sb, group); - ext4_mb_unload_buddy(&e4b); - -@@ -4954,5 +4971,8 @@ int ext4_trim_fs(struct super_block *sb, - } - range->len = trimmed * sb->s_blocksize; - -+ if (!ret) -+ atomic_set(&EXT4_SB(sb)->s_last_trim_minblks, minlen); -+ - return ret; - } diff --git a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-store-tree-generation-at-find.patch b/ldiskfs/kernel_patches/patches/sles11sp2/ext4-store-tree-generation-at-find.patch deleted file mode 100644 index e15fc03..0000000 --- a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-store-tree-generation-at-find.patch +++ /dev/null @@ -1,64 +0,0 @@ -diff -u -r linux-stage.orig/fs/ext4/ext4_extents.h linux-stage/fs/ext4/ext4_extents.h ---- linux-stage.orig/fs/ext4/ext4_extents.h 2013-01-02 10:14:02.000000000 -0500 -+++ linux-stage/fs/ext4/ext4_extents.h 2013-01-02 10:14:14.000000000 -0500 -@@ -113,6 +113,7 @@ - * Truncate uses it to simulate recursive walking. - */ - struct ext4_ext_path { -+ unsigned long p_generation; - ext4_fsblk_t p_block; - __u16 p_depth; - struct ext4_extent *p_ext; -diff -u -r linux-stage.orig/fs/ext4/extents.c linux-stage/fs/ext4/extents.c ---- linux-stage.orig/fs/ext4/extents.c 2013-01-02 10:14:02.000000000 -0500 -+++ linux-stage/fs/ext4/extents.c 2013-01-02 10:16:57.000000000 -0500 -@@ -1882,7 +1882,7 @@ - { - struct ext4_ext_path *path = NULL; - struct ext4_ext_cache cbex; -- struct ext4_extent *ex; -+ struct ext4_extent _ex, *ex; - ext4_lblk_t next, start = 0, end = 0; - ext4_lblk_t last = block + num; - int depth, exists, err = 0; -@@ -1895,21 +1895,29 @@ - /* find extent for this block */ - down_read(&EXT4_I(inode)->i_data_sem); - path = ext4_ext_find_extent(inode, block, path); -- up_read(&EXT4_I(inode)->i_data_sem); - if (IS_ERR(path)) { -+ up_read(&EXT4_I(inode)->i_data_sem); - err = PTR_ERR(path); - path = NULL; - break; - } - -+ path[0].p_generation = EXT4_I(inode)->i_ext_generation; -+ - depth = ext_depth(inode); - if (unlikely(path[depth].p_hdr == NULL)) { -+ up_read(&EXT4_I(inode)->i_data_sem); - EXT4_ERROR_INODE(inode, "path[%d].p_hdr == NULL", depth); - err = -EIO; - break; - } -- ex = path[depth].p_ext; -+ ex = NULL; -+ if (path[depth].p_ext) { -+ _ex = *path[depth].p_ext; -+ ex = &_ex; -+ } - next = ext4_ext_next_allocated_block(path); -+ up_read(&EXT4_I(inode)->i_data_sem); - - exists = 0; - if (!ex) { -@@ -1961,7 +1969,7 @@ - err = -EIO; - break; - } -- err = func(inode, path, &cbex, ex, cbdata); -+ err = func(inode, path, &cbex, NULL, cbdata); - ext4_ext_drop_refs(path); - - if (err < 0) diff --git a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-use-ext4_kvzalloc-ext4_kvmalloc-for-s_group_desc-and-s_group_info.patch b/ldiskfs/kernel_patches/patches/sles11sp2/ext4-use-ext4_kvzalloc-ext4_kvmalloc-for-s_group_desc-and-s_group_info.patch deleted file mode 100644 index 6c3a498..0000000 --- a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-use-ext4_kvzalloc-ext4_kvmalloc-for-s_group_desc-and-s_group_info.patch +++ /dev/null @@ -1,121 +0,0 @@ -From f18a5f21c25707b4fe64b326e2b4d150565e7300 Mon Sep 17 00:00:00 2001 -From: Theodore Ts'o -Date: Mon, 1 Aug 2011 08:45:38 -0400 -Subject: ext4: use ext4_kvzalloc()/ext4_kvmalloc() for s_group_desc and s_group_info -Git-commit: f18a5f21 -Patch-mainline: v3.1-rc1 - -Upstream-Signed-off-by: "Theodore Ts'o" -Signed-off-by: Jeff Mahoney ---- - fs/ext4/mballoc.c | 6 +++--- - fs/ext4/resize.c | 13 +++++++------ - fs/ext4/super.c | 9 +++++---- - 3 files changed, 15 insertions(+), 13 deletions(-) - -diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c -index fa716c9..d5021e8 100644 ---- a/fs/ext4/mballoc.c -+++ b/fs/ext4/mballoc.c -@@ -2331,7 +2331,7 @@ static int ext4_mb_init_backend(struct super_block *sb) - /* An 8TB filesystem with 64-bit pointers requires a 4096 byte - * kmalloc. A 128kb malloc should suffice for a 256TB filesystem. - * So a two level scheme suffices for now. */ -- sbi->s_group_info = kzalloc(array_size, GFP_KERNEL); -+ sbi->s_group_info = ext4_kvzalloc(array_size, GFP_KERNEL); - if (sbi->s_group_info == NULL) { - printk(KERN_ERR "EXT4-fs: can't allocate buddy meta group\n"); - return -ENOMEM; -@@ -2365,7 +2365,7 @@ err_freebuddy: - kfree(sbi->s_group_info[i]); - iput(sbi->s_buddy_cache); - err_freesgi: -- kfree(sbi->s_group_info); -+ ext4_kvfree(sbi->s_group_info); - return -ENOMEM; - } - -@@ -2559,7 +2559,7 @@ int ext4_mb_release(struct super_block *sb) - EXT4_DESC_PER_BLOCK_BITS(sb); - for (i = 0; i < num_meta_group_infos; i++) - kfree(sbi->s_group_info[i]); -- kfree(sbi->s_group_info); -+ ext4_kvfree(sbi->s_group_info); - } - kfree(sbi->s_mb_offsets); - kfree(sbi->s_mb_maxs); -diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c -index 71085df..707d3f1 100644 ---- a/fs/ext4/resize.c -+++ b/fs/ext4/resize.c -@@ -467,12 +467,13 @@ static int add_new_gdb(handle_t *handle, struct inode *inode, - if (unlikely(err)) - goto exit_dindj; - -- n_group_desc = kmalloc((gdb_num + 1) * sizeof(struct buffer_head *), -- GFP_NOFS); -+ n_group_desc = ext4_kvmalloc((gdb_num + 1) * -+ sizeof(struct buffer_head *), -+ GFP_NOFS); - if (!n_group_desc) { - err = -ENOMEM; -- ext4_warning(sb, -- "not enough memory for %lu groups", gdb_num + 1); -+ ext4_warning(sb, "not enough memory for %lu groups", -+ gdb_num + 1); - goto exit_inode; - } - -@@ -507,7 +508,7 @@ static int add_new_gdb(handle_t *handle, struct inode *inode, - n_group_desc[gdb_num] = *primary; - EXT4_SB(sb)->s_group_desc = n_group_desc; - EXT4_SB(sb)->s_gdb_count++; -- kfree(o_group_desc); -+ ext4_kvfree(o_group_desc); - - le16_add_cpu(&es->s_reserved_gdt_blocks, -1); - err = ext4_handle_dirty_metadata(handle, NULL, EXT4_SB(sb)->s_sbh); -@@ -517,7 +518,7 @@ static int add_new_gdb(handle_t *handle, struct inode *inode, - return err; - - exit_inode: -- kfree(n_group_desc); -+ ext4_kvfree(n_group_desc); - /* ext4_handle_release_buffer(handle, iloc.bh); */ - brelse(iloc.bh); - exit_dindj: -diff --git a/fs/ext4/super.c b/fs/ext4/super.c -index 658f586..e2d88ba 100644 ---- a/fs/ext4/super.c -+++ b/fs/ext4/super.c -@@ -819,7 +819,7 @@ static void ext4_put_super(struct super_block *sb) - - for (i = 0; i < sbi->s_gdb_count; i++) - brelse(sbi->s_group_desc[i]); -- kfree(sbi->s_group_desc); -+ ext4_kvfree(sbi->s_group_desc); - ext4_kvfree(sbi->s_flex_groups); - percpu_counter_destroy(&sbi->s_freeblocks_counter); - percpu_counter_destroy(&sbi->s_freeinodes_counter); -@@ -3439,8 +3439,9 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) - (EXT4_MAX_BLOCK_FILE_PHYS / EXT4_BLOCKS_PER_GROUP(sb))); - db_count = (sbi->s_groups_count + EXT4_DESC_PER_BLOCK(sb) - 1) / - EXT4_DESC_PER_BLOCK(sb); -- sbi->s_group_desc = kmalloc(db_count * sizeof(struct buffer_head *), -- GFP_KERNEL); -+ sbi->s_group_desc = ext4_kvmalloc(db_count * -+ sizeof(struct buffer_head *), -+ GFP_KERNEL); - if (sbi->s_group_desc == NULL) { - ext4_msg(sb, KERN_ERR, "not enough memory"); - goto failed_mount; -@@ -3783,7 +3784,7 @@ failed_mount3: - failed_mount2: - for (i = 0; i < db_count; i++) - brelse(sbi->s_group_desc[i]); -- kfree(sbi->s_group_desc); -+ ext4_kvfree(sbi->s_group_desc); - failed_mount: - if (sbi->s_proc) { - remove_proc_entry(sb->s_id, ext4_proc_root); - diff --git a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-use-ext4_msg-instead-of-printk-in-mballoc.patch b/ldiskfs/kernel_patches/patches/sles11sp2/ext4-use-ext4_msg-instead-of-printk-in-mballoc.patch deleted file mode 100644 index b19e58a..0000000 --- a/ldiskfs/kernel_patches/patches/sles11sp2/ext4-use-ext4_msg-instead-of-printk-in-mballoc.patch +++ /dev/null @@ -1,196 +0,0 @@ -From 9d8b9ec44234b2f6e0225300632d250210c04f11 Mon Sep 17 00:00:00 2001 -From: Theodore Ts'o -Date: Mon, 1 Aug 2011 17:41:35 -0400 -Subject: ext4: use ext4_msg() instead of printk in mballoc -Git-commit: 9d8b9ec4 -Patch-mainline: v3.1-rc1 - -Upstream-Signed-off-by: "Theodore Ts'o" -Signed-off-by: Jeff Mahoney ---- - fs/ext4/mballoc.c | 79 ++++++++++++++++++++++++++++------------------------- - 1 files changed, 42 insertions(+), 37 deletions(-) - -diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c -index d5021e8..70d1b3e 100644 ---- a/fs/ext4/mballoc.c -+++ b/fs/ext4/mballoc.c -@@ -493,10 +493,11 @@ static void mb_cmp_bitmaps(struct ext4_buddy *e4b, void *bitmap) - b2 = (unsigned char *) bitmap; - for (i = 0; i < e4b->bd_sb->s_blocksize; i++) { - if (b1[i] != b2[i]) { -- printk(KERN_ERR "corruption in group %u " -- "at byte %u(%u): %x in copy != %x " -- "on disk/prealloc\n", -- e4b->bd_group, i, i * 8, b1[i], b2[i]); -+ ext4_msg(e4b->bd_sb, KERN_ERR, -+ "corruption in group %u " -+ "at byte %u(%u): %x in copy != %x " -+ "on disk/prealloc", -+ e4b->bd_group, i, i * 8, b1[i], b2[i]); - BUG(); - } - } -@@ -2224,8 +2225,8 @@ int ext4_mb_add_groupinfo(struct super_block *sb, ext4_group_t group, - EXT4_DESC_PER_BLOCK_BITS(sb); - meta_group_info = kmalloc(metalen, GFP_KERNEL); - if (meta_group_info == NULL) { -- printk(KERN_ERR "EXT4-fs: can't allocate mem for a " -- "buddy group\n"); -+ ext4_msg(sb, KERN_ERR, "EXT4-fs: can't allocate mem " -+ "for a buddy group"); - goto exit_meta_group_info; - } - sbi->s_group_info[group >> EXT4_DESC_PER_BLOCK_BITS(sb)] = -@@ -2238,7 +2239,7 @@ int ext4_mb_add_groupinfo(struct super_block *sb, ext4_group_t group, - - meta_group_info[i] = kmem_cache_alloc(cachep, GFP_KERNEL); - if (meta_group_info[i] == NULL) { -- printk(KERN_ERR "EXT4-fs: can't allocate buddy mem\n"); -+ ext4_msg(sb, KERN_ERR, "EXT4-fs: can't allocate buddy mem"); - goto exit_group_info; - } - memset(meta_group_info[i], 0, kmem_cache_size(cachep)); -@@ -2333,12 +2334,12 @@ static int ext4_mb_init_backend(struct super_block *sb) - * So a two level scheme suffices for now. */ - sbi->s_group_info = ext4_kvzalloc(array_size, GFP_KERNEL); - if (sbi->s_group_info == NULL) { -- printk(KERN_ERR "EXT4-fs: can't allocate buddy meta group\n"); -+ ext4_msg(sb, KERN_ERR, "can't allocate buddy meta group"); - return -ENOMEM; - } - sbi->s_buddy_cache = new_inode(sb); - if (sbi->s_buddy_cache == NULL) { -- printk(KERN_ERR "EXT4-fs: can't get new inode\n"); -+ ext4_msg(sb, KERN_ERR, "can't get new inode"); - goto err_freesgi; - } - sbi->s_buddy_cache->i_ino = get_next_ino(); -@@ -2346,8 +2347,7 @@ static int ext4_mb_init_backend(struct super_block *sb) - for (i = 0; i < ngroups; i++) { - desc = ext4_get_group_desc(sb, i, NULL); - if (desc == NULL) { -- printk(KERN_ERR -- "EXT4-fs: can't read descriptor %u\n", i); -+ ext4_msg(sb, KERN_ERR, "can't read descriptor %u", i); - goto err_freebuddy; - } - if (ext4_mb_add_groupinfo(sb, i, desc) != 0) -@@ -2411,7 +2411,8 @@ static int ext4_groupinfo_create_slab(size_t size) - - mutex_unlock(&ext4_grpinfo_slab_create_mutex); - if (!cachep) { -- printk(KERN_EMERG "EXT4: no memory for groupinfo slab cache\n"); -+ printk(KERN_EMERG -+ "EXT4-fs: no memory for groupinfo slab cache\n"); - return -ENOMEM; - } - -@@ -2566,25 +2567,25 @@ int ext4_mb_release(struct super_block *sb) - if (sbi->s_buddy_cache) - iput(sbi->s_buddy_cache); - if (sbi->s_mb_stats) { -- printk(KERN_INFO -- "EXT4-fs: mballoc: %u blocks %u reqs (%u success)\n", -+ ext4_msg(sb, KERN_INFO, -+ "mballoc: %u blocks %u reqs (%u success)", - atomic_read(&sbi->s_bal_allocated), - atomic_read(&sbi->s_bal_reqs), - atomic_read(&sbi->s_bal_success)); -- printk(KERN_INFO -- "EXT4-fs: mballoc: %u extents scanned, %u goal hits, " -- "%u 2^N hits, %u breaks, %u lost\n", -+ ext4_msg(sb, KERN_INFO, -+ "mballoc: %u extents scanned, %u goal hits, " -+ "%u 2^N hits, %u breaks, %u lost", - atomic_read(&sbi->s_bal_ex_scanned), - atomic_read(&sbi->s_bal_goals), - atomic_read(&sbi->s_bal_2orders), - atomic_read(&sbi->s_bal_breaks), - atomic_read(&sbi->s_mb_lost_chunks)); -- printk(KERN_INFO -- "EXT4-fs: mballoc: %lu generated and it took %Lu\n", -+ ext4_msg(sb, KERN_INFO, -+ "mballoc: %lu generated and it took %Lu", - sbi->s_mb_buddies_generated++, - sbi->s_mb_generation_time); -- printk(KERN_INFO -- "EXT4-fs: mballoc: %u preallocated, %u discarded\n", -+ ext4_msg(sb, KERN_INFO, -+ "mballoc: %u preallocated, %u discarded", - atomic_read(&sbi->s_mb_preallocated), - atomic_read(&sbi->s_mb_discarded)); - } -@@ -3024,9 +3025,10 @@ ext4_mb_normalize_request(struct ext4_allocation_context *ac, - - if (start + size <= ac->ac_o_ex.fe_logical && - start > ac->ac_o_ex.fe_logical) { -- printk(KERN_ERR "start %lu, size %lu, fe_logical %lu\n", -- (unsigned long) start, (unsigned long) size, -- (unsigned long) ac->ac_o_ex.fe_logical); -+ ext4_msg(ac->ac_sb, KERN_ERR, -+ "start %lu, size %lu, fe_logical %lu", -+ (unsigned long) start, (unsigned long) size, -+ (unsigned long) ac->ac_o_ex.fe_logical); - } - BUG_ON(start + size <= ac->ac_o_ex.fe_logical && - start > ac->ac_o_ex.fe_logical); -@@ -3607,10 +3609,11 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh, - bit = next + 1; - } - if (free != pa->pa_free) { -- printk(KERN_CRIT "pa %p: logic %lu, phys. %lu, len %lu\n", -- pa, (unsigned long) pa->pa_lstart, -- (unsigned long) pa->pa_pstart, -- (unsigned long) pa->pa_len); -+ ext4_msg(e4b->bd_sb, KERN_CRIT, -+ "pa %p: logic %lu, phys. %lu, len %lu", -+ pa, (unsigned long) pa->pa_lstart, -+ (unsigned long) pa->pa_pstart, -+ (unsigned long) pa->pa_len); - ext4_grp_locked_error(sb, group, 0, 0, "free %u, pa_free %u", - free, pa->pa_free); - /* -@@ -3798,7 +3801,8 @@ repeat: - * use preallocation while we're discarding it */ - spin_unlock(&pa->pa_lock); - spin_unlock(&ei->i_prealloc_lock); -- printk(KERN_ERR "uh-oh! used pa while discarding\n"); -+ ext4_msg(sb, KERN_ERR, -+ "uh-oh! used pa while discarding"); - WARN_ON(1); - schedule_timeout_uninterruptible(HZ); - goto repeat; -@@ -3875,12 +3879,13 @@ static void ext4_mb_show_ac(struct ext4_allocation_context *ac) - (EXT4_SB(sb)->s_mount_flags & EXT4_MF_FS_ABORTED)) - return; - -- printk(KERN_ERR "EXT4-fs: Can't allocate:" -- " Allocation context details:\n"); -- printk(KERN_ERR "EXT4-fs: status %d flags %d\n", -+ ext4_msg(ac->ac_sb, KERN_ERR, "EXT4-fs: Can't allocate:" -+ " Allocation context details:"); -+ ext4_msg(ac->ac_sb, KERN_ERR, "EXT4-fs: status %d flags %d", - ac->ac_status, ac->ac_flags); -- printk(KERN_ERR "EXT4-fs: orig %lu/%lu/%lu@%lu, goal %lu/%lu/%lu@%lu, " -- "best %lu/%lu/%lu@%lu cr %d\n", -+ ext4_msg(ac->ac_sb, KERN_ERR, "EXT4-fs: orig %lu/%lu/%lu@%lu, " -+ "goal %lu/%lu/%lu@%lu, " -+ "best %lu/%lu/%lu@%lu cr %d", - (unsigned long)ac->ac_o_ex.fe_group, - (unsigned long)ac->ac_o_ex.fe_start, - (unsigned long)ac->ac_o_ex.fe_len, -@@ -3894,9 +3899,9 @@ static void ext4_mb_show_ac(struct ext4_allocation_context *ac) - (unsigned long)ac->ac_b_ex.fe_len, - (unsigned long)ac->ac_b_ex.fe_logical, - (int)ac->ac_criteria); -- printk(KERN_ERR "EXT4-fs: %lu scanned, %d found\n", ac->ac_ex_scanned, -- ac->ac_found); -- printk(KERN_ERR "EXT4-fs: groups: \n"); -+ ext4_msg(ac->ac_sb, KERN_ERR, "EXT4-fs: %lu scanned, %d found", -+ ac->ac_ex_scanned, ac->ac_found); -+ ext4_msg(ac->ac_sb, KERN_ERR, "EXT4-fs: groups: "); - ngroups = ext4_get_groups_count(sb); - for (i = 0; i < ngroups; i++) { - struct ext4_group_info *grp = ext4_get_group_info(sb, i); - diff --git a/ldiskfs/kernel_patches/patches/sles11sp2/restore-path-in-walk_extent_callback.patch b/ldiskfs/kernel_patches/patches/sles11sp2/restore-path-in-walk_extent_callback.patch deleted file mode 100644 index 3fa6dd0..0000000 --- a/ldiskfs/kernel_patches/patches/sles11sp2/restore-path-in-walk_extent_callback.patch +++ /dev/null @@ -1,58 +0,0 @@ -From: Jeff Mahoney -Subject: ext4: restore path parameter to ext_prepare_callback - -This patch partially reverts commit c03f8aa9 -(ext4: use FIEMAP_EXTENT_LAST flag for last extent in fiemap) - -The bug that commit fixed is still eliminated but we restore the -struct ext4_ext_path *path parameter to the callback for Lustre. - -next is calculated in ext4_ext_walk_space and can also be calculated in the -callback. - -Signed-off-by: Jeff Mahoney --- - - fs/ext4/ext4_extents.h | 2 +- - fs/ext4/extents.c | 5 +++-- - 2 files changed, 4 insertions(+), 3 deletions(-) - ---- a/fs/ext4/ext4_extents.h -+++ b/fs/ext4/ext4_extents.h -@@ -125,7 +125,7 @@ struct ext4_ext_path { - * positive retcode - signal for ext4_ext_walk_space(), see below - * callback must return valid extent (passed or newly created) - */ --typedef int (*ext_prepare_callback)(struct inode *, ext4_lblk_t, -+typedef int (*ext_prepare_callback)(struct inode *, struct ext4_ext_path *, - struct ext4_ext_cache *, - struct ext4_extent *, void *); - ---- a/fs/ext4/extents.c -+++ b/fs/ext4/extents.c -@@ -1964,7 +1964,7 @@ extern int ext4_ext_walk_space(struct in - err = -EIO; - break; - } -- err = func(inode, next, &cbex, ex, cbdata); -+ err = func(inode, path, &cbex, ex, cbdata); - ext4_ext_drop_refs(path); - - if (err < 0) -@@ -3954,7 +3954,7 @@ int ext4_convert_unwritten_extents(struc - /* - * Callback function called for each extent to gather FIEMAP information. - */ --static int ext4_ext_fiemap_cb(struct inode *inode, ext4_lblk_t next, -+static int ext4_ext_fiemap_cb(struct inode *inode, struct ext4_ext_path *path, - struct ext4_ext_cache *newex, struct ext4_extent *ex, - void *data) - { -@@ -3965,6 +3965,7 @@ static int ext4_ext_fiemap_cb(struct ino - int ret = 0; - struct fiemap_extent_info *fieinfo = data; - unsigned char blksize_bits; -+ ext4_lblk_t next = ext4_ext_next_allocated_block(path); - - blksize_bits = inode->i_sb->s_blocksize_bits; - logical = (__u64)newex->ec_block << blksize_bits; diff --git a/ldiskfs/kernel_patches/patches/sles11sp2/revert-ext4-avoid-uninitialized-memory-references-in-ext3_htree_next_block.patch b/ldiskfs/kernel_patches/patches/sles11sp2/revert-ext4-avoid-uninitialized-memory-references-in-ext3_htree_next_block.patch deleted file mode 100644 index ce75411..0000000 --- a/ldiskfs/kernel_patches/patches/sles11sp2/revert-ext4-avoid-uninitialized-memory-references-in-ext3_htree_next_block.patch +++ /dev/null @@ -1,107 +0,0 @@ -From: Jeff Mahoney -Subject: revert: ext4: avoid uninitialized memory references in ext3_htree_next_block() - -The data in dirent code depends on being able to store data in the -.. entry. We need to revert this commit because it will skip the dx -lookup on . and .. - - Original commit message: - ---->8---- - From: Theodore Ts'o - Date: Wed, 27 Oct 2010 21:30:08 -0400 - Subject: ext4: avoid uninitialized memory references in ext3_htree_next_block() - Git-commit: 8941ec8b - Patch-mainline: v2.6.37-rc1 - - If the first block of htree directory is missing '.' or '..' but is - otherwise a valid directory, and we do a lookup for '.' or '..', it's - possible to dereference an uninitialized memory pointer in - ext4_htree_next_block(). - - We avoid this by moving the special case from ext4_dx_find_entry() to - ext4_find_entry(); this also means we can optimize ext4_find_entry() - slightly when NFS looks up "..". - - Thanks to Brad Spengler for pointing a Clang warning that led me to - look more closely at this code. The warning was harmless, but it was - useful in pointing out code that was too ugly to live. This warning was - also reported by Roman Borisov. - - Signed-off-by: "Theodore Ts'o" - Cc: Brad Spengler - ----8<---- - -Signed-off-by: Jeff Mahoney --- - - fs/ext4/namei.c | 32 +++++++++++++++++--------------- - 1 file changed, 17 insertions(+), 15 deletions(-) - ---- a/fs/ext4/namei.c -+++ b/fs/ext4/namei.c -@@ -857,7 +857,6 @@ static struct buffer_head * ext4_find_en - struct buffer_head *bh_use[NAMEI_RA_SIZE]; - struct buffer_head *bh, *ret = NULL; - ext4_lblk_t start, block, b; -- const u8 *name = d_name->name; - int ra_max = 0; /* Number of bh's in the readahead - buffer, bh_use[] */ - int ra_ptr = 0; /* Current index into readahead -@@ -872,16 +871,6 @@ static struct buffer_head * ext4_find_en - namelen = d_name->len; - if (namelen > EXT4_NAME_LEN) - return NULL; -- if ((namelen <= 2) && (name[0] == '.') && -- (name[1] == '.' || name[1] == '\0')) { -- /* -- * "." or ".." will only be in the first block -- * NFS may look up ".."; "." should be handled by the VFS -- */ -- block = start = 0; -- nblocks = 1; -- goto restart; -- } - if (is_dx(dir)) { - bh = ext4_dx_find_entry(dir, d_name, res_dir, &err); - /* -@@ -972,15 +961,28 @@ cleanup_and_exit: - static struct buffer_head * ext4_dx_find_entry(struct inode *dir, const struct qstr *d_name, - struct ext4_dir_entry_2 **res_dir, int *err) - { -- struct super_block * sb = dir->i_sb; -+ struct super_block * sb; - struct dx_hash_info hinfo; -+ u32 hash; - struct dx_frame frames[2], *frame; - struct buffer_head *bh; - ext4_lblk_t block; - int retval; -+ int namelen = d_name->len; -+ const u8 *name = d_name->name; - -- if (!(frame = dx_probe(d_name, dir, &hinfo, frames, err))) -- return NULL; -+ sb = dir->i_sb; -+ /* NFS may look up ".." - look at dx_root directory block */ -+ if (namelen > 2 || name[0] != '.'||(name[1] != '.' && name[1] != '\0')){ -+ if (!(frame = dx_probe(d_name, dir, &hinfo, frames, err))) -+ return NULL; -+ } else { -+ frame = frames; -+ frame->bh = NULL; /* for dx_release() */ -+ frame->at = (struct dx_entry *)frames; /* hack for zero entry*/ -+ dx_set_block(frame->at, 0); /* dx_root block is 0 */ -+ } -+ hash = hinfo.hash; - do { - block = dx_get_block(frame->at); - if (!(bh = ext4_bread(NULL, dir, block, 0, err))) -@@ -1000,7 +1002,7 @@ static struct buffer_head * ext4_dx_find - } - - /* Check to see if we should continue to search */ -- retval = ext4_htree_next_block(dir, hinfo.hash, frame, -+ retval = ext4_htree_next_block(dir, hash, frame, - frames, NULL); - if (retval < 0) { - ext4_warning(sb, diff --git a/ldiskfs/kernel_patches/patches/sles11sp3/ext4-dont-check-before-replay.patch b/ldiskfs/kernel_patches/patches/sles11sp3/ext4-dont-check-before-replay.patch deleted file mode 100644 index 6357ec5..0000000 --- a/ldiskfs/kernel_patches/patches/sles11sp3/ext4-dont-check-before-replay.patch +++ /dev/null @@ -1,31 +0,0 @@ -Index: linux-stage/fs/ext4/super.c -When ldiskfs run in failover mode whith read-only disk. -Part of allocation updates are lost and ldiskfs may fail -while mounting this is due to inconsistent state of -group-descriptor. Group-descriptor check is added after -journal replay. -=================================================================== ---- linux-stage/fs/ext4/super.c 2016-11-24 20:50:46.736527130 +0530 -+++ linux-stage.orig/fs/ext4/super.c 2016-11-24 20:54:14.941779453 +0530 -@@ -3429,10 +3429,6 @@ - goto failed_mount2; - } - } -- if (!ext4_check_descriptors(sb, &first_not_zeroed)) { -- ext4_msg(sb, KERN_ERR, "group descriptors corrupted!"); -- goto failed_mount2; -- } - if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_FLEX_BG)) - if (!ext4_fill_flex_info(sb)) { - ext4_msg(sb, KERN_ERR, -@@ -3609,6 +3605,10 @@ - sbi->s_journal->j_commit_callback = ext4_journal_commit_callback; - - no_journal: -+ if (!ext4_check_descriptors(sb, &first_not_zeroed)) { -+ ext4_msg(sb, KERN_ERR, "group descriptors corrupted!"); -+ goto failed_mount_wq; -+ } - /* - * The maximum number of concurrent works can be high and - * concurrency isn't really necessary. Limit it to 1. diff --git a/ldiskfs/kernel_patches/patches/sles11sp3/ext4-mmp-brelse.patch b/ldiskfs/kernel_patches/patches/sles11sp3/ext4-mmp-brelse.patch deleted file mode 100644 index d74007e..0000000 --- a/ldiskfs/kernel_patches/patches/sles11sp3/ext4-mmp-brelse.patch +++ /dev/null @@ -1,23 +0,0 @@ ---- linux-stage.orig/fs/ext4/mmp.c 2015-11-01 15:42:38.069175571 +0530 -+++ linux-stage/fs/ext4/mmp.c 2015-11-01 15:46:53.840174791 +0530 -@@ -59,8 +59,11 @@ - } - - mmp = (struct mmp_struct *)((*bh)->b_data); -- if (le32_to_cpu(mmp->mmp_magic) != EXT4_MMP_MAGIC) -+ if (le32_to_cpu(mmp->mmp_magic) != EXT4_MMP_MAGIC) { -+ brelse(*bh); -+ *bh = NULL; - return -EINVAL; -+ } - - return 0; - } -@@ -178,6 +180,7 @@ - "The filesystem seems to have been" - " multiply mounted."); - ext4_error(sb, "abort"); -+ put_bh(bh_check); - goto failed; - } - put_bh(bh_check); diff --git a/ldiskfs/kernel_patches/patches/sles11sp3/ext4_s_max_ext_tree_depth.patch b/ldiskfs/kernel_patches/patches/sles11sp3/ext4_s_max_ext_tree_depth.patch deleted file mode 100644 index cb26db2..0000000 --- a/ldiskfs/kernel_patches/patches/sles11sp3/ext4_s_max_ext_tree_depth.patch +++ /dev/null @@ -1,158 +0,0 @@ -Fix ext4_ext_find_extent() to already pre-allocate ext4_ext_path[] -array of the max depth instead of current depth. -This will avoid racy cases of concurrent ext_depth() growth in -current and unsafe implementation with ext4_ext_path[] array -re-[sizing,allocation], even with more recent and related patches -that will be integrated in more recent Kernels. - -Index: linux-2.6.32-504.el6.x86_64/fs/ext4/ext4.h -=================================================================== ---- linux-2.6.32-504.el6.x86_64.orig/fs/ext4/ext4.h -+++ linux-2.6.32-504.el6.x86_64/fs/ext4/ext4.h -@@ -1147,6 +1147,9 @@ - unsigned long s_ext_extents; - #endif - -+ /* maximum possible extents tree depth, to be computed at mount time */ -+ unsigned int s_max_ext_tree_depth; -+ - /* for buddy allocator */ - struct ext4_group_info ***s_group_info; - struct inode *s_buddy_cache; -Index: linux-2.6.32-504.el6.x86_64/fs/ext4/super.c -=================================================================== ---- linux-2.6.32-504.el6.x86_64.orig/fs/ext4/super.c -+++ linux-2.6.32-504.el6.x86_64/fs/ext4/super.c -@@ -3529,6 +3529,8 @@ - if (ext4_multi_mount_protect(sb, le64_to_cpu(es->s_mmp_block))) - goto failed_mount3; - -+ ext4_ext_init(sb); /* needed before using extent-mapped journal */ -+ - /* - * The first inode we look at is the journal inode. Don't try - * root first: it may be modified in the journal! -@@ -3722,7 +3724,6 @@ - goto failed_mount4a; - } - -- ext4_ext_init(sb); - err = ext4_mb_init(sb, needs_recovery); - if (err) { - ext4_msg(sb, KERN_ERR, "failed to initalize mballoc (%d)", -Index: linux-2.6.32-504.el6.x86_64/fs/ext4/extents.c -=================================================================== ---- linux-2.6.32-504.el6.x86_64.orig/fs/ext4/extents.c -+++ linux-2.6.32-504.el6.x86_64/fs/ext4/extents.c -@@ -687,8 +687,9 @@ - - /* account possible depth increase */ - if (!path) { -- path = kzalloc(sizeof(struct ext4_ext_path) * (depth + 2), -- GFP_NOFS); -+ path = kzalloc(sizeof(struct ext4_ext_path) * -+ (EXT4_SB(inode->i_sb)->s_max_ext_tree_depth + 1), -+ GFP_NOFS); - if (!path) - return ERR_PTR(-ENOMEM); - alloc = 1; -@@ -1985,12 +1986,6 @@ - break; - } - -- if (ext_depth(inode) != depth) { -- /* depth was changed. we have to realloc path */ -- kfree(path); -- path = NULL; -- } -- - block = cbex.ec_block + cbex.ec_len; - } - -@@ -2636,7 +2631,8 @@ - * after i_size and walking into the tree depth-wise. - */ - depth = ext_depth(inode); -- path = kzalloc(sizeof(struct ext4_ext_path) * (depth + 1), GFP_NOFS); -+ path = kzalloc(sizeof(struct ext4_ext_path) * -+ (EXT4_SB(inode->i_sb)->s_max_ext_tree_depth + 1), -+ GFP_NOFS); - if (path == NULL) { - ext4_journal_stop(handle); - return -ENOMEM; -@@ -2755,13 +2751,15 @@ - */ - void ext4_ext_init(struct super_block *sb) - { -+ ext4_fsblk_t maxblocks; -+ - /* - * possible initialization would be here - */ - - if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS)) { --#if defined(AGGRESSIVE_TEST) || defined(CHECK_BINSEARCH) || defined(EXTENTS_STATS) -- printk(KERN_INFO "EXT4-fs: file extents enabled"); -+ printk(KERN_INFO "EXT4-fs (%s): file extents enabled", -+ sb->s_id); - #ifdef AGGRESSIVE_TEST - printk(", aggressive tests"); - #endif -@@ -2770,14 +2768,35 @@ - #endif - #ifdef EXTENTS_STATS - printk(", stats"); --#endif -- printk("\n"); --#endif --#ifdef EXTENTS_STATS - spin_lock_init(&EXT4_SB(sb)->s_ext_stats_lock); - EXT4_SB(sb)->s_ext_min = 1 << 30; - EXT4_SB(sb)->s_ext_max = 0; - #endif -+ EXT4_SB(sb)->s_max_ext_tree_depth = 1; -+ -+ maxblocks = sb->s_maxbytes / sb->s_blocksize; -+ -+ /* 1st/root level/node of extents tree stands in i_data and -+ * entries stored in tree nodes can be of type ext4_extent -+ * (leaf node) or ext4_extent_idx (internal node) */ -+ maxblocks /= (sizeof(((struct ext4_inode_info *)0x0)->i_data) - -+ sizeof(struct ext4_extent_header)) / -+ max(sizeof(struct ext4_extent), -+ sizeof(struct ext4_extent_idx)); -+ -+ /* compute maximum extents tree depth for a fully populated -+ * file of max size made of only minimal/1-block extents */ -+ while (maxblocks > 0) { -+ maxblocks /= (sb->s_blocksize - -+ sizeof(struct ext4_extent_header)) / -+ max(sizeof(struct ext4_extent), -+ sizeof(struct ext4_extent_idx)); -+ EXT4_SB(sb)->s_max_ext_tree_depth++; -+ } -+ -+ printk(", maximum tree depth=%u", -+ EXT4_SB(sb)->s_max_ext_tree_depth); -+ printk("\n"); - } - } - -@@ -3592,15 +3611,10 @@ - * the start of the hole - */ - ext4_ext_drop_refs(path); -- kfree(path); - -+ /* keep/reuse path */ - path = ext4_ext_find_extent(inode, -- map->m_lblk, NULL); -- if (IS_ERR(path)) { -- err = PTR_ERR(path); -- path = NULL; -- goto out2; -- } -+ map->m_lblk, path); - - depth = ext_depth(inode); - ex = path[depth].p_ext; diff --git a/ldiskfs/kernel_patches/patches/sles11sp4/ext4-large-dir.patch b/ldiskfs/kernel_patches/patches/sles11sp4/ext4-large-dir.patch deleted file mode 100644 index 81b8f61..0000000 --- a/ldiskfs/kernel_patches/patches/sles11sp4/ext4-large-dir.patch +++ /dev/null @@ -1,364 +0,0 @@ -This INCOMPAT_LARGEDIR feature allows larger directories -to be created in ldiskfs, both with directory sizes over -2GB and and a maximum htree depth of 3 instead of the -current limit of 2. These features are needed in order -to exceed the current limit of approximately 10M entries -in a single directory. - -Index: linux-stage/fs/ext4/ext4.h -=================================================================== ---- linux-stage.orig/fs/ext4/ext4.h -+++ linux-stage/fs/ext4/ext4.h -@@ -1391,6 +1391,7 @@ static inline void ext4_clear_state_flag - #define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200 - #define EXT4_FEATURE_INCOMPAT_EA_INODE 0x0400 /* EA in inode */ - #define EXT4_FEATURE_INCOMPAT_DIRDATA 0x1000 /* data in dirent */ -+#define EXT4_FEATURE_INCOMPAT_LARGEDIR 0x4000 - - #define EXT2_FEATURE_COMPAT_SUPP EXT4_FEATURE_COMPAT_EXT_ATTR - #define EXT2_FEATURE_INCOMPAT_SUPP (EXT4_FEATURE_INCOMPAT_FILETYPE| \ -@@ -1416,7 +1417,8 @@ static inline void ext4_clear_state_flag - EXT4_FEATURE_INCOMPAT_FLEX_BG| \ - EXT4_FEATURE_INCOMPAT_EA_INODE| \ - EXT4_FEATURE_INCOMPAT_MMP| \ -- EXT4_FEATURE_INCOMPAT_DIRDATA) -+ EXT4_FEATURE_INCOMPAT_DIRDATA| \ -+ EXT4_FEATURE_INCOMPAT_LARGEDIR) - - #define EXT4_FEATURE_RO_COMPAT_SUPP (EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER| \ - EXT4_FEATURE_RO_COMPAT_LARGE_FILE| \ -@@ -1679,6 +1681,17 @@ ext4_group_first_block_no(struct super_b - */ - #define ERR_BAD_DX_DIR -75000 - -+/* htree levels for ext4 */ -+#define EXT4_HTREE_LEVEL_COMPAT 2 -+#define EXT4_HTREE_LEVEL 3 -+ -+static inline int -+ext4_dir_htree_level(struct super_block *sb) -+{ -+ return EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_LARGEDIR) ? -+ EXT4_HTREE_LEVEL : EXT4_HTREE_LEVEL_COMPAT; -+} -+ - void ext4_get_group_no_and_offset(struct super_block *sb, ext4_fsblk_t blocknr, - ext4_group_t *blockgrpp, ext4_grpblk_t *offsetp); - -@@ -2077,13 +2090,15 @@ static inline void ext4_r_blocks_count_s - es->s_r_blocks_count_hi = cpu_to_le32(blk >> 32); - } - --static inline loff_t ext4_isize(struct ext4_inode *raw_inode) -+static inline loff_t ext4_isize(struct super_block *sb, -+ struct ext4_inode *raw_inode) - { -- if (S_ISREG(le16_to_cpu(raw_inode->i_mode))) -+ if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_LARGEDIR) || -+ S_ISREG(le16_to_cpu(raw_inode->i_mode))) - return ((loff_t)le32_to_cpu(raw_inode->i_size_high) << 32) | - le32_to_cpu(raw_inode->i_size_lo); -- else -- return (loff_t) le32_to_cpu(raw_inode->i_size_lo); -+ -+ return (loff_t) le32_to_cpu(raw_inode->i_size_lo); - } - - static inline void ext4_isize_set(struct ext4_inode *raw_inode, loff_t i_size) -Index: linux-stage/fs/ext4/inode.c -=================================================================== ---- linux-stage.orig/fs/ext4/inode.c -+++ linux-stage/fs/ext4/inode.c -@@ -5007,7 +5007,7 @@ struct inode *ext4_iget(struct super_blo - if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_64BIT)) - ei->i_file_acl |= - ((__u64)le16_to_cpu(raw_inode->i_file_acl_high)) << 32; -- inode->i_size = ext4_isize(raw_inode); -+ inode->i_size = ext4_isize(sb, raw_inode); - if ((size = i_size_read(inode)) < 0) { - EXT4_ERROR_INODE(inode, "bad i_size value: %lld", size); - ret = -EIO; -@@ -5253,7 +5253,7 @@ static int ext4_do_update_inode(handle_t - raw_inode->i_file_acl_high = - cpu_to_le16(ei->i_file_acl >> 32); - raw_inode->i_file_acl_lo = cpu_to_le32(ei->i_file_acl); -- if (ei->i_disksize != ext4_isize(raw_inode)) { -+ if (ei->i_disksize != ext4_isize(inode->i_sb, raw_inode)) { - ext4_isize_set(raw_inode, ei->i_disksize); - need_datasync = 1; - } -Index: linux-stage/fs/ext4/namei.c -=================================================================== ---- linux-stage.orig/fs/ext4/namei.c -+++ linux-stage/fs/ext4/namei.c -@@ -209,7 +209,7 @@ struct dx_root_info * dx_get_dx_info(str - - static inline ext4_lblk_t dx_get_block(struct dx_entry *entry) - { -- return le32_to_cpu(entry->block) & 0x00ffffff; -+ return le32_to_cpu(entry->block) & 0x0fffffff; - } - - static inline void dx_set_block(struct dx_entry *entry, ext4_lblk_t value) -@@ -372,7 +372,7 @@ dx_probe(const struct qstr *d_name, stru - struct dx_frame *frame = frame_in; - u32 hash; - -- frame->bh = NULL; -+ memset(frame_in, 0, EXT4_HTREE_LEVEL * sizeof(frame_in[0])); - if (!(bh = ext4_bread (NULL,dir, 0, 0, err))) - goto fail; - -@@ -402,9 +402,16 @@ dx_probe(const struct qstr *d_name, stru - goto fail; - } - -- if ((indirect = info->indirect_levels) > 1) { -- ext4_warning(dir->i_sb, "Unimplemented inode hash depth: %#06x", -- info->indirect_levels); -+ indirect = info->indirect_levels; -+ if (indirect >= ext4_dir_htree_level(dir->i_sb)) { -+ ext4_warning(dir->i_sb, -+ "Directory (ino: %lu) htree depth %#06x exceed " -+ "supported value", dir->i_ino, -+ ext4_dir_htree_level(dir->i_sb)); -+ if (ext4_dir_htree_level(dir->i_sb) < EXT4_HTREE_LEVEL) { -+ ext4_warning(dir->i_sb, "Enable large directory " -+ "feature to access it"); -+ } - brelse(bh); - *err = ERR_BAD_DX_DIR; - goto fail; -@@ -496,13 +503,18 @@ fail: - static void dx_release (struct dx_frame *frames) - { - struct dx_root_info *info; -+ int i; -+ - if (frames[0].bh == NULL) - return; - - info = dx_get_dx_info((struct ext4_dir_entry_2*)frames[0].bh->b_data); -- if (info->indirect_levels) -- brelse(frames[1].bh); -- brelse(frames[0].bh); -+ for (i = 0; i <= info->indirect_levels; i++) { -+ if (frames[i].bh == NULL) -+ break; -+ brelse(frames[i].bh); -+ frames[i].bh = NULL; -+ } - } - - /* -@@ -642,7 +654,7 @@ int ext4_htree_fill_tree(struct file *di - { - struct dx_hash_info hinfo; - struct ext4_dir_entry_2 *de; -- struct dx_frame frames[2], *frame; -+ struct dx_frame frames[EXT4_HTREE_LEVEL], *frame; - struct inode *dir; - ext4_lblk_t block; - int count = 0; -@@ -983,7 +995,7 @@ static struct buffer_head * ext4_dx_find - struct super_block * sb; - struct dx_hash_info hinfo; - u32 hash; -- struct dx_frame frames[2], *frame; -+ struct dx_frame frames[EXT4_HTREE_LEVEL], *frame; - struct buffer_head *bh; - ext4_lblk_t block; - int retval; -@@ -1423,7 +1435,7 @@ static int add_dirent_to_buf(handle_t *h - */ - dir->i_mtime = dir->i_ctime = ext4_current_time(dir); - ext4_update_dx_flag(dir); -- dir->i_version++; -+ inode_inc_iversion(dir); - ext4_mark_inode_dirty(handle, dir); - BUFFER_TRACE(bh, "call ext4_handle_dirty_metadata"); - err = ext4_handle_dirty_metadata(handle, dir, bh); -@@ -1443,7 +1455,7 @@ static int make_indexed_dir(handle_t *ha - const char *name = dentry->d_name.name; - int namelen = dentry->d_name.len; - struct buffer_head *bh2; -- struct dx_frame frames[2], *frame; -+ struct dx_frame frames[EXT4_HTREE_LEVEL], *frame; - struct dx_entry *entries; - struct ext4_dir_entry_2 *de, *de2, *dot_de, *dotdot_de; - char *data1, *top; -@@ -1692,15 +1704,18 @@ static int ext4_add_entry(handle_t *hand - static int ext4_dx_add_entry(handle_t *handle, struct dentry *dentry, - struct inode *inode) - { -- struct dx_frame frames[2], *frame; -+ struct dx_frame frames[EXT4_HTREE_LEVEL], *frame; - struct dx_entry *entries, *at; - struct dx_hash_info hinfo; - struct buffer_head *bh; - struct inode *dir = dentry->d_parent->d_inode; - struct super_block *sb = dir->i_sb; - struct ext4_dir_entry_2 *de; -+ int restart; - int err; - -+again: -+ restart = 0; - frame = dx_probe(&dentry->d_name, dir, &hinfo, frames, &err); - if (!frame) - return err; -@@ -1710,33 +1725,48 @@ static int ext4_dx_add_entry(handle_t *h - if (!(bh = ext4_bread(handle,dir, dx_get_block(frame->at), 0, &err))) - goto cleanup; - -- BUFFER_TRACE(bh, "get_write_access"); -- err = ext4_journal_get_write_access(handle, bh); -- if (err) -- goto journal_error; -- - err = add_dirent_to_buf(handle, dentry, inode, NULL, bh); - if (err != -ENOSPC) - goto cleanup; - -+ err = 0; - /* Block full, should compress but for now just split */ - dxtrace(printk(KERN_DEBUG "using %u of %u node entries\n", - dx_get_count(entries), dx_get_limit(entries))); - /* Need to split index? */ - if (dx_get_count(entries) == dx_get_limit(entries)) { - ext4_lblk_t newblock; -- unsigned icount = dx_get_count(entries); -- int levels = frame - frames; -+ int levels = frame - frames + 1; -+ unsigned icount; -+ int add_level = 1; - struct dx_entry *entries2; - struct dx_node *node2; - struct buffer_head *bh2; - -- if (levels && (dx_get_count(frames->entries) == -- dx_get_limit(frames->entries))) { -- ext4_warning(sb, "Directory index full!"); -+ while (frame > frames) { -+ if (dx_get_count((frame - 1)->entries) < -+ dx_get_limit((frame - 1)->entries)) { -+ add_level = 0; -+ break; -+ } -+ frame--; /* split higher index block */ -+ at = frame->at; -+ entries = frame->entries; -+ restart = 1; -+ } -+ if (add_level && levels == ext4_dir_htree_level(sb)) { -+ ext4_warning(sb, "Directory (ino: %lu) index full, " -+ "reach max htree level :%d", -+ dir->i_ino, levels); -+ if (ext4_dir_htree_level(sb) < EXT4_HTREE_LEVEL) { -+ ext4_warning(sb, "Large directory feature is" -+ "not enabled on this " -+ "filesystem"); -+ } - err = -ENOSPC; - goto cleanup; - } -+ icount = dx_get_count(entries); - bh2 = ext4_append (handle, dir, &newblock, &err); - if (!(bh2)) - goto cleanup; -@@ -1749,7 +1779,7 @@ static int ext4_dx_add_entry(handle_t *h - err = ext4_journal_get_write_access(handle, frame->bh); - if (err) - goto journal_error; -- if (levels) { -+ if (!add_level) { - unsigned icount1 = icount/2, icount2 = icount - icount1; - unsigned hash2 = dx_get_hash(entries + icount1); - dxtrace(printk(KERN_DEBUG "Split index %i/%i\n", -@@ -1757,7 +1787,7 @@ static int ext4_dx_add_entry(handle_t *h - - BUFFER_TRACE(frame->bh, "get_write_access"); /* index root */ - err = ext4_journal_get_write_access(handle, -- frames[0].bh); -+ (frame - 1)->bh); - if (err) - goto journal_error; - -@@ -1773,18 +1803,24 @@ static int ext4_dx_add_entry(handle_t *h - frame->entries = entries = entries2; - swap(frame->bh, bh2); - } -- dx_insert_block(frames + 0, hash2, newblock); -- dxtrace(dx_show_index("node", frames[1].entries)); -+ dx_insert_block((frame - 1), hash2, newblock); -+ dxtrace(dx_show_index("node", frame->entries)); - dxtrace(dx_show_index("node", - ((struct dx_node *) bh2->b_data)->entries)); - err = ext4_handle_dirty_metadata(handle, dir, bh2); - if (err) - goto journal_error; - brelse (bh2); -+ ext4_handle_dirty_metadata(handle, dir, -+ (frame - 1)->bh); -+ if (restart) { -+ ext4_handle_dirty_metadata(handle, dir, -+ frame->bh); -+ goto cleanup; -+ } - } else { - struct dx_root_info * info; -- dxtrace(printk(KERN_DEBUG -- "Creating second level index...\n")); -+ - memcpy((char *) entries2, (char *) entries, - icount * sizeof(struct dx_entry)); - dx_set_limit(entries2, dx_node_limit(dir)); -@@ -1794,19 +1830,16 @@ static int ext4_dx_add_entry(handle_t *h - dx_set_block(entries + 0, newblock); - info = dx_get_dx_info((struct ext4_dir_entry_2*) - frames[0].bh->b_data); -- info->indirect_levels = 1; -- -- /* Add new access path frame */ -- frame = frames + 1; -- frame->at = at = at - entries + entries2; -- frame->entries = entries = entries2; -- frame->bh = bh2; -- err = ext4_journal_get_write_access(handle, -- frame->bh); -- if (err) -- goto journal_error; -+ info->indirect_levels += 1; -+ dxtrace(printk(KERN_DEBUG -+ "Creating %d level index...\n", -+ info->indirect_levels)); -+ ext4_handle_dirty_metadata(handle, dir, frame->bh); -+ ext4_handle_dirty_metadata(handle, dir, bh2); -+ brelse(bh2); -+ restart = 1; -+ goto cleanup; - } -- err = ext4_handle_dirty_metadata(handle, dir, frames[0].bh); - if (err) { - ext4_std_error(inode->i_sb, err); - goto cleanup; -@@ -1824,6 +1857,10 @@ cleanup: - if (bh) - brelse(bh); - dx_release(frames); -+ /* @restart is true means htree-path has been changed, we need to -+ * repeat dx_probe() to find out valid htree-path */ -+ if (restart && err == 0) -+ goto again; - return err; - } - -@@ -1862,7 +1899,7 @@ int ext4_delete_entry(handle_t *handle, - blocksize); - else - de->inode = 0; -- dir->i_version++; -+ inode_inc_iversion(dir); - BUFFER_TRACE(bh, "call ext4_handle_dirty_metadata"); - err = ext4_handle_dirty_metadata(handle, dir, bh); - if (unlikely(err)) { diff --git a/ldiskfs/kernel_patches/patches/rhel7/ext4-osd-iop-common.patch b/ldiskfs/kernel_patches/patches/sles12/ext4-osd-iop-common.patch similarity index 100% rename from ldiskfs/kernel_patches/patches/rhel7/ext4-osd-iop-common.patch rename to ldiskfs/kernel_patches/patches/sles12/ext4-osd-iop-common.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-3.0-sles11.series b/ldiskfs/kernel_patches/series/ldiskfs-3.0-sles11.series deleted file mode 100644 index a6187d2..0000000 --- a/ldiskfs/kernel_patches/series/ldiskfs-3.0-sles11.series +++ /dev/null @@ -1,44 +0,0 @@ -sles11sp2/ext4-introduce-ext4_kvmalloc-ext4_kzalloc-and-ext4_kvfree.patch -sles11sp2/ext4-speed-up-fitrim-by-recording-flags-in-ext4_group_info.patch -sles11sp2/ext4-use-ext4_kvzalloc-ext4_kvmalloc-for-s_group_desc-and-s_group_info.patch -sles11sp2/ext4-use-ext4_msg-instead-of-printk-in-mballoc.patch -sles11sp2/revert-ext4-avoid-uninitialized-memory-references-in-ext3_htree_next_block.patch -sles11sp2/ext4-journal-callback.patch -sles11sp2/ext4-make-quota-as-first-class-supported-feature.patch -sles11sp2/ext4-handle-cleanup-after-quota-failure.patch -sles11sp2/ext4-map_inode_page-3.0.patch -sles11sp2/export-ext4-3.0.patch -rhel6.3/ext4-remove-cond_resched-calls.patch -rhel6.3/ext4-nlink-2.6.patch -sles11sp2/ext4-ext_generation.patch -rhel6.3/ext4-inode-version.patch -sles11sp2/ext4-lookup-dotdot.patch -rhel6.3/ext4-print-inum-in-htree-warning.patch -sles11sp2/ext4-prealloc.patch -sles11sp2/ext4-mballoc-extra-checks.patch -sles11sp2/restore-path-in-walk_extent_callback.patch -sles11sp2/ext4-misc.patch -rhel6.3/ext4-pdir-fix.patch -sles11sp2/ext4-osd-iop-common.patch -rhel6.3/ext4-osd-iam-exports.patch -rhel6.3/ext4-hash-indexed-dir-dotdot-update.patch -sles11sp2/ext4-kill-dx_root.patch -sles11sp2/ext4-mballoc-pa_free-mismatch.patch -sles11sp2/ext4-data-in-dirent.patch -sles11sp2/ext4-large-eas.patch -sles11sp2/ext4-disable-mb-cache.patch -rhel6.3/ext4-nocmtime-2.6.patch -rhel6.3/ext4-export-64bit-name-hash.patch -sles11sp2/ext4-store-tree-generation-at-find.patch -sles11sp2/ext4-large-dir.patch -rhel6.3/ext4-pdirop.patch -rhel6.3/ext4-max-dir-size.patch -sles11sp2/ext4-max-dir-size-options.patch -rhel6.3/ext4-not-discard-preallocation-umount.patch -rhel6.3/ext4-journal-path-opt.patch -sles11sp3/ext4_s_max_ext_tree_depth.patch -sles11sp1/ext4-notalloc_under_idatasem.patch -rhel6.5/ext4-fix-journal-quota.patch -rhel7/ext4-export-orphan-add.patch -sles11sp2/ext4-mmp-dont-mark-bh-dirty.patch -rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-3.0-sles11sp3.series b/ldiskfs/kernel_patches/series/ldiskfs-3.0-sles11sp3.series deleted file mode 100644 index 7558269..0000000 --- a/ldiskfs/kernel_patches/series/ldiskfs-3.0-sles11sp3.series +++ /dev/null @@ -1,48 +0,0 @@ -sles11sp2/ext4-introduce-ext4_kvmalloc-ext4_kzalloc-and-ext4_kvfree.patch -sles11sp2/ext4-speed-up-fitrim-by-recording-flags-in-ext4_group_info.patch -sles11sp2/ext4-use-ext4_kvzalloc-ext4_kvmalloc-for-s_group_desc-and-s_group_info.patch -sles11sp2/ext4-use-ext4_msg-instead-of-printk-in-mballoc.patch -sles11sp2/revert-ext4-avoid-uninitialized-memory-references-in-ext3_htree_next_block.patch -sles11sp2/ext4-journal-callback.patch -sles11sp2/ext4-make-quota-as-first-class-supported-feature.patch -sles11sp2/ext4-handle-cleanup-after-quota-failure.patch -sles11sp2/ext4-map_inode_page-3.0.patch -sles11sp2/export-ext4-3.0.patch -rhel6.3/ext4-remove-cond_resched-calls.patch -rhel6.3/ext4-nlink-2.6.patch -sles11sp2/ext4-ext_generation.patch -rhel6.3/ext4-inode-version.patch -sles11sp2/ext4-lookup-dotdot.patch -rhel6.3/ext4-print-inum-in-htree-warning.patch -sles11sp2/ext4-prealloc.patch -sles11sp2/ext4-mballoc-extra-checks.patch -sles11sp2/restore-path-in-walk_extent_callback.patch -sles11sp2/ext4-misc.patch -rhel6.3/ext4-pdir-fix.patch -sles11sp2/ext4-osd-iop-common.patch -rhel6.3/ext4-osd-iam-exports.patch -rhel6.3/ext4-hash-indexed-dir-dotdot-update.patch -sles11sp2/ext4-kill-dx_root.patch -sles11sp2/ext4-mballoc-pa_free-mismatch.patch -sles11sp2/ext4-data-in-dirent.patch -sles11sp2/ext4-large-eas.patch -sles11sp2/ext4-disable-mb-cache.patch -rhel6.3/ext4-nocmtime-2.6.patch -sles11sp2/ext4-store-tree-generation-at-find.patch -sles11sp2/ext4-large-dir.patch -rhel6.3/ext4-pdirop.patch -rhel6.3/ext4-max-dir-size.patch -sles11sp2/ext4-max-dir-size-options.patch -rhel6.3/ext4-not-discard-preallocation-umount.patch -rhel6.3/ext4-journal-path-opt.patch -sles11sp2/ext4-corrupted-inode-block-bitmaps-handling-patches.patch -rhel6.5/ext4-give-warning-with-dir-htree-growing.patch -sles11sp3/ext4-mmp-brelse.patch -sles11sp3/ext4_s_max_ext_tree_depth.patch -sles11sp1/ext4-notalloc_under_idatasem.patch -rhel6.5/ext4-fix-journal-quota.patch -sles11sp3/ext4-dont-check-before-replay.patch -rhel6.3/ext4-dont-check-in-ro.patch -rhel7/ext4-export-orphan-add.patch -sles11sp2/ext4-mmp-dont-mark-bh-dirty.patch -rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-3.0-sles11sp4.series b/ldiskfs/kernel_patches/series/ldiskfs-3.0-sles11sp4.series deleted file mode 100644 index 799e625..0000000 --- a/ldiskfs/kernel_patches/series/ldiskfs-3.0-sles11sp4.series +++ /dev/null @@ -1,48 +0,0 @@ -sles11sp2/ext4-introduce-ext4_kvmalloc-ext4_kzalloc-and-ext4_kvfree.patch -sles11sp2/ext4-speed-up-fitrim-by-recording-flags-in-ext4_group_info.patch -sles11sp2/ext4-use-ext4_kvzalloc-ext4_kvmalloc-for-s_group_desc-and-s_group_info.patch -sles11sp2/ext4-use-ext4_msg-instead-of-printk-in-mballoc.patch -sles11sp2/revert-ext4-avoid-uninitialized-memory-references-in-ext3_htree_next_block.patch -sles11sp2/ext4-journal-callback.patch -sles11sp2/ext4-make-quota-as-first-class-supported-feature.patch -sles11sp2/ext4-handle-cleanup-after-quota-failure.patch -sles11sp2/ext4-map_inode_page-3.0.patch -sles11sp2/export-ext4-3.0.patch -rhel6.3/ext4-remove-cond_resched-calls.patch -rhel6.3/ext4-nlink-2.6.patch -sles11sp2/ext4-ext_generation.patch -rhel6.3/ext4-inode-version.patch -sles11sp2/ext4-lookup-dotdot.patch -rhel6.3/ext4-print-inum-in-htree-warning.patch -sles11sp2/ext4-prealloc.patch -sles11sp2/ext4-mballoc-extra-checks.patch -sles11sp2/restore-path-in-walk_extent_callback.patch -sles11sp2/ext4-misc.patch -rhel6.3/ext4-pdir-fix.patch -sles11sp2/ext4-osd-iop-common.patch -rhel6.3/ext4-osd-iam-exports.patch -rhel6.3/ext4-hash-indexed-dir-dotdot-update.patch -sles11sp2/ext4-kill-dx_root.patch -sles11sp2/ext4-mballoc-pa_free-mismatch.patch -sles11sp2/ext4-data-in-dirent.patch -sles11sp2/ext4-large-eas.patch -sles11sp2/ext4-disable-mb-cache.patch -rhel6.3/ext4-nocmtime-2.6.patch -sles11sp2/ext4-store-tree-generation-at-find.patch -sles11sp4/ext4-large-dir.patch -rhel6.3/ext4-pdirop.patch -rhel6.3/ext4-max-dir-size.patch -sles11sp2/ext4-max-dir-size-options.patch -rhel6.3/ext4-not-discard-preallocation-umount.patch -rhel6.3/ext4-journal-path-opt.patch -sles11sp2/ext4-corrupted-inode-block-bitmaps-handling-patches.patch -rhel6.5/ext4-give-warning-with-dir-htree-growing.patch -sles11sp3/ext4-mmp-brelse.patch -sles11sp3/ext4_s_max_ext_tree_depth.patch -sles11sp1/ext4-notalloc_under_idatasem.patch -rhel6.5/ext4-fix-journal-quota.patch -sles11sp3/ext4-dont-check-before-replay.patch -rhel6.3/ext4-dont-check-in-ro.patch -rhel7/ext4-export-orphan-add.patch -sles11sp2/ext4-mmp-dont-mark-bh-dirty.patch -rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.2.series b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.2.series index 9019133..b9813c7 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.2.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.2.series @@ -1,41 +1 @@ -rhel7/ext4-inode-version.patch -rhel7/ext4-lookup-dotdot.patch -rhel6.3/ext4-print-inum-in-htree-warning.patch -rhel7/ext4-prealloc.patch -rhel7/ext4-mballoc-extra-checks.patch -rhel7/ext4-misc.patch -rhel7/ext4-osd-iop-common.patch -rhel7/ext4-hash-indexed-dir-dotdot-update.patch -rhel7/ext4-kill-dx-root.patch -rhel7/ext4-mballoc-pa-free-mismatch.patch -rhel7/ext4-data-in-dirent.patch -rhel7.2/ext4-large-eas.patch -rhel7/ext4-disable-mb-cache.patch -rhel7/ext4-nocmtime.patch -rhel7/ext4-large-dir.patch -rhel7.2/ext4-pdirop.patch -rhel7/ext4-max-dir-size.patch -rhel7/ext4-corrupted-inode-block-bitmaps-handling-patches.patch -rhel7/ext4-give-warning-with-dir-htree-growing.patch -rhel7/ext4-mmp-brelse.patch -rhel7/ext4-jcb-optimization.patch -rhel7/ext4_s_max_ext_tree_depth.patch -rhel7.2/ext4-release-bh-in-makeinxdir.patch -rhel7.2/ext4-dont-check-in-ro.patch -rhel7.2/ext4-dont-check-before-replay.patch -rhel7.2/ext4-remove-i_data_sem-from-xattr.patch -rhel7/ext4-projid-ignore-maxquotas.patch -rhel7/ext4-projid-feature-support.patch -rhel7/ext4-projid-quotas.patch -rhel7/ext4-projid-xfs-ioctls.patch -rhel7/ext4-fix-xattr-shifting-when-expanding-inodes.patch -rhel7/ext4-cleanup-goto-next-group.patch -rhel7/ext4-reduce-lock-contention-in-__ext4_new_inode.patch -rhel7.2/ext4-preread-gd.patch -rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch -rhel7/ext4-export-orphan-add.patch -rhel7/ext4-mmp-dont-mark-bh-dirty.patch -rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch -rhel7/ext4-optimize-ext4_find_delalloc_range-in-nodelalloc.patch -rhel7/ext4-mballoc-skip-uninit-groups-cr0.patch rhel7/ext4-mballoc-prefetch.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.3.series b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.3.series index 0322656..b9813c7 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.3.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.3.series @@ -1,41 +1 @@ -rhel7/ext4-inode-version.patch -rhel7/ext4-lookup-dotdot.patch -rhel6.3/ext4-print-inum-in-htree-warning.patch -rhel7/ext4-prealloc.patch -rhel7/ext4-mballoc-extra-checks.patch -rhel7/ext4-misc.patch -rhel7/ext4-osd-iop-common.patch -rhel7/ext4-hash-indexed-dir-dotdot-update.patch -rhel7/ext4-kill-dx-root.patch -rhel7/ext4-mballoc-pa-free-mismatch.patch -rhel7.3/ext4-data-in-dirent.patch -rhel7.2/ext4-large-eas.patch -rhel7.3/ext4-disable-mb-cache.patch -rhel7/ext4-nocmtime.patch -rhel7/ext4-large-dir.patch -rhel7.2/ext4-pdirop.patch -rhel7/ext4-max-dir-size.patch -rhel7.3/ext4-corrupted-inode-block-bitmaps-handling-patches.patch -rhel7/ext4-give-warning-with-dir-htree-growing.patch -rhel7/ext4-mmp-brelse.patch -rhel7/ext4-jcb-optimization.patch -rhel7/ext4_s_max_ext_tree_depth.patch -rhel7.2/ext4-release-bh-in-makeinxdir.patch -rhel7.2/ext4-remove-i_data_sem-from-xattr.patch -rhel7/ext4-projid-ignore-maxquotas.patch -rhel7/ext4-projid-feature-support.patch -rhel7/ext4-projid-quotas.patch -rhel7/ext4-projid-xfs-ioctls.patch -rhel7/ext4-fix-xattr-shifting-when-expanding-inodes.patch -rhel6.3/ext4-dont-check-in-ro.patch -rhel7.2/ext4-dont-check-before-replay.patch -rhel7/ext4-cleanup-goto-next-group.patch -rhel7/ext4-reduce-lock-contention-in-__ext4_new_inode.patch -rhel7.2/ext4-preread-gd.patch -rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch -rhel7/ext4-export-orphan-add.patch -rhel7/ext4-mmp-dont-mark-bh-dirty.patch -rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch -rhel7/ext4-optimize-ext4_find_delalloc_range-in-nodelalloc.patch -rhel7/ext4-mballoc-skip-uninit-groups-cr0.patch rhel7/ext4-mballoc-prefetch.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.4.series b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.4.series index adf98a8..b9813c7 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.4.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.4.series @@ -1,41 +1 @@ -rhel7/ext4-inode-version.patch -rhel7/ext4-lookup-dotdot.patch -rhel6.3/ext4-print-inum-in-htree-warning.patch -rhel7.4/ext4-prealloc.patch -rhel7/ext4-mballoc-extra-checks.patch -rhel7/ext4-misc.patch -rhel7/ext4-osd-iop-common.patch -rhel7/ext4-hash-indexed-dir-dotdot-update.patch -rhel7/ext4-kill-dx-root.patch -rhel7/ext4-mballoc-pa-free-mismatch.patch -rhel7.3/ext4-data-in-dirent.patch -rhel7.2/ext4-large-eas.patch -rhel7.3/ext4-disable-mb-cache.patch -rhel7/ext4-nocmtime.patch -rhel7.4/ext4-large-dir.patch -rhel7.4/ext4-pdirop.patch -rhel7/ext4-max-dir-size.patch -rhel7.3/ext4-corrupted-inode-block-bitmaps-handling-patches.patch -rhel7/ext4-give-warning-with-dir-htree-growing.patch -rhel7/ext4-mmp-brelse.patch -rhel7/ext4-jcb-optimization.patch -rhel7/ext4_s_max_ext_tree_depth.patch -rhel7.4/ext4-remove-i_data_sem-from-xattr.patch -rhel7/ext4-projid-ignore-maxquotas.patch -rhel7/ext4-projid-feature-support.patch -rhel7/ext4-projid-quotas.patch -rhel7/ext4-projid-xfs-ioctls.patch -rhel7.4/ext4-fix-xattr-shifting-when-expanding-inodes.patch -rhel7.4/ext4-attach-jinode-in-writepages.patch -rhel6.3/ext4-dont-check-in-ro.patch -rhel7.4/ext4-dont-check-before-replay.patch -rhel7/ext4-cleanup-goto-next-group.patch -rhel7/ext4-reduce-lock-contention-in-__ext4_new_inode.patch -rhel7.2/ext4-preread-gd.patch -rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch -rhel7/ext4-export-orphan-add.patch -rhel7/ext4-mmp-dont-mark-bh-dirty.patch -rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch -rhel7/ext4-optimize-ext4_find_delalloc_range-in-nodelalloc.patch -rhel7/ext4-mballoc-skip-uninit-groups-cr0.patch rhel7/ext4-mballoc-prefetch.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.5.series b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.5.series index 1615249..b9813c7 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.5.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.5.series @@ -1,41 +1 @@ -rhel7/ext4-inode-version.patch -rhel7/ext4-lookup-dotdot.patch -rhel6.3/ext4-print-inum-in-htree-warning.patch -rhel7.4/ext4-prealloc.patch -rhel7/ext4-mballoc-extra-checks.patch -rhel7/ext4-misc.patch -rhel7/ext4-osd-iop-common.patch -rhel7/ext4-hash-indexed-dir-dotdot-update.patch -rhel7/ext4-kill-dx-root.patch -rhel7/ext4-mballoc-pa-free-mismatch.patch -rhel7.3/ext4-data-in-dirent.patch -rhel7.2/ext4-large-eas.patch -rhel7.3/ext4-disable-mb-cache.patch -rhel7/ext4-nocmtime.patch -rhel7.4/ext4-large-dir.patch -rhel7.4/ext4-pdirop.patch -rhel7/ext4-max-dir-size.patch -rhel7.3/ext4-corrupted-inode-block-bitmaps-handling-patches.patch -rhel7/ext4-give-warning-with-dir-htree-growing.patch -rhel7/ext4-mmp-brelse.patch -rhel7/ext4-jcb-optimization.patch -rhel7/ext4_s_max_ext_tree_depth.patch -rhel7/ext4-projid-ignore-maxquotas.patch -rhel7/ext4-projid-feature-support.patch -rhel7/ext4-projid-quotas.patch -rhel7.5/ext4-projid-xfs-ioctls.patch -rhel7.4/ext4-fix-xattr-shifting-when-expanding-inodes.patch -rhel7.4/ext4-attach-jinode-in-writepages.patch -rhel6.3/ext4-dont-check-in-ro.patch -rhel7.4/ext4-dont-check-before-replay.patch -rhel7/ext4-cleanup-goto-next-group.patch -rhel7/ext4-reduce-lock-contention-in-__ext4_new_inode.patch -rhel7.2/ext4-preread-gd.patch -rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch -rhel7/ext4-export-orphan-add.patch -rhel7/ext4-mmp-dont-mark-bh-dirty.patch -rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch -rhel7.2/ext4-export-mb-stream-allocator-variables.patch -rhel7/ext4-optimize-ext4_find_delalloc_range-in-nodelalloc.patch -rhel7/ext4-mballoc-skip-uninit-groups-cr0.patch rhel7/ext4-mballoc-prefetch.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.6.series b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.6.series index 97651e9..fcb7484 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.6.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.6.series @@ -1,44 +1,44 @@ -rhel7/ext4-inode-version.patch -rhel7/ext4-lookup-dotdot.patch -rhel6.3/ext4-print-inum-in-htree-warning.patch -rhel7.4/ext4-prealloc.patch -rhel7/ext4-mballoc-extra-checks.patch -rhel7/ext4-misc.patch +rhel7.6/ext4-inode-version.patch +rhel7.6/ext4-lookup-dotdot.patch +rhel7.6/ext4-print-inum-in-htree-warning.patch +rhel7.6/ext4-prealloc.patch +rhel7.6/ext4-mballoc-extra-checks.patch +rhel7.6/ext4-misc.patch rhel7.6/ext4-osd-iop-common.patch -rhel7/ext4-hash-indexed-dir-dotdot-update.patch -rhel7/ext4-kill-dx-root.patch -rhel7/ext4-mballoc-pa-free-mismatch.patch -rhel7.3/ext4-data-in-dirent.patch +rhel7.6/ext4-hash-indexed-dir-dotdot-update.patch +rhel7.6/ext4-kill-dx-root.patch +rhel7.6/ext4-mballoc-pa-free-mismatch.patch +rhel7.6/ext4-data-in-dirent.patch rhel7.6/ext4-large-eas.patch -rhel7.3/ext4-disable-mb-cache.patch -rhel7/ext4-nocmtime.patch -rhel7.4/ext4-large-dir.patch -rhel7.4/ext4-pdirop.patch -rhel7/ext4-max-dir-size.patch +rhel7.6/ext4-disable-mb-cache.patch +rhel7.6/ext4-nocmtime.patch +rhel7.6/ext4-large-dir.patch +rhel7.6/ext4-pdirop.patch +rhel7.6/ext4-max-dir-size.patch rhel7.6/ext4-corrupted-inode-block-bitmaps-handling-patches.patch -rhel7/ext4-give-warning-with-dir-htree-growing.patch -rhel7/ext4-mmp-brelse.patch -rhel7/ext4-jcb-optimization.patch -rhel7/ext4_s_max_ext_tree_depth.patch -rhel7/ext4-projid-ignore-maxquotas.patch -rhel7/ext4-projid-feature-support.patch -rhel7/ext4-projid-quotas.patch -rhel7.5/ext4-projid-xfs-ioctls.patch -rhel7.4/ext4-fix-xattr-shifting-when-expanding-inodes.patch -rhel7.4/ext4-attach-jinode-in-writepages.patch -rhel6.3/ext4-dont-check-in-ro.patch +rhel7.6/ext4-give-warning-with-dir-htree-growing.patch +rhel7.6/ext4-mmp-brelse.patch +rhel7.6/ext4-jcb-optimization.patch +rhel7.6/ext4_s_max_ext_tree_depth.patch +rhel7.6/ext4-projid-ignore-maxquotas.patch +rhel7.6/ext4-projid-feature-support.patch +rhel7.6/ext4-projid-quotas.patch +rhel7.6/ext4-projid-xfs-ioctls.patch +rhel7.6/ext4-fix-xattr-shifting-when-expanding-inodes.patch +rhel7.6/ext4-attach-jinode-in-writepages.patch +rhel7.6/ext4-dont-check-in-ro.patch rhel7.6/ext4-dont-check-before-replay.patch -rhel7/ext4-cleanup-goto-next-group.patch -rhel7/ext4-reduce-lock-contention-in-__ext4_new_inode.patch -rhel7.2/ext4-preread-gd.patch -rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch -rhel7/ext4-export-orphan-add.patch -rhel7/ext4-mmp-dont-mark-bh-dirty.patch -rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch -rhel7.2/ext4-export-mb-stream-allocator-variables.patch -rhel7/ext4-optimize-ext4_find_delalloc_range-in-nodelalloc.patch -rhel7.2/ext4-simple-blockalloc.patch -rhel7/ext4-mballoc-skip-uninit-groups-cr0.patch +rhel7.6/ext4-cleanup-goto-next-group.patch +rhel7.6/ext4-reduce-lock-contention-in-__ext4_new_inode.patch +rhel7.6/ext4-preread-gd.patch +rhel7.6/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch +rhel7.6/ext4-export-orphan-add.patch +rhel7.6/ext4-mmp-dont-mark-bh-dirty.patch +rhel7.6/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch +rhel7.6/ext4-export-mb-stream-allocator-variables.patch +rhel7.6/ext4-optimize-ext4_find_delalloc_range-in-nodelalloc.patch +rhel7.6/ext4-simple-blockalloc.patch +rhel7.6/ext4-mballoc-skip-uninit-groups-cr0.patch rhel7/ext4-mballoc-prefetch.patch rhel7.6/ext4-track-extent-status-tree-shrinker-delay-statict.patch rhel7.6/ext4-remove-extent-status-procfs-files-if-journal-lo.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.7.series b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.7.series index 70220a2..2851ec9 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.7.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.7.series @@ -1,44 +1,44 @@ -rhel7/ext4-inode-version.patch -rhel7/ext4-lookup-dotdot.patch -rhel6.3/ext4-print-inum-in-htree-warning.patch -rhel7.4/ext4-prealloc.patch -rhel7/ext4-mballoc-extra-checks.patch +rhel7.6/ext4-inode-version.patch +rhel7.6/ext4-lookup-dotdot.patch +rhel7.6/ext4-print-inum-in-htree-warning.patch +rhel7.6/ext4-prealloc.patch +rhel7.6/ext4-mballoc-extra-checks.patch rhel7.7/ext4-misc.patch rhel7.6/ext4-osd-iop-common.patch -rhel7/ext4-hash-indexed-dir-dotdot-update.patch -rhel7/ext4-kill-dx-root.patch -rhel7/ext4-mballoc-pa-free-mismatch.patch -rhel7.3/ext4-data-in-dirent.patch +rhel7.6/ext4-hash-indexed-dir-dotdot-update.patch +rhel7.6/ext4-kill-dx-root.patch +rhel7.6/ext4-mballoc-pa-free-mismatch.patch +rhel7.6/ext4-data-in-dirent.patch rhel7.7/ext4-large-eas.patch -rhel7.3/ext4-disable-mb-cache.patch -rhel7/ext4-nocmtime.patch +rhel7.6/ext4-disable-mb-cache.patch +rhel7.6/ext4-nocmtime.patch rhel7.7/ext4-large-dir.patch rhel7.7/ext4-pdirop.patch -rhel7/ext4-max-dir-size.patch +rhel7.6/ext4-max-dir-size.patch rhel7.6/ext4-corrupted-inode-block-bitmaps-handling-patches.patch -rhel7/ext4-give-warning-with-dir-htree-growing.patch -rhel7/ext4-mmp-brelse.patch -rhel7/ext4-jcb-optimization.patch -rhel7/ext4_s_max_ext_tree_depth.patch +rhel7.6/ext4-give-warning-with-dir-htree-growing.patch +rhel7.6/ext4-mmp-brelse.patch +rhel7.6/ext4-jcb-optimization.patch +rhel7.6/ext4_s_max_ext_tree_depth.patch rhel7.7/ext4-projid-ignore-maxquotas.patch -rhel7/ext4-projid-feature-support.patch -rhel7/ext4-projid-quotas.patch -rhel7.5/ext4-projid-xfs-ioctls.patch +rhel7.6/ext4-projid-feature-support.patch +rhel7.6/ext4-projid-quotas.patch +rhel7.6/ext4-projid-xfs-ioctls.patch rhel7.7/ext4-fix-xattr-shifting-when-expanding-inodes.patch -rhel7.4/ext4-attach-jinode-in-writepages.patch -rhel6.3/ext4-dont-check-in-ro.patch +rhel7.6/ext4-attach-jinode-in-writepages.patch +rhel7.6/ext4-dont-check-in-ro.patch rhel7.6/ext4-dont-check-before-replay.patch -rhel7/ext4-cleanup-goto-next-group.patch -rhel7/ext4-reduce-lock-contention-in-__ext4_new_inode.patch -rhel7.2/ext4-preread-gd.patch -rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch -rhel7/ext4-export-orphan-add.patch -rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch -rhel7.2/ext4-export-mb-stream-allocator-variables.patch -rhel7/ext4-optimize-ext4_find_delalloc_range-in-nodelalloc.patch +rhel7.6/ext4-cleanup-goto-next-group.patch +rhel7.6/ext4-reduce-lock-contention-in-__ext4_new_inode.patch +rhel7.6/ext4-preread-gd.patch +rhel7.6/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch +rhel7.6/ext4-export-orphan-add.patch +rhel7.6/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch +rhel7.6/ext4-export-mb-stream-allocator-variables.patch +rhel7.6/ext4-optimize-ext4_find_delalloc_range-in-nodelalloc.patch rhel7.7/ext4-fix-project-with-unpatched-kernel.patch -rhel7.2/ext4-simple-blockalloc.patch -rhel7/ext4-mballoc-skip-uninit-groups-cr0.patch +rhel7.6/ext4-simple-blockalloc.patch +rhel7.6/ext4-mballoc-skip-uninit-groups-cr0.patch rhel7.7/ext4-mballoc-prefetch.patch rhel7.6/ext4-track-extent-status-tree-shrinker-delay-statict.patch rhel7.6/ext4-remove-extent-status-procfs-files-if-journal-lo.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.series b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.series index 5912b55..b9813c7 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.series @@ -1,36 +1 @@ -rhel7/ext4-inode-version.patch -rhel7/ext4-lookup-dotdot.patch -rhel6.3/ext4-print-inum-in-htree-warning.patch -rhel7/ext4-prealloc.patch -rhel7/ext4-mballoc-extra-checks.patch -rhel7/ext4-misc.patch -rhel7/ext4-osd-iop-common.patch -rhel7/ext4-hash-indexed-dir-dotdot-update.patch -rhel7/ext4-kill-dx-root.patch -rhel7/ext4-mballoc-pa-free-mismatch.patch -rhel7/ext4-data-in-dirent.patch -rhel7/ext4-large-eas.patch -rhel7/ext4-disable-mb-cache.patch -rhel7/ext4-nocmtime.patch -rhel7/ext4-large-dir.patch -rhel7/ext4-pdirop.patch -rhel7/ext4-max-dir-size.patch -rhel7/ext4-corrupted-inode-block-bitmaps-handling-patches.patch -rhel7/ext4-give-warning-with-dir-htree-growing.patch -rhel7/ext4-mmp-brelse.patch -rhel7/ext4-jcb-optimization.patch -rhel7/ext4_s_max_ext_tree_depth.patch -rhel7/ext4-remove-i_data_sem-from-xattr.patch -rhel7/ext4-projid-ignore-maxquotas.patch -rhel7/ext4-projid-feature-support.patch -rhel7/ext4-projid-quotas.patch -rhel7/ext4-projid-xfs-ioctls.patch -rhel7/ext4-fix-xattr-shifting-when-expanding-inodes.patch -rhel7/ext4-cleanup-goto-next-group.patch -rhel7/ext4-reduce-lock-contention-in-__ext4_new_inode.patch -rhel7/ext4-export-orphan-add.patch -rhel7/ext4-mmp-dont-mark-bh-dirty.patch -rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch -rhel7/ext4-optimize-ext4_find_delalloc_range-in-nodelalloc.patch -rhel7/ext4-mballoc-skip-uninit-groups-cr0.patch rhel7/ext4-mballoc-prefetch.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-3.12-sles12.series b/ldiskfs/kernel_patches/series/ldiskfs-3.12-sles12.series index b8f25a7..671a918 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-3.12-sles12.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-3.12-sles12.series @@ -1,25 +1,25 @@ sles12/ext4-inode-version.patch -rhel7/ext4-lookup-dotdot.patch -rhel6.3/ext4-print-inum-in-htree-warning.patch +rhel7.6/ext4-lookup-dotdot.patch +rhel7.6/ext4-print-inum-in-htree-warning.patch sles12/ext4-prealloc.patch -rhel7/ext4-osd-iop-common.patch +sles12/ext4-osd-iop-common.patch sles12/ext4-misc.patch -rhel7/ext4-mballoc-extra-checks.patch -rhel7/ext4-hash-indexed-dir-dotdot-update.patch -rhel7/ext4-kill-dx-root.patch -rhel7/ext4-mballoc-pa-free-mismatch.patch +rhel7.6/ext4-mballoc-extra-checks.patch +rhel7.6/ext4-hash-indexed-dir-dotdot-update.patch +rhel7.6/ext4-kill-dx-root.patch +rhel7.6/ext4-mballoc-pa-free-mismatch.patch sles12/ext4-data-in-dirent.patch sles12/ext4-large-eas.patch -rhel7/ext4-disable-mb-cache.patch -rhel7/ext4-nocmtime.patch -rhel7/ext4-large-dir.patch +sles12/ext4-disable-mb-cache.patch +rhel7.6/ext4-nocmtime.patch +sles12/ext4-large-dir.patch sles12/ext4-pdirop.patch -rhel7/ext4-max-dir-size.patch +rhel7.6/ext4-max-dir-size.patch sles12/ext4-corrupted-inode-block-bitmaps-handling-patches.patch -rhel7/ext4-give-warning-with-dir-htree-growing.patch -rhel7/ext4-mmp-brelse.patch -rhel7/ext4-jcb-optimization.patch -rhel7/ext4-export-orphan-add.patch -rhel7/ext4-mmp-dont-mark-bh-dirty.patch -rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch -rhel7/ext4-optimize-ext4_find_delalloc_range-in-nodelalloc.patch +rhel7.6/ext4-give-warning-with-dir-htree-growing.patch +rhel7.6/ext4-mmp-brelse.patch +rhel7.6/ext4-jcb-optimization.patch +rhel7.6/ext4-export-orphan-add.patch +rhel7.6/ext4-mmp-dont-mark-bh-dirty.patch +rhel7.6/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch +rhel7.6/ext4-optimize-ext4_find_delalloc_range-in-nodelalloc.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-3.12-sles12sp1.series b/ldiskfs/kernel_patches/series/ldiskfs-3.12-sles12sp1.series index da684d6..1b95066 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-3.12-sles12sp1.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-3.12-sles12sp1.series @@ -1,26 +1,26 @@ sles12/ext4-inode-version.patch sles12sp1/ext4-lookup-dotdot.patch -rhel6.3/ext4-print-inum-in-htree-warning.patch +rhel7.6/ext4-print-inum-in-htree-warning.patch sles12/ext4-prealloc.patch -rhel7/ext4-osd-iop-common.patch +sles12/ext4-osd-iop-common.patch sles12/ext4-misc.patch -rhel7/ext4-mballoc-extra-checks.patch -rhel7/ext4-hash-indexed-dir-dotdot-update.patch -rhel7/ext4-kill-dx-root.patch -rhel7/ext4-mballoc-pa-free-mismatch.patch +rhel7.6/ext4-mballoc-extra-checks.patch +rhel7.6/ext4-hash-indexed-dir-dotdot-update.patch +rhel7.6/ext4-kill-dx-root.patch +rhel7.6/ext4-mballoc-pa-free-mismatch.patch sles12/ext4-data-in-dirent.patch sles12/ext4-large-eas.patch -rhel7/ext4-disable-mb-cache.patch -rhel7/ext4-nocmtime.patch +sles12/ext4-disable-mb-cache.patch +rhel7.6/ext4-nocmtime.patch sles12sp1/ext4-large-dir.patch sles12/ext4-pdirop.patch -rhel7/ext4-max-dir-size.patch +rhel7.6/ext4-max-dir-size.patch sles12/ext4-corrupted-inode-block-bitmaps-handling-patches.patch -rhel7/ext4-give-warning-with-dir-htree-growing.patch -rhel7/ext4-mmp-brelse.patch -rhel7/ext4-jcb-optimization.patch +rhel7.6/ext4-give-warning-with-dir-htree-growing.patch +rhel7.6/ext4-mmp-brelse.patch +rhel7.6/ext4-jcb-optimization.patch sles12sp1/ext4-attach-jinode-in-writepages.patch -rhel7/ext4-export-orphan-add.patch -rhel7/ext4-mmp-dont-mark-bh-dirty.patch -rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch -rhel7/ext4-optimize-ext4_find_delalloc_range-in-nodelalloc.patch +rhel7.6/ext4-export-orphan-add.patch +rhel7.6/ext4-mmp-dont-mark-bh-dirty.patch +rhel7.6/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch +rhel7.6/ext4-optimize-ext4_find_delalloc_range-in-nodelalloc.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-4.15.0-20-ubuntu18.series b/ldiskfs/kernel_patches/series/ldiskfs-4.15.0-20-ubuntu18.series index ca4e47d..e3e11225 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-4.15.0-20-ubuntu18.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-4.15.0-20-ubuntu18.series @@ -7,7 +7,7 @@ ubuntu18/ext4-misc.patch ubuntu18/ext4-mballoc-extra-checks.patch ubuntu18/ext4-hash-indexed-dir-dotdot-update.patch ubuntu18/ext4-kill-dx-root.patch -rhel7/ext4-mballoc-pa-free-mismatch.patch +rhel7.6/ext4-mballoc-pa-free-mismatch.patch ubuntu18/ext4-data-in-dirent.patch ubuntu18/ext4-nocmtime.patch ubuntu18/ext4-pdirop.patch @@ -17,7 +17,7 @@ ubuntu18/ext4-give-warning-with-dir-htree-growing.patch ubuntu18/ext4-jcb-optimization.patch ubuntu18/ext4-attach-jinode-in-writepages.patch ubuntu18/ext4-dont-check-before-replay.patch -rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch -rhel7/ext4-export-orphan-add.patch -rhel7/ext4-mmp-dont-mark-bh-dirty.patch +rhel7.6/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch +rhel7.6/ext4-export-orphan-add.patch +rhel7.6/ext4-mmp-dont-mark-bh-dirty.patch ubuntu18/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-4.15.0-24-ubuntu18.series b/ldiskfs/kernel_patches/series/ldiskfs-4.15.0-24-ubuntu18.series index 21edbd5..c9b4ff7 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-4.15.0-24-ubuntu18.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-4.15.0-24-ubuntu18.series @@ -7,7 +7,7 @@ ubuntu18/ext4-misc.patch ubuntu18/ext4-mballoc-extra-checks.patch ubuntu18/ext4-hash-indexed-dir-dotdot-update.patch ubuntu18/ext4-kill-dx-root.patch -rhel7/ext4-mballoc-pa-free-mismatch.patch +rhel7.6/ext4-mballoc-pa-free-mismatch.patch ubuntu18/ext4-data-in-dirent.patch ubuntu18/ext4-nocmtime.patch ubuntu18/ext4-pdirop.patch @@ -17,8 +17,8 @@ ubuntu18/ext4-give-warning-with-dir-htree-growing.patch ubuntu18/ext4-jcb-optimization.patch ubuntu18/ext4-attach-jinode-in-writepages.patch ubuntu18/ext4-dont-check-before-replay.patch -rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch -rhel7/ext4-export-orphan-add.patch -rhel7/ext4-mmp-dont-mark-bh-dirty.patch +rhel7.6/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch +rhel7.6/ext4-export-orphan-add.patch +rhel7.6/ext4-mmp-dont-mark-bh-dirty.patch ubuntu18/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch sles12sp2/ext4-export-mb-stream-allocator-variables.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-4.18-rhel8.1.series b/ldiskfs/kernel_patches/series/ldiskfs-4.18-rhel8.1.series index 539f849..92a8f9b 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-4.18-rhel8.1.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-4.18-rhel8.1.series @@ -7,7 +7,7 @@ rhel8.1/ext4-misc.patch rhel8/ext4-mballoc-extra-checks.patch ubuntu18/ext4-hash-indexed-dir-dotdot-update.patch rhel8.1/ext4-kill-dx-root.patch -rhel7/ext4-mballoc-pa-free-mismatch.patch +rhel7.6/ext4-mballoc-pa-free-mismatch.patch ubuntu18/ext4-data-in-dirent.patch rhel8/ext4-nocmtime.patch rhel8/ext4-pdirop.patch @@ -17,8 +17,8 @@ ubuntu18/ext4-give-warning-with-dir-htree-growing.patch ubuntu18/ext4-jcb-optimization.patch ubuntu18/ext4-attach-jinode-in-writepages.patch rhel8/ext4-dont-check-before-replay.patch -rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch -rhel7/ext4-export-orphan-add.patch +rhel7.6/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch +rhel7.6/ext4-export-orphan-add.patch rhel8/ext4-export-mb-stream-allocator-variables.patch rhel8/ext4-simple-blockalloc.patch rhel8/ext4-mballoc-skip-uninit-groups-cr0.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-4.18-rhel8.series b/ldiskfs/kernel_patches/series/ldiskfs-4.18-rhel8.series index 8cb32e7..94078d6 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-4.18-rhel8.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-4.18-rhel8.series @@ -7,7 +7,7 @@ rhel8/ext4-misc.patch rhel8/ext4-mballoc-extra-checks.patch ubuntu18/ext4-hash-indexed-dir-dotdot-update.patch ubuntu18/ext4-kill-dx-root.patch -rhel7/ext4-mballoc-pa-free-mismatch.patch +rhel7.6/ext4-mballoc-pa-free-mismatch.patch ubuntu18/ext4-data-in-dirent.patch rhel8/ext4-nocmtime.patch rhel8/ext4-pdirop.patch @@ -17,8 +17,8 @@ ubuntu18/ext4-give-warning-with-dir-htree-growing.patch ubuntu18/ext4-jcb-optimization.patch ubuntu18/ext4-attach-jinode-in-writepages.patch rhel8/ext4-dont-check-before-replay.patch -rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch -rhel7/ext4-export-orphan-add.patch +rhel7.6/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch +rhel7.6/ext4-export-orphan-add.patch ubuntu18/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch rhel8/ext4-export-mb-stream-allocator-variables.patch rhel8/ext4-simple-blockalloc.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-4.4-sles12sp2.series b/ldiskfs/kernel_patches/series/ldiskfs-4.4-sles12sp2.series index 45b3845..27e9b0f 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-4.4-sles12sp2.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-4.4-sles12sp2.series @@ -7,25 +7,25 @@ sles12sp2/ext4-misc.patch sles12sp3/ext4-mballoc-extra-checks.patch sles12sp2/ext4-hash-indexed-dir-dotdot-update.patch sles12sp2/ext4-kill-dx-root.patch -rhel7/ext4-mballoc-pa-free-mismatch.patch +rhel7.6/ext4-mballoc-pa-free-mismatch.patch sles12sp2/ext4-data-in-dirent.patch sles12sp2/ext4-large-eas.patch sles12sp2/ext4-disable-mb-cache.patch -rhel7/ext4-nocmtime.patch +rhel7.6/ext4-nocmtime.patch sles12sp2/ext4-large-dir.patch sles12sp2/ext4-pdirop.patch sles12sp2/ext4-max-dir-size.patch sles12sp2/ext4-corrupted-inode-block-bitmaps-handling-patches.patch sles12sp2/ext4-give-warning-with-dir-htree-growing.patch sles12sp2/ext4-mmp-brelse.patch -rhel7/ext4-jcb-optimization.patch +rhel7.6/ext4-jcb-optimization.patch sles12sp2/ext4-attach-jinode-in-writepages.patch sles12sp2/ext4-dont-check-before-replay.patch -rhel7.2/ext4-dont-check-in-ro.patch +sles12sp2/ext4-dont-check-in-ro.patch sles12sp2/ext4-fix-xattr-shifting-when-expanding-inodes.patch -rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch -rhel7/ext4-export-orphan-add.patch -rhel7/ext4-mmp-dont-mark-bh-dirty.patch -rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch +rhel7.6/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch +rhel7.6/ext4-export-orphan-add.patch +rhel7.6/ext4-mmp-dont-mark-bh-dirty.patch +rhel7.6/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch sles12sp2/ext4-export-mb-stream-allocator-variables.patch -rhel7/ext4-optimize-ext4_find_delalloc_range-in-nodelalloc.patch +rhel7.6/ext4-optimize-ext4_find_delalloc_range-in-nodelalloc.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-4.4-sles12sp3.series b/ldiskfs/kernel_patches/series/ldiskfs-4.4-sles12sp3.series index de29b53..455ec18 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-4.4-sles12sp3.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-4.4-sles12sp3.series @@ -7,24 +7,24 @@ sles12sp2/ext4-misc.patch sles12sp3/ext4-mballoc-extra-checks.patch sles12sp2/ext4-hash-indexed-dir-dotdot-update.patch sles12sp2/ext4-kill-dx-root.patch -rhel7/ext4-mballoc-pa-free-mismatch.patch +rhel7.6/ext4-mballoc-pa-free-mismatch.patch sles12sp3/ext4-data-in-dirent.patch sles12sp3/ext4-large-eas.patch sles12sp3/ext4-disable-mb-cache.patch -rhel7/ext4-nocmtime.patch +rhel7.6/ext4-nocmtime.patch sles12sp3/ext4-large-dir.patch sles12sp3/ext4-pdirop.patch sles12sp3/ext4-max-dir-size.patch sles12sp3/ext4-corrupted-inode-block-bitmaps-handling-patches.patch sles12sp2/ext4-give-warning-with-dir-htree-growing.patch sles12sp2/ext4-mmp-brelse.patch -rhel7/ext4-jcb-optimization.patch +rhel7.6/ext4-jcb-optimization.patch sles12sp2/ext4-attach-jinode-in-writepages.patch sles12sp3/ext4-dont-check-before-replay.patch -rhel7.2/ext4-dont-check-in-ro.patch +sles12sp2/ext4-dont-check-in-ro.patch sles12sp2/ext4-fix-xattr-shifting-when-expanding-inodes.patch -rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch -rhel7/ext4-export-orphan-add.patch -rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch +rhel7.6/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch +rhel7.6/ext4-export-orphan-add.patch +rhel7.6/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch sles12sp2/ext4-export-mb-stream-allocator-variables.patch -rhel7/ext4-optimize-ext4_find_delalloc_range-in-nodelalloc.patch +rhel7.6/ext4-optimize-ext4_find_delalloc_range-in-nodelalloc.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-4.4.0-45-ubuntu14+16.series b/ldiskfs/kernel_patches/series/ldiskfs-4.4.0-45-ubuntu14+16.series index 0318650..a3e91ea 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-4.4.0-45-ubuntu14+16.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-4.4.0-45-ubuntu14+16.series @@ -7,21 +7,21 @@ ubuntu14+16/ext4-misc.patch sles12sp2/ext4-mballoc-extra-checks.patch sles12sp2/ext4-hash-indexed-dir-dotdot-update.patch sles12sp2/ext4-kill-dx-root.patch -rhel7/ext4-mballoc-pa-free-mismatch.patch +rhel7.6/ext4-mballoc-pa-free-mismatch.patch ubuntu14+16/ext4-data-in-dirent.patch ubuntu14+16/ext4-large-eas.patch ubuntu14+16/ext4-disable-mb-cache.patch -rhel7/ext4-nocmtime.patch +rhel7.6/ext4-nocmtime.patch ubuntu14+16/ext4-large-dir.patch ubuntu14+16/ext4-pdirop.patch sles12sp2/ext4-max-dir-size.patch sles12sp2/ext4-corrupted-inode-block-bitmaps-handling-patches.patch sles12sp2/ext4-give-warning-with-dir-htree-growing.patch sles12sp2/ext4-mmp-brelse.patch -rhel7/ext4-jcb-optimization.patch +rhel7.6/ext4-jcb-optimization.patch sles12sp2/ext4-attach-jinode-in-writepages.patch -rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch -rhel7/ext4-export-orphan-add.patch -rhel7/ext4-mmp-dont-mark-bh-dirty.patch -rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch -rhel7/ext4-optimize-ext4_find_delalloc_range-in-nodelalloc.patch +rhel7.6/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch +rhel7.6/ext4-export-orphan-add.patch +rhel7.6/ext4-mmp-dont-mark-bh-dirty.patch +rhel7.6/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch +rhel7.6/ext4-optimize-ext4_find_delalloc_range-in-nodelalloc.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-4.4.0-49-ubuntu14+16.series b/ldiskfs/kernel_patches/series/ldiskfs-4.4.0-49-ubuntu14+16.series index 65fff0b..1245873 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-4.4.0-49-ubuntu14+16.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-4.4.0-49-ubuntu14+16.series @@ -7,21 +7,21 @@ ubuntu14+16/ext4-misc.patch sles12sp2/ext4-mballoc-extra-checks.patch sles12sp2/ext4-hash-indexed-dir-dotdot-update.patch sles12sp2/ext4-kill-dx-root.patch -rhel7/ext4-mballoc-pa-free-mismatch.patch +rhel7.6/ext4-mballoc-pa-free-mismatch.patch ubuntu14+16/ext4-data-in-dirent-001.patch ubuntu14+16/ext4-large-eas.patch ubuntu14+16/ext4-disable-mb-cache.patch -rhel7/ext4-nocmtime.patch +rhel7.6/ext4-nocmtime.patch ubuntu14+16/ext4-large-dir.patch ubuntu14+16/ext4-pdirop-001.patch sles12sp2/ext4-max-dir-size.patch sles12sp2/ext4-corrupted-inode-block-bitmaps-handling-patches.patch sles12sp2/ext4-give-warning-with-dir-htree-growing.patch sles12sp2/ext4-mmp-brelse.patch -rhel7/ext4-jcb-optimization.patch +rhel7.6/ext4-jcb-optimization.patch sles12sp2/ext4-attach-jinode-in-writepages.patch -rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch -rhel7/ext4-export-orphan-add.patch -rhel7/ext4-mmp-dont-mark-bh-dirty.patch -rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch -rhel7/ext4-optimize-ext4_find_delalloc_range-in-nodelalloc.patch +rhel7.6/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch +rhel7.6/ext4-export-orphan-add.patch +rhel7.6/ext4-mmp-dont-mark-bh-dirty.patch +rhel7.6/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch +rhel7.6/ext4-optimize-ext4_find_delalloc_range-in-nodelalloc.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-4.4.0-62-ubuntu14+16.series b/ldiskfs/kernel_patches/series/ldiskfs-4.4.0-62-ubuntu14+16.series index 2542292..c76c5a1 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-4.4.0-62-ubuntu14+16.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-4.4.0-62-ubuntu14+16.series @@ -7,21 +7,21 @@ ubuntu14+16/ext4-misc.patch sles12sp2/ext4-mballoc-extra-checks.patch sles12sp2/ext4-hash-indexed-dir-dotdot-update.patch sles12sp2/ext4-kill-dx-root.patch -rhel7/ext4-mballoc-pa-free-mismatch.patch +rhel7.6/ext4-mballoc-pa-free-mismatch.patch ubuntu14+16/ext4-data-in-dirent-001.patch ubuntu14+16/ext4-large-eas.patch ubuntu14+16/ext4-disable-mb-cache.patch -rhel7/ext4-nocmtime.patch +rhel7.6/ext4-nocmtime.patch ubuntu14+16/ext4-large-dir-001.patch ubuntu14+16/ext4-pdirop-001.patch sles12sp2/ext4-max-dir-size.patch sles12sp2/ext4-corrupted-inode-block-bitmaps-handling-patches.patch sles12sp2/ext4-give-warning-with-dir-htree-growing.patch sles12sp2/ext4-mmp-brelse.patch -rhel7/ext4-jcb-optimization.patch +rhel7.6/ext4-jcb-optimization.patch sles12sp2/ext4-attach-jinode-in-writepages.patch -rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch -rhel7/ext4-export-orphan-add.patch -rhel7/ext4-mmp-dont-mark-bh-dirty.patch -rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch -rhel7/ext4-optimize-ext4_find_delalloc_range-in-nodelalloc.patch +rhel7.6/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch +rhel7.6/ext4-export-orphan-add.patch +rhel7.6/ext4-mmp-dont-mark-bh-dirty.patch +rhel7.6/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch +rhel7.6/ext4-optimize-ext4_find_delalloc_range-in-nodelalloc.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-4.4.0-73-ubuntu14+16.series b/ldiskfs/kernel_patches/series/ldiskfs-4.4.0-73-ubuntu14+16.series index 5f0232b..4994434 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-4.4.0-73-ubuntu14+16.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-4.4.0-73-ubuntu14+16.series @@ -7,22 +7,22 @@ ubuntu14+16/ext4-misc.patch sles12sp2/ext4-mballoc-extra-checks.patch sles12sp2/ext4-hash-indexed-dir-dotdot-update.patch sles12sp2/ext4-kill-dx-root.patch -rhel7/ext4-mballoc-pa-free-mismatch.patch +rhel7.6/ext4-mballoc-pa-free-mismatch.patch ubuntu14+16/ext4-data-in-dirent-001.patch ubuntu14+16/ext4-large-eas.patch ubuntu14+16/ext4-disable-mb-cache-001.patch -rhel7/ext4-nocmtime.patch +rhel7.6/ext4-nocmtime.patch ubuntu14+16/ext4-large-dir-001.patch ubuntu14+16/ext4-pdirop-001.patch sles12sp2/ext4-max-dir-size.patch sles12sp2/ext4-corrupted-inode-block-bitmaps-handling-patches.patch sles12sp2/ext4-give-warning-with-dir-htree-growing.patch sles12sp2/ext4-mmp-brelse.patch -rhel7/ext4-jcb-optimization.patch +rhel7.6/ext4-jcb-optimization.patch sles12sp2/ext4-attach-jinode-in-writepages.patch -rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch -rhel7/ext4-export-orphan-add.patch -rhel7/ext4-mmp-dont-mark-bh-dirty.patch -rhel7/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch +rhel7.6/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch +rhel7.6/ext4-export-orphan-add.patch +rhel7.6/ext4-mmp-dont-mark-bh-dirty.patch +rhel7.6/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch sles12sp2/ext4-export-mb-stream-allocator-variables.patch -rhel7/ext4-optimize-ext4_find_delalloc_range-in-nodelalloc.patch +rhel7.6/ext4-optimize-ext4_find_delalloc_range-in-nodelalloc.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-5.0.0-13-ubuntu19.series b/ldiskfs/kernel_patches/series/ldiskfs-5.0.0-13-ubuntu19.series index 1ab4116..aea3c2c 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-5.0.0-13-ubuntu19.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-5.0.0-13-ubuntu19.series @@ -7,7 +7,7 @@ ubuntu19/ext4-misc.patch rhel8/ext4-mballoc-extra-checks.patch ubuntu18/ext4-hash-indexed-dir-dotdot-update.patch ubuntu18/ext4-kill-dx-root.patch -rhel7/ext4-mballoc-pa-free-mismatch.patch +rhel7.6/ext4-mballoc-pa-free-mismatch.patch ubuntu18/ext4-data-in-dirent.patch rhel8/ext4-nocmtime.patch rhel8/ext4-pdirop.patch @@ -17,8 +17,8 @@ ubuntu18/ext4-give-warning-with-dir-htree-growing.patch ubuntu18/ext4-jcb-optimization.patch ubuntu18/ext4-attach-jinode-in-writepages.patch rhel8/ext4-dont-check-before-replay.patch -rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch -rhel7/ext4-export-orphan-add.patch +rhel7.6/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch +rhel7.6/ext4-export-orphan-add.patch rhel8/ext4-export-mb-stream-allocator-variables.patch ubuntu19/ext4-iget-with-flags.patch rhel8/ext4-simple-blockalloc.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-5.4.0-ml.series b/ldiskfs/kernel_patches/series/ldiskfs-5.4.0-ml.series index a2582ef..76aef9f 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-5.4.0-ml.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-5.4.0-ml.series @@ -7,7 +7,7 @@ ubuntu19/ext4-misc.patch rhel8/ext4-mballoc-extra-checks.patch linux-5.4/ext4-hash-indexed-dir-dotdot-update.patch linux-5.4/ext4-kill-dx-root.patch -rhel7/ext4-mballoc-pa-free-mismatch.patch +rhel7.6/ext4-mballoc-pa-free-mismatch.patch linux-5.4/ext4-data-in-dirent.patch rhel8/ext4-nocmtime.patch linux-5.4/ext4-pdirop.patch @@ -17,8 +17,8 @@ linux-5.4/ext4-give-warning-with-dir-htree-growing.patch ubuntu18/ext4-jcb-optimization.patch linux-5.4/ext4-attach-jinode-in-writepages.patch rhel8/ext4-dont-check-before-replay.patch -rhel7/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch -rhel7/ext4-export-orphan-add.patch +rhel7.6/ext4-use-GFP_NOFS-in-ext4_inode_attach_jinode.patch +rhel7.6/ext4-export-orphan-add.patch rhel8/ext4-export-mb-stream-allocator-variables.patch ubuntu19/ext4-iget-with-flags.patch linux-5.4/export-ext4fs-dirhash-helper.patch -- 1.8.3.1