From: Greg Kroah-Hartman Date: Mon, 26 Sep 2011 16:04:20 +0000 (-0700) Subject: 3.0 patches X-Git-Tag: v3.0.5~12 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=163b9cf5f8760200e4671f8cbbbf3f585acfa9a6;p=thirdparty%2Fkernel%2Fstable-queue.git 3.0 patches --- diff --git a/queue-3.0/btrfs-fix-d_off-in-the-first-dirent.patch b/queue-3.0/btrfs-fix-d_off-in-the-first-dirent.patch new file mode 100644 index 00000000000..37002a8af21 --- /dev/null +++ b/queue-3.0/btrfs-fix-d_off-in-the-first-dirent.patch @@ -0,0 +1,74 @@ +From 3765fefaee2da83f10829fa64a74e6b7360350cb Mon Sep 17 00:00:00 2001 +From: Hidetoshi Seto +Date: Sun, 18 Sep 2011 10:20:46 -0400 +Subject: btrfs: fix d_off in the first dirent + +From: Hidetoshi Seto + +commit 3765fefaee2da83f10829fa64a74e6b7360350cb upstream. + +Since the d_off in the first dirent for "." (that originates from +the 4th argument "offset" of filldir() for the 2nd dirent for "..") +is wrongly assigned in btrfs_real_readdir(), telldir returns same +offset for different locations. + + | # mkfs.btrfs /dev/sdb1 + | # mount /dev/sdb1 fs0 + | # cd fs0 + | # touch file0 file1 + | # ../test + | telldir: 0 + | readdir: d_off = 2, d_name = "." + | telldir: 2 + | readdir: d_off = 2, d_name = ".." + | telldir: 2 + | readdir: d_off = 3, d_name = "file0" + | telldir: 3 + | readdir: d_off = 2147483647, d_name = "file1" + | telldir: 2147483647 + +To fix this problem, pass filp->f_pos (which is loff_t) instead. + + | # ../test + | telldir: 0 + | readdir: d_off = 1, d_name = "." + | telldir: 1 + | readdir: d_off = 2, d_name = ".." + | telldir: 2 + | readdir: d_off = 3, d_name = "file0" + : + +At the moment the "offset" for "." is unused because there is no +preceding dirent, however it is better to pass filp->f_pos to follow +grammatical usage. + +Signed-off-by: Hidetoshi Seto +Signed-off-by: Chris Mason +Cc: Grazvydas Ignotas +Signed-off-by: Greg Kroah-Hartman + +--- + fs/btrfs/inode.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +--- a/fs/btrfs/inode.c ++++ b/fs/btrfs/inode.c +@@ -4124,7 +4124,8 @@ static int btrfs_real_readdir(struct fil + + /* special case for "." */ + if (filp->f_pos == 0) { +- over = filldir(dirent, ".", 1, 1, btrfs_ino(inode), DT_DIR); ++ over = filldir(dirent, ".", 1, ++ filp->f_pos, btrfs_ino(inode), DT_DIR); + if (over) + return 0; + filp->f_pos = 1; +@@ -4133,7 +4134,7 @@ static int btrfs_real_readdir(struct fil + if (filp->f_pos == 1) { + u64 pino = parent_ino(filp->f_path.dentry); + over = filldir(dirent, "..", 2, +- 2, pino, DT_DIR); ++ filp->f_pos, pino, DT_DIR); + if (over) + return 0; + filp->f_pos = 2; diff --git a/queue-3.0/series b/queue-3.0/series index be92d9bfb62..8db4032424d 100644 --- a/queue-3.0/series +++ b/queue-3.0/series @@ -209,3 +209,4 @@ alsa-usb-audio-clear-chip-probing-on-error-exit.patch drm-radeon-kms-fix-ddia-enable-on-some-rs690-systems.patch alsa-fm801-fix-double-free-in-case-of-error-in-tuner-detection.patch alsa-fm801-gracefully-handle-failure-of-tuner-auto-detect.patch +btrfs-fix-d_off-in-the-first-dirent.patch