[PATCH 2/2] xfstests: btrfs, test send's ability to punch holes and prealloc extents

2018-05-08 Thread Howard McLauchlan
From: Filipe Manana 

This test verifies that after an incremental btrfs send the
replicated file has the same exact hole and data structure as in
the origin filesystem. This didn't use to be the case before the
send stream version 2 - holes were sent as write operations of 0
valued bytes instead of punching holes with the fallocate system
call, and pre-allocated extents were sent as well as write
operations of 0 valued bytes instead of intructions for the
receiver to use the fallocate system call.

It also checks that prealloc extents that lie beyond the file's
size are replicated by an incremental send.

[Howard: rebased on kernel v4.17-rc4, btrfs progs v4.16.1]
Signed-off-by: Howard McLauchlan 
Signed-off-by: Filipe David Borba Manana 
---
 common/rc   |  10 
 tests/btrfs/160 | 121 
 tests/btrfs/160.out |  42 +++
 tests/btrfs/group   |   1 +
 4 files changed, 174 insertions(+)
 create mode 100755 tests/btrfs/160
 create mode 100644 tests/btrfs/160.out

diff --git a/common/rc b/common/rc
index 9ffab7fd..e2e9904a 100644
--- a/common/rc
+++ b/common/rc
@@ -3802,6 +3802,16 @@ _require_scratch_feature()
esac
 }
 
+_require_btrfs_stream_version_2()
+{
+   $BTRFS_UTIL_PROG send 2>&1 | \
+   grep '^[ \t]*\--stream-version[ \t]\+.*' > /dev/null 2>&1
+   if [ $? -ne 0 ]; then
+   _notrun "Missing btrfs-progs send -a command line option, 
skipped this test"
+   fi
+}
+
+
 init_rc
 
 

diff --git a/tests/btrfs/160 b/tests/btrfs/160
new file mode 100755
index ..e4b7264c
--- /dev/null
+++ b/tests/btrfs/160
@@ -0,0 +1,121 @@
+#! /bin/bash
+# FS QA Test No. btrfs/160
+#
+# Verify that after an incremental btrfs send the replicated file has
+# the same exact hole and data structure as in the origin filesystem.
+# This didn't use to be the case before the send stream version 2 -
+# holes were sent as write operations of 0 valued bytes instead of punching
+# holes with the fallocate system call, and pre-allocated extents were sent
+# as well as write operations of 0 valued bytes instead of intructions for
+# the receiver to use the fallocate system call. Also check that prealloc
+# extents that lie beyond the file's size are replicated by an incremental
+# send.
+#
+# More specifically, this structure preserving guarantee was added by the
+# following linux kernel commits:
+#
+#Btrfs: send, use fallocate command to punch holes
+#Btrfs: send, use fallocate command to allocate extents
+#
+#---
+# Copyright (c) 2014 Filipe Manana.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#---
+#
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+tmp=/tmp/$$
+status=1   # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+rm -fr $send_files_dir
+rm -fr $tmp
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/punch
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+_require_fssum
+_require_xfs_io_command "fiemap"
+_require_btrfs_stream_version_2
+
+send_files_dir=$TEST_DIR/btrfs-test-$seq
+
+rm -f $seqres.full
+rm -fr $send_files_dir
+mkdir $send_files_dir
+
+_scratch_mkfs >/dev/null 2>&1
+_scratch_mount
+
+$XFS_IO_PROG -f -c "pwrite -S 0x01 -b 30 0 30" $SCRATCH_MNT/foo \
+   | _filter_xfs_io
+
+_run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap1
+
+$XFS_IO_PROG -c "fpunch 10 5" $SCRATCH_MNT/foo
+$XFS_IO_PROG -c "falloc 10 5" $SCRATCH_MNT/foo
+$XFS_IO_PROG -c "pwrite -S 0xff -b 1000 12 1000" $SCRATCH_MNT/foo \
+   | _filter_xfs_io
+$XFS_IO_PROG -c "fpunch 25 2" $SCRATCH_MNT/foo
+
+$XFS_IO_PROG -c "falloc -k 30 100" $SCRATCH_MNT/foo
+$XFS_IO_PROG -c "falloc -k 900 200" $SCRATCH_MNT/foo
+
+_run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap2
+
+_run_btrfs_util_prog send --stream-version 2 -f $send_files_dir/1.snap \
+$SCRATCH_MNT/mysnap1
+_run_btrfs_util_prog 

[PATCH 1/2] btrfs: add verify chattr support for send/receive test

2018-05-08 Thread Howard McLauchlan
From: Howard McLauchlan 

This test aims to verify correct behaviour with chattr operations and
btrfs send/receive. The intent is to check general correctness as well
as special interactions with troublesome flags(immutable, append only).

This test is motivated by a bug in btrfs which demonstrates a lack of
chattr support in btrfs send/receive.

A kernel patch to fix this can be found at:

btrfs: add chattr support for send/receive

The accompanying userspace patch can be found at:

btrfs-progs: add chattr support for send/receive

Signed-off-by: Howard McLauchlan 
---
 tests/btrfs/161 | 202 
 tests/btrfs/161.out |  38 +
 tests/btrfs/group   |   1 +
 3 files changed, 241 insertions(+)
 create mode 100755 tests/btrfs/161
 create mode 100644 tests/btrfs/161.out

diff --git a/tests/btrfs/161 b/tests/btrfs/161
new file mode 100755
index ..6c30a5e2
--- /dev/null
+++ b/tests/btrfs/161
@@ -0,0 +1,202 @@
+#! /bin/bash
+# FS QA Test 161
+#
+# This test verifies the correct behaviour of chattr support for btrfs
+# send/receive; 6 cases will be tested:
+# 1. New inode created with an inode flag set
+# 2. Existing inode with BTRFS_INODE_APPEND is written to with sequence:
+#  chattr -a
+#  pwrite something
+#  chattr +a
+# 3. Existing inode with BTRFS_INODE_APPEND is written to with sequence:
+#  chattr -a
+#  pwrite something
+#  chattr +d
+# 4. Existing inode is written to with sequence:
+#  setfattr something
+#  chattr +a
+# 5. Existing inode with BTRFS_INODE_APPEND is written to with sequence:
+#  chattr -a
+#  setfattr something
+#  setfattr something else
+#  chattr +a
+# 6. As above, but with pwrite instead of setfattr
+# The goal of 5 and 6 is not to test correctness, but to ensure we
+# don't send extra chattrs that are unnecessary.
+#
+# We verify the md5sum of the snapshots in the receive directory to ensure file
+# contents have changed appropriately. We also observe the flags changing (or
+# not changing) as appropriate.
+#
+#---
+# Copyright (c) 2018 Facebook.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#---
+#
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1   # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+   cd /
+   rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+
+# Modify as appropriate.
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+
+send_files_dir=$TEST_DIR/btrfs-test-$seq
+
+rm -rf $send_files_dir
+mkdir $send_files_dir
+
+_scratch_mkfs >>$seqres.full 2>&1
+_scratch_mount
+
+# Create receive directory
+mkdir $SCRATCH_MNT/receive
+
+# Create test file and set chattr flag
+_run_btrfs_util_prog subvolume create $SCRATCH_MNT/parent
+$XFS_IO_PROG -f -c "pwrite -S 0xaa 0K 32K" $SCRATCH_MNT/parent/foo | 
_filter_xfs_io
+$CHATTR_PROG +a $SCRATCH_MNT/parent/foo
+
+# Send/Receive initial snapshot
+_run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT/parent \
+   $SCRATCH_MNT/old_parent
+_run_btrfs_util_prog send --stream-version 2 -f $SCRATCH_MNT/out 
$SCRATCH_MNT/old_parent
+_run_btrfs_util_prog receive -f $SCRATCH_MNT/out $SCRATCH_MNT/receive
+
+# Verify post-send content and flags
+echo "post-send file digest for old_parent:"
+md5sum $SCRATCH_MNT/old_parent/foo | _filter_scratch
+echo "post-send file flag for old_parent:"
+lsattr $SCRATCH_MNT/receive/old_parent/foo | _filter_scratch
+
+# Make change
+$CHATTR_PROG -a $SCRATCH_MNT/parent/foo
+$XFS_IO_PROG -f -c "pwrite -S 0xab 0K 32K" $SCRATCH_MNT/parent/foo | 
_filter_xfs_io
+$CHATTR_PROG +a $SCRATCH_MNT/parent/foo
+
+# Send incremental change
+_run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT/parent \
+   $SCRATCH_MNT/child_1
+_run_btrfs_util_prog send --stream-version 2 -p $SCRATCH_MNT/old_parent -f 
$SCRATCH_MNT/out \
+$SCRATCH_MNT/child_1
+_run_btrfs_util_prog 

[RFC PATCH 6/6] btrfs-progs: add chattr support for send/receive

2018-05-08 Thread Howard McLauchlan
From: Howard McLauchlan 

Presently, btrfs send/receive does not propagate inode attribute flags;
all chattr operations are effectively discarded upon transmission.

This patch adds userspace support for inode attribute flags. Kernel
support can be found under the commit:

btrfs: add chattr support for send/receive

An associated xfstest can also be found at:

btrfs: verify chattr support for send/receive test

Signed-off-by: Howard McLauchlan 
---
 cmds-receive.c | 37 +
 send-dump.c|  6 ++
 send-stream.c  |  5 +
 send-stream.h  |  1 +
 send.h |  4 ++--
 5 files changed, 51 insertions(+), 2 deletions(-)

diff --git a/cmds-receive.c b/cmds-receive.c
index 20e593f7..2a841bfc 100644
--- a/cmds-receive.c
+++ b/cmds-receive.c
@@ -40,6 +40,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "ctree.h"
 #include "ioctl.h"
@@ -1201,6 +1202,41 @@ out:
return ret;
 }
 
+static int process_chattr(const char *path, u64 flags, void *user)
+{
+   int ret = 0;
+   int fd = 0;
+   int _flags = flags;
+   struct btrfs_receive *rctx = user;
+   char full_path[PATH_MAX];
+
+   ret = path_cat_out(full_path, rctx->full_subvol_path, path);
+   if (ret < 0) {
+   error("chattr: path invalid: %s", path);
+   goto out;
+   }
+
+   if (g_verbose >= 2)
+   fprintf(stderr, "chattr %s - flags=0%o\n", path, (int)flags);
+
+   fd = open(full_path, O_RDONLY);
+   if (fd < 0) {
+   ret = -errno;
+   error("cannot open %s: %s", path, strerror(-ret));
+   goto out;
+   }
+
+   ret = ioctl(fd, FS_IOC_SETFLAGS, &_flags);
+   if (ret < 0) {
+   ret = -errno;
+   error("chattr %s failed: %s", path, strerror(-ret));
+   goto out;
+   }
+
+out:
+   return ret;
+}
+
 static struct btrfs_send_ops send_ops = {
.subvol = process_subvol,
.snapshot = process_snapshot,
@@ -1225,6 +1261,7 @@ static struct btrfs_send_ops send_ops = {
.update_extent = process_update_extent,
.total_data_size = process_total_data_size,
.fallocate = process_fallocate,
+   .chattr = process_chattr,
 };
 
 static int do_receive(struct btrfs_receive *rctx, const char *tomnt,
diff --git a/send-dump.c b/send-dump.c
index c5a695a2..15aea402 100644
--- a/send-dump.c
+++ b/send-dump.c
@@ -331,6 +331,11 @@ static int print_fallocate(const char *path, u32 flags, 
u64 offset, u64 len,
  len);
 }
 
+static int print_chattr(const char *path, u64 flags, void *user)
+{
+   return PRINT_DUMP(user, path, "chattr", "flags=%llu", flags);
+}
+
 struct btrfs_send_ops btrfs_print_send_ops = {
.subvol = print_subvol,
.snapshot = print_snapshot,
@@ -355,4 +360,5 @@ struct btrfs_send_ops btrfs_print_send_ops = {
.update_extent = print_update_extent,
.total_data_size = print_total_data_size,
.fallocate = print_fallocate,
+   .chattr = print_chattr,
 };
diff --git a/send-stream.c b/send-stream.c
index 74ec37dd..4f26fae3 100644
--- a/send-stream.c
+++ b/send-stream.c
@@ -470,6 +470,11 @@ static int read_and_process_cmd(struct btrfs_send_stream 
*sctx)
sctx->user);
}
break;
+   case BTRFS_SEND_C_CHATTR:
+   TLV_GET_STRING(sctx, BTRFS_SEND_A_PATH, );
+   TLV_GET_U64(sctx, BTRFS_SEND_A_CHATTR, );
+   ret = sctx->ops->chattr(path, tmp, sctx->user);
+   break;
case BTRFS_SEND_C_END:
ret = 1;
break;
diff --git a/send-stream.h b/send-stream.h
index 89e64043..a9f08d52 100644
--- a/send-stream.h
+++ b/send-stream.h
@@ -69,6 +69,7 @@ struct btrfs_send_ops {
int (*total_data_size)(u64 size, void *user);
int (*fallocate)(const char *path, u32 flags, u64 offset,
 u64 len, void *user);
+   int (*chattr)(const char *path, u64 flags, void *user);
 };
 
 int btrfs_read_and_process_send_stream(int fd,
diff --git a/send.h b/send.h
index eb14fba3..5b5ada61 100644
--- a/send.h
+++ b/send.h
@@ -103,8 +103,8 @@ enum btrfs_send_cmd {
 */
BTRFS_SEND_C_TOTAL_DATA_SIZE,
BTRFS_SEND_C_FALLOCATE,
-   BTRFS_SEND_C_INODE_SET_FLAGS,
BTRFS_SEND_C_UTIMES2, /* Same as UTIMES, but it includes OTIME too. */
+   BTRFS_SEND_C_CHATTR,
 
__BTRFS_SEND_C_MAX,
 };
@@ -148,7 +148,7 @@ enum {
 * The following attributes were added in stream version 2.
 */
BTRFS_SEND_A_FALLOCATE_FLAGS, /* 32 bits */
-   BTRFS_SEND_A_INODE_FLAGS, /* 32 bits */
+   BTRFS_SEND_A_CHATTR,  /* 32 bits */
 
__BTRFS_SEND_A_MAX,
 };
-- 
2.17.0

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to 

[RFC PATCH 5/6] btrfs-progs: add total data size, fallocate to dump

2018-05-08 Thread Howard McLauchlan
From: Howard McLauchlan 

Adding entries to dump for new commands (total data size, fallocate).

Signed-off-by: Howard McLauchlan 
---
 send-dump.c | 19 ++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/send-dump.c b/send-dump.c
index 1591e0cc..c5a695a2 100644
--- a/send-dump.c
+++ b/send-dump.c
@@ -316,6 +316,21 @@ static int print_update_extent(const char *path, u64 
offset, u64 len,
  offset, len);
 }
 
+static int print_total_data_size(u64 size, void *user)
+{
+   char path;
+
+   return PRINT_DUMP(user, , "total_data_size", "size=%llu", size);
+}
+
+static int print_fallocate(const char *path, u32 flags, u64 offset, u64 len,
+  void *user)
+{
+   return PRINT_DUMP(user, path, "fallocate",
+ "flags=%u offset=%llu len=%llu", flags, offset,
+ len);
+}
+
 struct btrfs_send_ops btrfs_print_send_ops = {
.subvol = print_subvol,
.snapshot = print_snapshot,
@@ -337,5 +352,7 @@ struct btrfs_send_ops btrfs_print_send_ops = {
.chmod = print_chmod,
.chown = print_chown,
.utimes = print_utimes,
-   .update_extent = print_update_extent
+   .update_extent = print_update_extent,
+   .total_data_size = print_total_data_size,
+   .fallocate = print_fallocate,
 };
-- 
2.17.0

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC PATCH 4/6] Btrfs-progs: add write and clone commands debug info to receive

2018-05-08 Thread Howard McLauchlan
From: Filipe Manana 

When specifying -vv print information about received write and clone commands 
too,
as we do this for other commands already and it's very useful for debugging and
troubleshooting.

Signed-off-by: Filipe David Borba Manana 
---
 cmds-receive.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/cmds-receive.c b/cmds-receive.c
index 510b6bc8..20e593f7 100644
--- a/cmds-receive.c
+++ b/cmds-receive.c
@@ -790,6 +790,10 @@ static int process_write(const char *path, const void 
*data, u64 offset,
u64 pos = 0;
int w;
 
+   if (g_verbose >= 2)
+   fprintf(stderr, "write %s, offset %llu, len %llu\n",
+   path, offset, len);
+
ret = path_cat_out(full_path, rctx->full_subvol_path, path);
if (ret < 0) {
error("write: path invalid: %s", path);
@@ -831,6 +835,11 @@ static int process_clone(const char *path, u64 offset, u64 
len,
char full_clone_path[PATH_MAX];
int clone_fd = -1;
 
+   if (g_verbose >= 2)
+   fprintf(stderr,
+   "clone %s, offset %llu, len %llu, clone path %s, clone 
offset %llu\n",
+   path, offset, len, clone_path, clone_offset);
+
ret = path_cat_out(full_path, rctx->full_subvol_path, path);
if (ret < 0) {
error("clone: source path invalid: %s", path);
-- 
2.17.0

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC PATCH 3/6] Btrfs-progs: send, implement fallocate command callback

2018-05-08 Thread Howard McLauchlan
From: Filipe Manana 

The fallocate send stream command, added in stream version 2, is used to
pre-allocate space for files and punch file holes. This change implements
the callback for that new command, using the fallocate function from the
standard C library to carry out the specified action (allocate file space
or punch a file hole).

Signed-off-by: Filipe David Borba Manana 
---
 cmds-receive.c | 44 
 send-stream.c  | 13 +
 send-stream.h  |  2 ++
 3 files changed, 59 insertions(+)

diff --git a/cmds-receive.c b/cmds-receive.c
index d8ff5194..510b6bc8 100644
--- a/cmds-receive.c
+++ b/cmds-receive.c
@@ -39,6 +39,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "ctree.h"
 #include "ioctl.h"
@@ -1149,6 +1150,48 @@ static int process_update_extent(const char *path, u64 
offset, u64 len,
return 0;
 }
 
+static int process_fallocate(const char *path, u32 flags, u64 offset,
+u64 len, void *user)
+{
+   struct btrfs_receive *rctx = user;
+   int mode = 0;
+   int ret;
+   char full_path[PATH_MAX];
+
+   ret = path_cat_out(full_path, rctx->full_subvol_path, path);
+   if (ret < 0) {
+   error("fallocate: path invalid: %s", path);
+   goto out;
+   }
+
+   if (flags & BTRFS_SEND_A_FALLOCATE_FLAG_KEEP_SIZE)
+   mode |= FALLOC_FL_KEEP_SIZE;
+   if (flags & BTRFS_SEND_A_FALLOCATE_FLAG_PUNCH_HOLE)
+   mode |= FALLOC_FL_PUNCH_HOLE;
+
+   if (g_verbose >= 2)
+   fprintf(stderr,
+   "fallocate %s - flags %u, offset %llu, len %llu\n",
+   path, flags, offset, len);
+
+   ret = open_inode_for_write(rctx, full_path);
+   if (ret < 0)
+   goto out;
+
+   ret = fallocate(rctx->write_fd, mode, offset, len);
+   if (ret) {
+   ret = -errno;
+   fprintf(stderr,
+   "ERROR: fallocate against %s failed. %s\n",
+   path, strerror(-ret));
+   goto out;
+   }
+   update_progress(rctx, len);
+
+out:
+   return ret;
+}
+
 static struct btrfs_send_ops send_ops = {
.subvol = process_subvol,
.snapshot = process_snapshot,
@@ -1172,6 +1215,7 @@ static struct btrfs_send_ops send_ops = {
.utimes = process_utimes,
.update_extent = process_update_extent,
.total_data_size = process_total_data_size,
+   .fallocate = process_fallocate,
 };
 
 static int do_receive(struct btrfs_receive *rctx, const char *tomnt,
diff --git a/send-stream.c b/send-stream.c
index d30fd5a7..74ec37dd 100644
--- a/send-stream.c
+++ b/send-stream.c
@@ -457,6 +457,19 @@ static int read_and_process_cmd(struct btrfs_send_stream 
*sctx)
TLV_GET_U64(sctx, BTRFS_SEND_A_SIZE, );
ret = sctx->ops->total_data_size(tmp, sctx->user);
break;
+   case BTRFS_SEND_C_FALLOCATE:
+   {
+   u32 flags;
+   u64 len;
+
+   TLV_GET_STRING(sctx, BTRFS_SEND_A_PATH, );
+   TLV_GET_U32(sctx, BTRFS_SEND_A_FALLOCATE_FLAGS, );
+   TLV_GET_U64(sctx, BTRFS_SEND_A_FILE_OFFSET, );
+   TLV_GET_U64(sctx, BTRFS_SEND_A_SIZE, );
+   ret = sctx->ops->fallocate(path, flags, offset, len,
+   sctx->user);
+   }
+   break;
case BTRFS_SEND_C_END:
ret = 1;
break;
diff --git a/send-stream.h b/send-stream.h
index 5b244ab6..89e64043 100644
--- a/send-stream.h
+++ b/send-stream.h
@@ -67,6 +67,8 @@ struct btrfs_send_ops {
  void *user);
int (*update_extent)(const char *path, u64 offset, u64 len, void *user);
int (*total_data_size)(u64 size, void *user);
+   int (*fallocate)(const char *path, u32 flags, u64 offset,
+u64 len, void *user);
 };
 
 int btrfs_read_and_process_send_stream(int fd,
-- 
2.17.0

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC PATCH 2/6] Btrfs-progs: send, implement total data size callback and progress report

2018-05-08 Thread Howard McLauchlan
From: Filipe Manana 

This is a followup to the kernel patch titled:

Btrfs: send, implement total data size command to allow for progress 
estimation

This makes the btrfs send and receive commands aware of the new send flag,
named BTRFS_SEND_C_TOTAL_DATA_SIZE, which tells us the amount of file data
that is new between the parent and send snapshots/roots. As this command
immediately follows the commands to start a snapshot/subvolume, it can be
used to report and compute progress, by keeping a counter that is incremented
with the data length of each write, clone and fallocate command that is received
from the stream.

Example:

$ btrfs send -s --stream-version 2 /mnt/sdd/snap_base | btrfs receive 
/mnt/sdc
At subvol /mnt/sdd/snap_base
At subvol snap_base
About to receive 9212392667 bytes
Subvolume /mnt/sdc//snap_base, 4059722426 / 9212392667 bytes received, 
44.07%, 40.32MB/s

$ btrfs send -s --stream-version 2 -p /mnt/sdd/snap_base /mnt/sdd/snap_incr 
| btrfs receive /mnt/sdc
At subvol /mnt/sdd/snap_incr
At subvol snap_incr
About to receive 9571342213 bytes
Subvolume /mnt/sdc//snap_incr, 6557345221 / 9571342213 bytes received, 
68.51%, 51.04MB/s

At the moment progress is only reported by btrfs-receive, but it is possible 
and simple
to do it for btrfs-send too, so that we can get progress report when not piping 
btrfs-send
output to btrfs-receive (directly to a file).

Signed-off-by: Filipe David Borba Manana 
---
 cmds-receive.c | 91 ++
 cmds-send.c| 23 +++--
 send-stream.c  |  4 +++
 send-stream.h  |  1 +
 4 files changed, 117 insertions(+), 2 deletions(-)

diff --git a/cmds-receive.c b/cmds-receive.c
index 68123a31..d8ff5194 100644
--- a/cmds-receive.c
+++ b/cmds-receive.c
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -79,6 +80,14 @@ struct btrfs_receive
 
int honor_end_cmd;
 
+   /* For the subvolume/snapshot we're currently receiving. */
+   u64 total_data_size;
+   u64 bytes_received;
+   time_t last_progress_update;
+   u64 bytes_received_last_update;
+   float progress;
+   const char *target;
+
/*
 * Buffer to store capabilities from security.capabilities xattr,
 * usually 20 bytes, but make same room for potentially larger
@@ -156,6 +165,16 @@ out:
return ret;
 }
 
+static void reset_progress(struct btrfs_receive *rctx, const char *dest)
+{
+   rctx->total_data_size = 0;
+   rctx->bytes_received = 0;
+   rctx->progress = 0.0;
+   rctx->last_progress_update = 0;
+   rctx->bytes_received_last_update = 0;
+   rctx->target = dest;
+}
+
 static int process_subvol(const char *path, const u8 *uuid, u64 ctransid,
  void *user)
 {
@@ -180,6 +199,7 @@ static int process_subvol(const char *path, const u8 *uuid, 
u64 ctransid,
ret = -EINVAL;
goto out;
}
+   reset_progress(rctx, "Subvolume");
 
if (*rctx->dest_dir_path == 0) {
strncpy_null(rctx->cur_subvol_path, path);
@@ -249,6 +269,7 @@ static int process_snapshot(const char *path, const u8 
*uuid, u64 ctransid,
ret = -EINVAL;
goto out;
}
+   reset_progress(rctx, "Snapshot");
 
if (*rctx->dest_dir_path == 0) {
strncpy_null(rctx->cur_subvol_path, path);
@@ -388,6 +409,73 @@ out:
return ret;
 }
 
+static int process_total_data_size(u64 size, void *user)
+{
+   struct btrfs_receive *rctx = user;
+
+   rctx->total_data_size = size;
+   fprintf(stdout, "About to receive %llu bytes\n", size);
+
+   return 0;
+}
+
+static void update_progress(struct btrfs_receive *rctx, u64 bytes)
+{
+   float new_progress;
+   time_t now;
+   time_t tdiff;
+
+   if (rctx->total_data_size == 0)
+   return;
+
+   rctx->bytes_received += bytes;
+
+   now = time(NULL);
+   tdiff = now - rctx->last_progress_update;
+   if (tdiff < 1) {
+   if (rctx->bytes_received == rctx->total_data_size)
+   fprintf(stdout, "\n");
+   return;
+   }
+
+   new_progress = ((float)rctx->bytes_received / rctx->total_data_size) * 
100.0;
+
+   if ((int)(new_progress * 100) > (int)(rctx->progress * 100) ||
+   rctx->bytes_received == rctx->total_data_size) {
+   char line[5000];
+   float rate = rctx->bytes_received - 
rctx->bytes_received_last_update;
+   const char *rate_units;
+
+   rate /= tdiff;
+   if (rate > (1024 * 1024)) {
+   rate_units = "MB/s";
+   rate /= 1024 * 1024;
+   } else if (rate > 1024) {
+   rate_units = "KB/s";
+   rate /= 1024;
+   } else {
+ 

[RFC PATCH 1/6] Btrfs-progs: send, bump stream version

2018-05-08 Thread Howard McLauchlan
From: Filipe Manana 

This increases the send stream version from version 1 to version 2, adding
new commands:

1) total data size - used to tell the receiver how much file data the stream
   will add or update;

2) fallocate - used to pre-allocate space for files and to punch holes in files;

3) inode set flags;

4) set inode otime.

This is preparation work for subsequent changes that implement the new features.

This doesn't break compatibility with older kernels or clients. In order to get
a version 2 send stream, new flags must be passed to the send ioctl.

Signed-off-by: Filipe David Borba Manana 
---
 cmds-send.c   | 61 ---
 ioctl.h   | 15 +
 send-stream.c |  2 +-
 send.h| 23 ++-
 4 files changed, 81 insertions(+), 20 deletions(-)

diff --git a/cmds-send.c b/cmds-send.c
index c5ecdaa1..0ec557c7 100644
--- a/cmds-send.c
+++ b/cmds-send.c
@@ -52,6 +52,7 @@
  * the 'At subvol' message.
  */
 static int g_verbose = 1;
+static int g_stream_version = BTRFS_SEND_STREAM_VERSION_1;
 
 struct btrfs_send {
int send_fd;
@@ -343,6 +344,8 @@ static int do_send(struct btrfs_send *send, u64 
parent_root_id,
io_send.flags |= BTRFS_SEND_FLAG_OMIT_STREAM_HEADER;
if (!is_last_subvol)
io_send.flags |= BTRFS_SEND_FLAG_OMIT_END_CMD;
+   if (g_stream_version == BTRFS_SEND_STREAM_VERSION_2)
+   io_send.flags |= BTRFS_SEND_FLAG_STREAM_V2;
ret = ioctl(subvol_fd, BTRFS_IOC_SEND, _send);
if (ret < 0) {
ret = -errno;
@@ -513,7 +516,8 @@ int cmd_send(int argc, char **argv)
static const struct option long_options[] = {
{ "verbose", no_argument, NULL, 'v' },
{ "quiet", no_argument, NULL, 'q' },
-   { "no-data", no_argument, NULL, GETOPT_VAL_SEND_NO_DATA 
}
+   { "no-data", no_argument, NULL, GETOPT_VAL_SEND_NO_DATA 
},
+   { "stream-version", 1, NULL, 'V' },
};
int c = getopt_long(argc, argv, "vqec:f:i:p:", long_options, 
NULL);
 
@@ -597,6 +601,24 @@ int cmd_send(int argc, char **argv)
error("option -i was removed, use -c instead");
ret = 1;
goto out;
+   case 'V':
+   if (sscanf(optarg, "%d", _stream_version) != 1) {
+   fprintf(stderr,
+   "ERROR: invalid value for stream 
version: %s\n",
+   optarg);
+   ret = 1;
+   goto out;
+   }
+   if (g_stream_version <= 0 ||
+   g_stream_version > BTRFS_SEND_STREAM_VERSION_MAX) {
+   fprintf(stderr,
+   "ERROR: unsupported stream version %d, 
minimum: 1, maximum: %d\n",
+   g_stream_version,
+   BTRFS_SEND_STREAM_VERSION_MAX);
+   ret = 1;
+   goto out;
+   }
+   break;
case GETOPT_VAL_SEND_NO_DATA:
send_flags |= BTRFS_SEND_FLAG_NO_FILE_DATA;
break;
@@ -776,7 +798,7 @@ out:
 }
 
 const char * const cmd_send_usage[] = {
-   "btrfs send [-ve] [-p ] [-c ] [-f ] 
 [...]",
+   "btrfs send [-ve] [--stream-version ] [-p ] [-c 
] [-f ]  [...]",
"Send the subvolume(s) to stdout.",
"Sends the subvolume(s) specified by  to stdout.",
" should be read-only here.",
@@ -790,21 +812,24 @@ const char * const cmd_send_usage[] = {
"which case 'btrfs send' will determine a suitable parent among the",
"clone sources itself.",
"\n",
-   "-e   If sending multiple subvols at once, use the new",
-   " format and omit the end-cmd between the subvols.",
-   "-p   Send an incremental stream from  to",
-   " .",
-   "-cUse this snapshot as a clone source for an ",
-   " incremental send (multiple allowed)",
-   "-f  Output is normally written to stdout. To write to",
-   " a file, use this option. An alternative would be to",
-   " use pipes.",
-   "--no-datasend in NO_FILE_DATA mode, Note: the output stream",
-   " does not contain any file data and thus cannot be 
used",
-   " to transfer changes. This mode is faster and useful 
to",
-   " show the differences in metadata.",
-   "-v|--verbose enable verbose output to stderr, each occurrence of",
-   "

[RFC PATCH 2/6] btrfs: send, implement total data size command to allow for progress estimation

2018-05-08 Thread Howard McLauchlan
From: Filipe David Borba Manana 

This new send flag makes send calculate first the amount of new file data (in 
bytes)
the send root has relatively to the parent root, or for the case of a 
non-incremental
send, the total amount of file data the stream will create (including holes and 
prealloc
extents). In other words, it computes the sum of the lengths of all write, 
clone and
fallocate operations that will be sent through the send stream.

This data size value is sent in a new command, named 
BTRFS_SEND_C_TOTAL_DATA_SIZE, that
immediately follows a BTRFS_SEND_C_SUBVOL or BTRFS_SEND_C_SNAPSHOT command, and 
precedes
any command that changes a file or the filesystem hierarchy. Upon receiving a 
write, clone
or fallocate command, the receiving end can increment a counter by the data 
length of that
command and therefore report progress by comparing the counter's value with the 
data size
value received in the BTRFS_SEND_C_TOTAL_DATA_SIZE command.

The approach is simple, before the normal operation of send, do a scan in the 
file system
tree for new inodes and new/changed file extent items, just like in send's 
normal operation,
and keep incrementing a counter with new inodes' size and the size of file 
extents (and file
holes)  that are going to be written, cloned or fallocated. This is actually a 
simpler and
more lightweight tree scan/processing than the one we do when sending the 
changes, as it
doesn't process inode references nor does any lookups in the extent tree for 
example.

After modifying btrfs-progs to understand this new command and report progress, 
here's an
example (the -o flag tells btrfs send to pass the new flag to the kernel's send 
ioctl):

$ btrfs send -s --stream-version 2 /mnt/sdd/snap_base | btrfs receive 
/mnt/sdc
At subvol /mnt/sdd/snap_base
At subvol snap_base
About to receive 9212392667 bytes
Subvolume /mnt/sdc//snap_base, 4059722426 / 9212392667 bytes received, 
44.07%, 40.32MB/s

$ btrfs send -s --stream-version 2 -p /mnt/sdd/snap_base /mnt/sdd/snap_incr 
| btrfs receive /mnt/sdc
At subvol /mnt/sdd/snap_incr
At subvol snap_incr
About to receive 9571342213 bytes
Subvolume /mnt/sdc//snap_incr, 6557345221 / 9571342213 bytes received, 
68.51%, 51.04MB/s

[Howard: rebased on 4.17-rc4]
Signed-off-by: Howard McLauchlan 
Signed-off-by: Filipe David Borba Manana 
---
 fs/btrfs/send.c | 189 
 1 file changed, 157 insertions(+), 32 deletions(-)

diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index eccd69387065..7b184831812b 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -66,7 +66,13 @@ struct clone_root {
 #define SEND_CTX_MAX_NAME_CACHE_SIZE 128
 #define SEND_CTX_NAME_CACHE_CLEAN_SIZE (SEND_CTX_MAX_NAME_CACHE_SIZE * 2)
 
+enum btrfs_send_phase {
+   SEND_PHASE_STREAM_CHANGES,
+   SEND_PHASE_COMPUTE_DATA_SIZE,
+};
+
 struct send_ctx {
+   enum btrfs_send_phase phase;
struct file *send_filp;
loff_t send_off;
char *send_buf;
@@ -102,6 +108,7 @@ struct send_ctx {
u64 cur_inode_next_write_offset;
 
u64 send_progress;
+   u64 total_data_size;
 
struct list_head new_refs;
struct list_head deleted_refs;
@@ -709,6 +716,8 @@ static int send_rename(struct send_ctx *sctx,
struct btrfs_fs_info *fs_info = sctx->send_root->fs_info;
int ret;
 
+   ASSERT(sctx->phase != SEND_PHASE_COMPUTE_DATA_SIZE);
+
btrfs_debug(fs_info, "send_rename %s -> %s", from->start, to->start);
 
ret = begin_cmd(sctx, BTRFS_SEND_C_RENAME);
@@ -758,6 +767,8 @@ static int send_unlink(struct send_ctx *sctx, struct 
fs_path *path)
struct btrfs_fs_info *fs_info = sctx->send_root->fs_info;
int ret;
 
+   ASSERT(sctx->phase != SEND_PHASE_COMPUTE_DATA_SIZE);
+
btrfs_debug(fs_info, "send_unlink %s", path->start);
 
ret = begin_cmd(sctx, BTRFS_SEND_C_UNLINK);
@@ -780,6 +791,7 @@ static int send_rmdir(struct send_ctx *sctx, struct fs_path 
*path)
 {
struct btrfs_fs_info *fs_info = sctx->send_root->fs_info;
int ret;
+   ASSERT(sctx->phase != SEND_PHASE_COMPUTE_DATA_SIZE);
 
btrfs_debug(fs_info, "send_rmdir %s", path->start);
 
@@ -2419,6 +2431,8 @@ static int send_truncate(struct send_ctx *sctx, u64 ino, 
u64 gen, u64 size)
int ret = 0;
struct fs_path *p;
 
+   ASSERT(sctx->phase != SEND_PHASE_COMPUTE_DATA_SIZE);
+
btrfs_debug(fs_info, "send_truncate %llu size=%llu", ino, size);
 
p = fs_path_alloc();
@@ -2449,6 +2463,8 @@ static int send_chmod(struct send_ctx *sctx, u64 ino, u64 
gen, u64 mode)
int ret = 0;
struct fs_path *p;
 
+   ASSERT(sctx->phase != SEND_PHASE_COMPUTE_DATA_SIZE);
+
btrfs_debug(fs_info, "send_chmod %llu mode=%llu", ino, mode);
 
p = fs_path_alloc();
@@ -2479,6 +2495,8 @@ static int send_chown(struct send_ctx *sctx, u64 

[RFC PATCH 3/6] btrfs: send, use fallocate command to punch holes

2018-05-08 Thread Howard McLauchlan
From: Filipe David Borba Manana 

Instead of sending a write command with a data buffer filled with 0 value bytes,
use the fallocate command, introduced in the send stream version 2, to tell the
receiver to punch a file hole using the fallocate system call.

[Howard: rebased on 4.17-rc4]
Signed-off-by: Howard McLauchlan 
Signed-off-by: Filipe David Borba Manana 
---
 fs/btrfs/send.c | 54 ++---
 fs/btrfs/send.h |  4 
 2 files changed, 55 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index 7b184831812b..328c7a2857ae 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -581,6 +581,7 @@ static int tlv_put(struct send_ctx *sctx, u16 attr, const 
void *data, int len)
return tlv_put(sctx, attr, &__tmp, sizeof(__tmp));  \
}
 
+TLV_PUT_DEFINE_INT(32)
 TLV_PUT_DEFINE_INT(64)
 
 static int tlv_put_string(struct send_ctx *sctx, u16 attr,
@@ -5047,17 +5048,57 @@ static int send_update_extent(struct send_ctx *sctx,
return ret;
 }
 
+static int send_fallocate(struct send_ctx *sctx, u32 flags,
+ u64 offset, u64 len)
+{
+   struct fs_path *p = NULL;
+   int ret = 0;
+
+   ASSERT(sctx->flags & BTRFS_SEND_FLAG_STREAM_V2);
+
+   if (sctx->phase == SEND_PHASE_COMPUTE_DATA_SIZE) {
+   sctx->total_data_size += len;
+   return 0;
+   }
+
+   p = fs_path_alloc();
+   if (!p)
+   return -ENOMEM;
+   ret = get_cur_path(sctx, sctx->cur_ino, sctx->cur_inode_gen, p);
+   if (ret < 0)
+   goto out;
+
+   ret = begin_cmd(sctx, BTRFS_SEND_C_FALLOCATE);
+   if (ret < 0)
+   goto out;
+   TLV_PUT_PATH(sctx, BTRFS_SEND_A_PATH, p);
+   TLV_PUT_U32(sctx, BTRFS_SEND_A_FALLOCATE_FLAGS, flags);
+   TLV_PUT_U64(sctx, BTRFS_SEND_A_FILE_OFFSET, offset);
+   TLV_PUT_U64(sctx, BTRFS_SEND_A_SIZE, len);
+   ret = send_cmd(sctx);
+
+tlv_put_failure:
+out:
+   fs_path_free(p);
+   return ret;
+}
+
+
 static int send_hole(struct send_ctx *sctx, u64 end)
 {
struct fs_path *p = NULL;
u64 offset = sctx->cur_inode_last_extent;
-   u64 len;
+   u64 len = end - offset;
int ret = 0;
 
if (sctx->phase == SEND_PHASE_COMPUTE_DATA_SIZE) {
-   sctx->total_data_size += end - offset;
+   sctx->total_data_size += len;
return 0;
}
+   if (sctx->flags & BTRFS_SEND_FLAG_STREAM_V2)
+   return send_fallocate(sctx, BTRFS_SEND_PUNCH_HOLE_FALLOC_FLAGS,
+ offset, len);
+
if (sctx->flags & BTRFS_SEND_FLAG_NO_FILE_DATA)
return send_update_extent(sctx, offset, end - offset);
 
@@ -5304,7 +5345,8 @@ static int send_write_or_clone(struct send_ctx *sctx,
ret = 0;
goto out;
}
-   if (offset + len > sctx->cur_inode_size)
+   if (offset < sctx->cur_inode_size &&
+   offset + len > sctx->cur_inode_size)
len = sctx->cur_inode_size - offset;
if (len == 0) {
ret = 0;
@@ -5325,6 +5367,12 @@ static int send_write_or_clone(struct send_ctx *sctx,
data_offset = btrfs_file_extent_offset(path->nodes[0], ei);
ret = clone_range(sctx, clone_root, disk_byte, data_offset,
  offset, len);
+   } else if (btrfs_file_extent_disk_bytenr(path->nodes[0], ei) == 0 &&
+type != BTRFS_FILE_EXTENT_INLINE &&
+(sctx->flags & BTRFS_SEND_FLAG_STREAM_V2) &&
+offset < sctx->cur_inode_size) {
+   ret = send_fallocate(sctx, BTRFS_SEND_PUNCH_HOLE_FALLOC_FLAGS,
+offset, len);
} else {
ret = send_extent_data(sctx, offset, len);
}
diff --git a/fs/btrfs/send.h b/fs/btrfs/send.h
index a9b5489d690e..a5830d216ac1 100644
--- a/fs/btrfs/send.h
+++ b/fs/btrfs/send.h
@@ -138,6 +138,10 @@ enum {
 #define BTRFS_SEND_A_FALLOCATE_FLAG_KEEP_SIZE   (1 << 0)
 #define BTRFS_SEND_A_FALLOCATE_FLAG_PUNCH_HOLE  (1 << 1)
 
+#define BTRFS_SEND_PUNCH_HOLE_FALLOC_FLAGS\
+   (BTRFS_SEND_A_FALLOCATE_FLAG_KEEP_SIZE |  \
+BTRFS_SEND_A_FALLOCATE_FLAG_PUNCH_HOLE)
+
 #ifdef __KERNEL__
 long btrfs_ioctl_send(struct file *mnt_file, struct btrfs_ioctl_send_args 
*arg);
 #endif
-- 
2.17.0

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC PATCH 5/6] btrfs: add send_stream_version attribute to sysfs

2018-05-08 Thread Howard McLauchlan
From: Filipe David Borba Manana 

So that applications can find out what's the highest send stream
version supported/implemented by the running kernel:

$ cat /sys/fs/btrfs/send/stream_version
2

[Howard: rebased on 4.17-rc4]
Signed-off-by: Howard McLauchlan 
Signed-off-by: Filipe David Borba Manana 
Reviewed-by: David Sterba 
---
 fs/btrfs/send.h  |  1 +
 fs/btrfs/sysfs.c | 29 +
 2 files changed, 30 insertions(+)

diff --git a/fs/btrfs/send.h b/fs/btrfs/send.h
index a5830d216ac1..2f5e25e03def 100644
--- a/fs/btrfs/send.h
+++ b/fs/btrfs/send.h
@@ -12,6 +12,7 @@
 #define BTRFS_SEND_STREAM_MAGIC "btrfs-stream"
 #define BTRFS_SEND_STREAM_VERSION_1 1
 #define BTRFS_SEND_STREAM_VERSION_2 2
+#define BTRFS_SEND_STREAM_VERSION_LATEST BTRFS_SEND_STREAM_VERSION_2
 
 #define BTRFS_SEND_BUF_SIZE SZ_64K
 #define BTRFS_SEND_READ_SIZE (48 * SZ_1K)
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index 4848a4318fb5..3c82cba91ff6 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -18,6 +18,7 @@
 #include "transaction.h"
 #include "sysfs.h"
 #include "volumes.h"
+#include "send.h"
 
 static inline struct btrfs_fs_info *to_fs_info(struct kobject *kobj);
 static inline struct btrfs_fs_devices *to_fs_devs(struct kobject *kobj);
@@ -884,6 +885,28 @@ static int btrfs_init_debugfs(void)
return 0;
 }
 
+static ssize_t send_stream_version_show(struct kobject *kobj,
+   struct kobj_attribute *a,
+   char *buf)
+{
+   return snprintf(buf, PAGE_SIZE, "%d\n",
+   BTRFS_SEND_STREAM_VERSION_LATEST);
+}
+
+BTRFS_ATTR(, stream_version, send_stream_version_show);
+
+static struct attribute *btrfs_send_attrs[] = {
+   BTRFS_ATTR_PTR(, stream_version),
+   NULL
+};
+
+static const struct attribute_group btrfs_send_attr_group = {
+   .name = "send",
+   .attrs = btrfs_send_attrs,
+};
+
+
+
 int __init btrfs_init_sysfs(void)
 {
int ret;
@@ -900,8 +923,13 @@ int __init btrfs_init_sysfs(void)
ret = sysfs_create_group(_kset->kobj, _feature_attr_group);
if (ret)
goto out2;
+   ret = sysfs_create_group(_kset->kobj, _send_attr_group);
+   if (ret)
+   goto out3;
 
return 0;
+out3:
+   sysfs_remove_group(_kset->kobj, _feature_attr_group);
 out2:
debugfs_remove_recursive(btrfs_debugfs_root_dentry);
 out1:
@@ -913,6 +941,7 @@ int __init btrfs_init_sysfs(void)
 void __cold btrfs_exit_sysfs(void)
 {
sysfs_remove_group(_kset->kobj, _feature_attr_group);
+   sysfs_remove_group(_kset->kobj, _send_attr_group);
kset_unregister(btrfs_kset);
debugfs_remove_recursive(btrfs_debugfs_root_dentry);
 }
-- 
2.17.0

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC PATCH 6/6] btrfs: add chattr support for send/receive

2018-05-08 Thread Howard McLauchlan
From: Howard McLauchlan 

Presently btrfs send/receive does not propagate inode attribute flags;
all chattr operations are effectively discarded upon transmission.

This patch adds kernel support for inode attribute flags. Userspace
support can be found under the commit:

btrfs-progs: add chattr support for send/receive

An associated xfstest can be found at:

btrfs: add verify chattr support for send/receive test

These changes are only enabled for send stream version 2

Signed-off-by: Howard McLauchlan 
---
 fs/btrfs/ctree.h |   2 +
 fs/btrfs/ioctl.c |   2 +-
 fs/btrfs/send.c  | 181 ---
 fs/btrfs/send.h  |   4 +-
 4 files changed, 159 insertions(+), 30 deletions(-)

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 2771cc56a622..0a2359144b18 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -1461,6 +1461,8 @@ struct btrfs_map_token {
unsigned long offset;
 };
 
+unsigned int btrfs_flags_to_ioctl(unsigned int flags);
+
 #define BTRFS_BYTES_TO_BLKS(fs_info, bytes) \
((bytes) >> (fs_info)->sb->s_blocksize_bits)
 
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 632e26d6f7ce..36ce1e589f9e 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -106,7 +106,7 @@ static unsigned int btrfs_mask_flags(umode_t mode, unsigned 
int flags)
 /*
  * Export inode flags to the format expected by the FS_IOC_GETFLAGS ioctl.
  */
-static unsigned int btrfs_flags_to_ioctl(unsigned int flags)
+unsigned int btrfs_flags_to_ioctl(unsigned int flags)
 {
unsigned int iflags = 0;
 
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index c8ea1ccaa3d8..fa7db1474a7f 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -108,6 +108,13 @@ struct send_ctx {
u64 cur_inode_last_extent;
u64 cur_inode_next_write_offset;
 
+   /*
+* state for chattr purposes
+*/
+   u64 cur_inode_flip_flags;
+   u64 cur_inode_receive_flags;
+   int receive_flags_valid;
+
u64 send_progress;
u64 total_data_size;
 
@@ -815,7 +822,7 @@ static int send_rmdir(struct send_ctx *sctx, struct fs_path 
*path)
  */
 static int __get_inode_info(struct btrfs_root *root, struct btrfs_path *path,
  u64 ino, u64 *size, u64 *gen, u64 *mode, u64 *uid,
- u64 *gid, u64 *rdev)
+ u64 *gid, u64 *rdev, u64 *flags)
 {
int ret;
struct btrfs_inode_item *ii;
@@ -845,6 +852,8 @@ static int __get_inode_info(struct btrfs_root *root, struct 
btrfs_path *path,
*gid = btrfs_inode_gid(path->nodes[0], ii);
if (rdev)
*rdev = btrfs_inode_rdev(path->nodes[0], ii);
+   if (flags)
+   *flags = btrfs_inode_flags(path->nodes[0], ii);
 
return ret;
 }
@@ -852,7 +861,7 @@ static int __get_inode_info(struct btrfs_root *root, struct 
btrfs_path *path,
 static int get_inode_info(struct btrfs_root *root,
  u64 ino, u64 *size, u64 *gen,
  u64 *mode, u64 *uid, u64 *gid,
- u64 *rdev)
+ u64 *rdev, u64 *flags)
 {
struct btrfs_path *path;
int ret;
@@ -861,7 +870,7 @@ static int get_inode_info(struct btrfs_root *root,
if (!path)
return -ENOMEM;
ret = __get_inode_info(root, path, ino, size, gen, mode, uid, gid,
-  rdev);
+  rdev, flags);
btrfs_free_path(path);
return ret;
 }
@@ -1250,7 +1259,7 @@ static int __iterate_backrefs(u64 ino, u64 offset, u64 
root, void *ctx_)
 * accept clones from these extents.
 */
ret = __get_inode_info(found->root, bctx->path, ino, _size, NULL, 
NULL,
-  NULL, NULL, NULL);
+  NULL, NULL, NULL, NULL);
btrfs_release_path(bctx->path);
if (ret < 0)
return ret;
@@ -1610,7 +1619,7 @@ static int get_cur_inode_state(struct send_ctx *sctx, u64 
ino, u64 gen)
u64 right_gen;
 
ret = get_inode_info(sctx->send_root, ino, NULL, _gen, NULL, NULL,
-   NULL, NULL);
+   NULL, NULL, NULL);
if (ret < 0 && ret != -ENOENT)
goto out;
left_ret = ret;
@@ -1619,7 +1628,7 @@ static int get_cur_inode_state(struct send_ctx *sctx, u64 
ino, u64 gen)
right_ret = -ENOENT;
} else {
ret = get_inode_info(sctx->parent_root, ino, NULL, _gen,
-   NULL, NULL, NULL, NULL);
+   NULL, NULL, NULL, NULL, NULL);
if (ret < 0 && ret != -ENOENT)
goto out;
right_ret = ret;
@@ -1788,7 +1797,7 @@ static int get_first_ref(struct btrfs_root *root, u64 ino,
 
if (dir_gen) {
ret = 

[RFC PATCH 0/6] btrfs send stream version 2

2018-05-08 Thread Howard McLauchlan
In trying to implement support for inode flags in send/receive, the need for
proper versioning/compatibility came up. I found some of Filipe's old patches
[1] for send stream v2 and rebased them on 4.17-rc4. My chattr changes are
landed on top and also gated behind send stream v2. Similar was done for
btrfs-progs (v4.16.1) [2] and a relevant xfstest (master) [3].

Unfortunately, since Filipe's changes are about 4 years old, rebasing required
quite a few "I guess this is how it works" guesses. A critical eye would be
greatly appreciated.

As of 4.17-rc4, commit a6aa10c70bf7 ("Btrfs: send, fix missing truncate for
inode with prealloc extent past eof") is causing some strange behaviour with the
rebased changes (this can be best seen in the xfstest output for btrfs/160).
Specifically, the hole/data structure is consistent between sender/receiver, but
the receiver is missing some information in fiemap for prealloc extents past
eof. Filipe mentioned that his fix was considering the lack of fallocate command
in send, so that's something we can look at if this patch set gets anywhere.

A few things I was unsure about:

- I couldn't use open_inode_for_write() in process_chattr() in btrfs-progs.
  Ended up having to open() with O_RDONLY. This is probably because I was
  setting immutable on the inode for my test cases.
- Filipe's original patches had BTRFS_SEND_{A/C}_INODE_FLAGS as placeholders,
  but I'd already implemented everything as BTRFS_SEND_{A/C}_CHATTR, since
  send_chown(), send_chmod(), etc. seemed to set a precedent in naming. If this
  needs to be changed let me know:

As of v4.17-rc4, these changes pass all "send" group xfstests.

Cheers, Howard

1: https://www.spinics.net/lists/linux-btrfs/msg35169.html
2: https://patchwork.kernel.org/patch/4021491/
3: https://patchwork.kernel.org/patch/4004861/

Filipe David Borba Manana (5):
  btrfs: send, bump stream version
  btrfs: send, implement total data size command to allow for progress
estimation
  btrfs: send, use fallocate command to punch holes
  btrfs: send, use fallocate command to allocate extents
  btrfs: add send_stream_version attribute to sysfs

Howard McLauchlan (1):
  btrfs: add chattr support for send/receive

 fs/btrfs/ctree.h   |   2 +
 fs/btrfs/ioctl.c   |   2 +-
 fs/btrfs/send.c| 496 +++--
 fs/btrfs/send.h|  26 +-
 fs/btrfs/sysfs.c   |  29 +++
 include/uapi/linux/btrfs.h |  21 +-
 6 files changed, 495 insertions(+), 81 deletions(-)

-- 
2.17.0

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC PATCH 4/6] btrfs: send, use fallocate command to allocate extents

2018-05-08 Thread Howard McLauchlan
From: Filipe David Borba Manana 

The send stream version 2 adds the fallocate command, which can be used to
allocate extents for a file or punch holes in a file. Previously we were
ignoring file prealloc extents or treating them as extents filled with 0
bytes and sending a regular write command to the stream.

After this change, together with my previous change titled:

"Btrfs: send, use fallocate command to punch holes"

an incremental send preserves the hole and data structure of files, which can
be seen via calls to lseek with the whence parameter set to SEEK_DATA or 
SEEK_HOLE,
as the example below shows:

mkfs.btrfs -f /dev/sdc
mount /dev/sdc /mnt
xfs_io -f -c "pwrite -S 0x01 -b 30 0 30" /mnt/foo
btrfs subvolume snapshot -r /mnt /mnt/mysnap1

xfs_io -c "fpunch 10 5" /mnt/foo
xfs_io -c "falloc 10 5" /mnt/foo
xfs_io -c "pwrite -S 0xff -b 1000 12 1000" /mnt/foo
xfs_io -c "fpunch 25 2" /mnt/foo

# prealloc extents that start beyond the inode's size
xfs_io -c "falloc -k 30 100" /mnt/foo
xfs_io -c "falloc -k 900 200" /mnt/foo

btrfs subvolume snapshot -r /mnt /mnt/mysnap2

btrfs send /mnt/mysnap1 -f /tmp/1.snap
btrfs send -p /mnt/mysnap1 /mnt/mysnap2 -f /tmp/2.snap

mkfs.btrfs -f /dev/sdd
mount /dev/sdd /mnt2
btrfs receive /mnt2 -f /tmp/1.snap
btrfs receive /mnt2 -f /tmp/2.snap

Before this change the hole/data structure differed between both filesystems:

$ xfs_io -r -c 'seek -r -a 0' /mnt/mysnap2/foo
Whence  Result
DATA0
HOLE102400
DATA118784
HOLE122880
DATA147456
HOLE253952
DATA266240
HOLE30

$ xfs_io -r -c 'seek -r -a 0' /mnt2/mysnap2/foo
Whence  Result
DATA0
HOLE30

After this change the second filesystem (/dev/sdd) ends up with the same 
hole/data
structure as the first filesystem.

Also, after this change, prealloc extents that lie beyond the inode's size (were
allocated with fallocate + keep size flag) are also replicated by an incremental
send. For the above test, it can be observed via fiemap (or btrfs-debug-tree):

$ xfs_io -r -c 'fiemap -l' /mnt2/mysnap2/foo
0: [0..191]: 25096..25287 192 blocks
1: [192..199]: 24672..24679 8 blocks
2: [200..231]: 24584..24615 32 blocks
3: [232..239]: 24680..24687 8 blocks
4: [240..287]: 24616..24663 48 blocks
5: [288..295]: 24688..24695 8 blocks
6: [296..487]: 25392..25583 192 blocks
7: [488..495]: 24696..24703 8 blocks
8: [496..519]: hole 24 blocks
9: [520..527]: 24704..24711 8 blocks
10: [528..583]: 25624..25679 56 blocks
11: [584..591]: 24712..24719 8 blocks
12: [592..2543]: 26192..28143 1952 blocks
13: [2544..17575]: hole 15032 blocks
14: [17576..21487]: 28144..32055 3912 blocks

The proposed xfstest can be found at:

xfstests: btrfs, test send's ability to punch holes and prealloc extents

This test verifies that send-stream version 2 does space pre-allocation
and hole punching.

[Howard: rebased on 4.17-rc4]
Signed-off-by: Howard McLauchlan 
Signed-off-by: Filipe David Borba Manana 
---
 fs/btrfs/send.c | 71 -
 1 file changed, 53 insertions(+), 18 deletions(-)

diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index 328c7a2857ae..c8ea1ccaa3d8 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -98,9 +98,10 @@ struct send_ctx {
 */
u64 cur_ino;
u64 cur_inode_gen;
-   int cur_inode_new;
-   int cur_inode_new_gen;
-   int cur_inode_deleted;
+   u8 cur_inode_new:1;
+   u8 cur_inode_new_gen:1;
+   u8 cur_inode_skip_truncate:1;
+   u8 cur_inode_deleted:1;
u64 cur_inode_size;
u64 cur_inode_mode;
u64 cur_inode_rdev;
@@ -5313,6 +5314,19 @@ static int clone_range(struct send_ctx *sctx,
return ret;
 }
 
+static int truncate_before_falloc(struct send_ctx *sctx)
+{
+   int ret = 0;
+
+   if (!sctx->cur_inode_skip_truncate) {
+   ret = send_truncate(sctx, sctx->cur_ino,
+   sctx->cur_inode_gen,
+   sctx->cur_inode_size);
+   sctx->cur_inode_skip_truncate = 1;
+   }
+   return ret;
+}
+
 static int send_write_or_clone(struct send_ctx *sctx,
   struct btrfs_path *path,
   struct btrfs_key *key,
@@ -5354,8 +5368,7 @@ static int send_write_or_clone(struct send_ctx *sctx,
}
 
if (sctx->phase == SEND_PHASE_COMPUTE_DATA_SIZE) {
-   if (offset < sctx->cur_inode_size)
-   sctx->total_data_size += len;
+   sctx->total_data_size += len;
goto out;
}
 
@@ -5373,6 +5386,21 @@ static int 

[RFC PATCH 1/6] btrfs: send, bump stream version

2018-05-08 Thread Howard McLauchlan
From: Filipe David Borba Manana 

This increases the send stream version from version 1 to version 2, adding
new commands:

1) total data size - used to tell the receiver how much file data the stream
   will add or update;

2) fallocate - used to pre-allocate space for files and to punch holes in files;

3) inode set flags;

4) set inode otime.

This is preparation work for subsequent changes that implement the new features.

A version 2 stream is only produced if the send ioctl caller passes in one of 
the
new flags (BTRFS_SEND_FLAG_CALCULATE_DATA_SIZE | BTRFS_SEND_FLAG_STREAM_V2), 
meaning
old clients are unaffected.

[Howard: rebased on 4.17-rc4]
Signed-off-by: Howard McLauchlan 
Signed-off-by: Filipe David Borba Manana 
---
 fs/btrfs/send.c|  7 ++-
 fs/btrfs/send.h| 21 -
 include/uapi/linux/btrfs.h | 21 -
 3 files changed, 46 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index c0074d2d7d6d..eccd69387065 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -649,7 +649,10 @@ static int send_header(struct send_ctx *sctx)
struct btrfs_stream_header hdr;
 
strcpy(hdr.magic, BTRFS_SEND_STREAM_MAGIC);
-   hdr.version = cpu_to_le32(BTRFS_SEND_STREAM_VERSION);
+   if (sctx->flags & BTRFS_SEND_FLAG_STREAM_V2)
+   hdr.version = cpu_to_le32(BTRFS_SEND_STREAM_VERSION_2);
+   else
+   hdr.version = cpu_to_le32(BTRFS_SEND_STREAM_VERSION_1);
 
return write_buf(sctx->send_filp, , sizeof(hdr),
>send_off);
@@ -6535,6 +6538,8 @@ long btrfs_ioctl_send(struct file *mnt_file, struct 
btrfs_ioctl_send_args *arg)
INIT_LIST_HEAD(>name_cache_list);
 
sctx->flags = arg->flags;
+   if (sctx->flags & BTRFS_SEND_FLAG_CALCULATE_DATA_SIZE)
+   sctx->flags |= BTRFS_SEND_FLAG_STREAM_V2;
 
sctx->send_filp = fget(arg->send_fd);
if (!sctx->send_filp) {
diff --git a/fs/btrfs/send.h b/fs/btrfs/send.h
index ead397f7034f..a9b5489d690e 100644
--- a/fs/btrfs/send.h
+++ b/fs/btrfs/send.h
@@ -10,7 +10,8 @@
 #include "ctree.h"
 
 #define BTRFS_SEND_STREAM_MAGIC "btrfs-stream"
-#define BTRFS_SEND_STREAM_VERSION 1
+#define BTRFS_SEND_STREAM_VERSION_1 1
+#define BTRFS_SEND_STREAM_VERSION_2 2
 
 #define BTRFS_SEND_BUF_SIZE SZ_64K
 #define BTRFS_SEND_READ_SIZE (48 * SZ_1K)
@@ -77,6 +78,15 @@ enum btrfs_send_cmd {
 
BTRFS_SEND_C_END,
BTRFS_SEND_C_UPDATE_EXTENT,
+
+   /*
+* The following commands were added in stream version 2.
+*/
+   BTRFS_SEND_C_TOTAL_DATA_SIZE,
+   BTRFS_SEND_C_FALLOCATE,
+   BTRFS_SEND_C_INODE_SET_FLAGS,
+   BTRFS_SEND_C_UTIMES2, /* Same as UTIMES, but it includes OTIME too. */
+
__BTRFS_SEND_C_MAX,
 };
 #define BTRFS_SEND_C_MAX (__BTRFS_SEND_C_MAX - 1)
@@ -115,10 +125,19 @@ enum {
BTRFS_SEND_A_CLONE_OFFSET,
BTRFS_SEND_A_CLONE_LEN,
 
+   /*
+* The following attributes were added in stream version 2.
+*/
+   BTRFS_SEND_A_FALLOCATE_FLAGS,
+   BTRFS_SEND_A_INODE_FLAGS,
+
__BTRFS_SEND_A_MAX,
 };
 #define BTRFS_SEND_A_MAX (__BTRFS_SEND_A_MAX - 1)
 
+#define BTRFS_SEND_A_FALLOCATE_FLAG_KEEP_SIZE   (1 << 0)
+#define BTRFS_SEND_A_FALLOCATE_FLAG_PUNCH_HOLE  (1 << 1)
+
 #ifdef __KERNEL__
 long btrfs_ioctl_send(struct file *mnt_file, struct btrfs_ioctl_send_args 
*arg);
 #endif
diff --git a/include/uapi/linux/btrfs.h b/include/uapi/linux/btrfs.h
index c8d99b9ca550..ed63176660d2 100644
--- a/include/uapi/linux/btrfs.h
+++ b/include/uapi/linux/btrfs.h
@@ -711,10 +711,29 @@ struct btrfs_ioctl_received_subvol_args {
  */
 #define BTRFS_SEND_FLAG_OMIT_END_CMD   0x4
 
+/*
+ * Calculate the amount (in bytes) of new file data between the send and
+ * parent snapshots, or in case of a full send, the total amount of file data
+ * we will send.
+ * This corresponds to the sum of the data lengths of each write, clone and
+ * fallocate commands that are sent through the send stream. The receiving end
+ * can use this information to compute progress.
+ *
+ * Added in send stream version 2, and implies producing a version 2 stream.
+ */
+#define BTRFS_SEND_FLAG_CALCULATE_DATA_SIZE0x8
+
+/*
+ * Used by a client to request a version 2 of the send stream.
+ */
+#define BTRFS_SEND_FLAG_STREAM_V2  0x10
+
 #define BTRFS_SEND_FLAG_MASK \
(BTRFS_SEND_FLAG_NO_FILE_DATA | \
 BTRFS_SEND_FLAG_OMIT_STREAM_HEADER | \
-BTRFS_SEND_FLAG_OMIT_END_CMD)
+BTRFS_SEND_FLAG_OMIT_END_CMD | \
+BTRFS_SEND_FLAG_CALCULATE_DATA_SIZE | \
+BTRFS_SEND_FLAG_STREAM_V2)
 
 struct btrfs_ioctl_send_args {
__s64 send_fd;  /* in */
-- 
2.17.0

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info 

Re: [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root

2018-05-08 Thread Jeff Mahoney
On 5/8/18 7:38 PM, Dave Chinner wrote:
> On Tue, May 08, 2018 at 11:03:20AM -0700, Mark Fasheh wrote:
>> Hi,
>>
>> The VFS's super_block covers a variety of filesystem functionality. In
>> particular we have a single structure representing both I/O and
>> namespace domains.
>>
>> There are requirements to de-couple this functionality. For example,
>> filesystems with more than one root (such as btrfs subvolumes) can
>> have multiple inode namespaces. This starts to confuse userspace when
>> it notices multiple inodes with the same inode/device tuple on a
>> filesystem.
> 
> Devil's Advocate - I'm not looking at the code, I'm commenting on
> architectural issues I see here.
> 
> The XFS subvolume work I've been doing explicitly uses a superblock
> per subvolume. That's because subvolumes are designed to be
> completely independent of the backing storage - they know nothing
> about the underlying storage except to share a BDI for writeback
> purposes and write to whatever block device the remapping layer
> gives them at IO time.  Hence XFS subvolumes have (at this point)
> their own unique s_dev, on-disk format configuration, journal, space
> accounting, etc. i.e. They are fully independent filesystems in
> their own right, and as such we do not have multiple inode
> namespaces per superblock.

That's a fundamental difference between how your XFS subvolumes work and
how btrfs subvolumes do.  There is no independence among btrfs
subvolumes.  When a snapshot is created, it has a few new blocks but
otherwise shares the metadata of the source subvolume.  The metadata
trees are shared across all of the subvolumes and there are several
internal trees used to manage all of it.  It's a single storage pool and
a single transaction engine.  There are housekeeping and maintenance
tasks that operate across the entire file system internally.  I
understand that there are several problems you need to solve at the VFS
layer to get your version of subvolumes up and running, but trying to
shoehorn one into the other is bound to fail.

> So this doesn't sound like a "subvolume problem" - it's a "how do we
> sanely support multiple independent namespaces per superblock"
> problem. AFAICT, this same problem exists with bind mounts and mount
> namespaces - they are effectively multiple roots on a single
> superblock, but it's done at the vfsmount level and so the
> superblock knows nothing about them.

In this case, you're talking about the user-visible file system
hierarchy namespace that has no bearing on the underlying file system
outside of per-mount flags.  It makes sense for that to be above the
superblock because the file system doesn't care about them.  We're
interested in the inode namespace, which for every other file system can
be described using an inode and a superblock pair, but btrfs has another
layer in the middle: inode -> btrfs_root -> superblock.  The lifetime
rules for e.g. the s_dev follow that middle layer and a vfsmount can
disappear well before the inode does.

> So this kinda feel like there's still a impedence mismatch between
> btrfs subvolumes being mounted as subtrees on the underlying root
> vfsmount rather than being created as truly independent vfs
> namespaces that share a superblock. To put that as a question: why
> aren't btrfs subvolumes vfsmounts in their own right, and the unique
> information subvolume information get stored in (or obtained from)
> the vfsmount?

Those are two separate problems.   Using a vfsmount to export the
btrfs_root is on my roadmap.  I have a WIP patch set that automounts the
subvolumes when stepping into a new one, but it's to fix a longstanding
UX wart.  Ultimately, vfsmounts are at the wrong level to solve the
inode namespace problem.  Again, there's the lifetime issue.  There are
also many places where we only have an inode and need the s_dev
associated with it.  Most of these sites are well removed from having
access to a vfsmount and pinning one and passing it around carries no
other benefit.

>> In addition, it's currently impossible for a filesystem subvolume to
>> have a different security context from it's parent. If we could allow
>> for subvolumes to optionally specify their own security context, we
>> could use them as containers directly instead of having to go through
>> an overlay.
> 
> Again, XFS subvolumes don't have this problem. So really we need to
> frame this discussion in terms of supporting multiple namespaces
> within a superblock sanely, not subvolumes.
> 
>> I ran into this particular problem with respect to Btrfs some years
>> ago and sent out a very naive set of patches which were (rightfully)
>> not incorporated:
>>
>> https://marc.info/?l=linux-btrfs=130074451403261=2
>> https://marc.info/?l=linux-btrfs=130532890824992=2
>>
>> During the discussion, one question did come up - why can't
>> filesystems like Btrfs use a superblock per subvolume? There's a
>> couple of problems with that:
>>
>> - It's common for a single Btrfs filesystem 

Re: [PATCH] btrfs: incremental send, fix BUG when parent commit_root changed

2018-05-08 Thread robbieko

Filipe Manana 於 2018-05-08 19:12 寫到:
On Tue, May 8, 2018 at 11:30 AM, robbieko  
wrote:

Hi Filipe Manana,

Although the snapshot is readonly, when the snapshot is created,
in order to modify the last_snapshot, it will cause generation 
changes,

and it will affect the commit_root modification.


So what you to say is that the problem happens when creating a
snapshot of snapshot that is being used by send.
You don't mention that anywhere, except in the example below.

Just say that in the changelog, that the problem can happen if while
we are doing a send one of the snapshots used (parent or send) is
snapshotted, because snapshoting implies COWing the root of the source
subvolume/snaphot.
That is not mentioned anywhere in the changelog.


OK, I will add this information to changelog.




Now, why does this happen without your patch?
Before we use the commit roots, we call extent_buffer_get() on them to
make sure they are not released and we do that while holding the
semaphore commit_root_sem. Why isn't this enough to prevent
use-after-free problems?



Although we use extent_buffer_get to prevent the extent_buffer
from being released, because of the snapshoting implies COWing
the root, the commit_root original space (A) is released.
Therefore, when other process need alloc the new tree block,
it may use the space of A.
However, alloc_extent_buffer is created by the bytenr.
It will first find out if there is an existing extent_buffer through
find_extent_buffer and cause the original extent_buffer to be modified.
Eventually causing send process to access illegal memory.
Thus extent_buffer_get can only prevent extent_buffer from being 
released,

but it cannot prevent extent_buffer from being used by others.

btrfs_alloc_tree_block
--btrfs_reserve_extent (get A bytenr)
--btrfs_init_new_buffer (use A bytenr)
btrfs_find_create_tree_block
--alloc_extent_buffer
find_extent_buffer (get A)

So we fixed the problem by copy commit_root to avoid accessing illegal 
memory




That should be explained as well in the changelog.

Those are the 2 pieces of information you need to put in the changelog.



Example:
#btrfs sub show snap1
Name:   snap1
UUID:   17ba3140-b79d-1649-a2e1-b238c3253a40
Parent UUID:6fe90a14-02f3-1b40-bdfc-be435060d023
Received UUID:  17ba3140-b79d-1649-a2e1-b238c3253a40
Creation time:  2018-04-27 18:04:11 +0800
Subvolume ID:   514
Generation: 4854
Gen at creation:506
Parent ID:  511
Top level ID:   511
Flags:  readonly
Snapshot(s):

#btrfs-debug-tree -t 514 /dev/md2 | more
btrfs-progs v4.0
file tree key (514 ROOT_ITEM 506)
node 259127066624 level 2 items 192 free 301 generation 4854 owner 514
fs uuid 081b4c28-007c-430b-be7f-ead57aa71548
chunk uuid a48e7346-bd15-4eac-8957-b11a2bf9bbe2
key (256 INODE_ITEM 0) block 258707652608 (15790262) gen 505

#btrfs sub snap send_snap1 test_subvol
#btrfs-debug-tree -t 514 /dev/md2 | more
btrfs-progs v4.0
file tree key (514 ROOT_ITEM 506)
node 258444509184 level 2 items 192 free 301 generation 4881 owner 514
fs uuid 081b4c28-007c-430b-be7f-ead57aa71548
chunk uuid a48e7346-bd15-4eac-8957-b11a2bf9bbe2
key (256 INODE_ITEM 0) block 258707652608 (15790262) gen 505

According to the above example node and generation will be updated.

This means that as long as the send or parent snapshot is taken during
the btrfs send, commit_root will change, and send process may access
invalid memory.

Thanks.
Robbie Ko


Filipe Manana 於 2018-05-08 17:15 寫到:


On Tue, May 8, 2018 at 9:15 AM, robbieko  
wrote:



From: Robbie Ko 

[BUG]
btrfs send BUG on parent commit_root node receive destination
is at the same volume.



I can't make sense of that sentence.



[Example]
btrfs send -e -p /mnt/snap1/ /mnt/snap2/ | btrfs receive -e 
/mnt/temp



So, is -e necessary?
So doing that, for any parent and send snapshots, triggers the bug?
(and regardless of -e)
If that was enough I'm pretty sure almost everyone would be reporting
send/receive as unusable.
Please clarify.



[REASON]
1. When send with the parent, the send process will get the parent
   commit_root(A), then send commit_root(B) and then compare the
   tree between A and B.
2. The receive process will take snapshot from parent, then the 
parent

   commit_root changes from A to C, so A will be released.



I don't understand this. How can the commit_root change?
The snapshot is readonly, it's can't be modified after it's created.


3. Then A will be assigned to other leaf nodes.
4. Therefore, the send process will use invalid A, resulting in
   invalid memory access.

[FIX]
We create new root and copy from parent/send commit_root to
avoid invalid memory access.

CallTrace looks like this:
 [ cut here ]
 kernel BUG at 

Re: [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root

2018-05-08 Thread Dave Chinner
On Tue, May 08, 2018 at 11:03:20AM -0700, Mark Fasheh wrote:
> Hi,
> 
> The VFS's super_block covers a variety of filesystem functionality. In
> particular we have a single structure representing both I/O and
> namespace domains.
> 
> There are requirements to de-couple this functionality. For example,
> filesystems with more than one root (such as btrfs subvolumes) can
> have multiple inode namespaces. This starts to confuse userspace when
> it notices multiple inodes with the same inode/device tuple on a
> filesystem.

Devil's Advocate - I'm not looking at the code, I'm commenting on
architectural issues I see here.

The XFS subvolume work I've been doing explicitly uses a superblock
per subvolume. That's because subvolumes are designed to be
completely independent of the backing storage - they know nothing
about the underlying storage except to share a BDI for writeback
purposes and write to whatever block device the remapping layer
gives them at IO time.  Hence XFS subvolumes have (at this point)
their own unique s_dev, on-disk format configuration, journal, space
accounting, etc. i.e. They are fully independent filesystems in
their own right, and as such we do not have multiple inode
namespaces per superblock.

So this doesn't sound like a "subvolume problem" - it's a "how do we
sanely support multiple independent namespaces per superblock"
problem. AFAICT, this same problem exists with bind mounts and mount
namespaces - they are effectively multiple roots on a single
superblock, but it's done at the vfsmount level and so the
superblock knows nothing about them.

So this kinda feel like there's still a impedence mismatch between
btrfs subvolumes being mounted as subtrees on the underlying root
vfsmount rather than being created as truly independent vfs
namespaces that share a superblock. To put that as a question: why
aren't btrfs subvolumes vfsmounts in their own right, and the unique
information subvolume information get stored in (or obtained from)
the vfsmount?

> In addition, it's currently impossible for a filesystem subvolume to
> have a different security context from it's parent. If we could allow
> for subvolumes to optionally specify their own security context, we
> could use them as containers directly instead of having to go through
> an overlay.

Again, XFS subvolumes don't have this problem. So really we need to
frame this discussion in terms of supporting multiple namespaces
within a superblock sanely, not subvolumes.

> I ran into this particular problem with respect to Btrfs some years
> ago and sent out a very naive set of patches which were (rightfully)
> not incorporated:
> 
> https://marc.info/?l=linux-btrfs=130074451403261=2
> https://marc.info/?l=linux-btrfs=130532890824992=2
> 
> During the discussion, one question did come up - why can't
> filesystems like Btrfs use a superblock per subvolume? There's a
> couple of problems with that:
> 
> - It's common for a single Btrfs filesystem to have thousands of
>   subvolumes. So keeping a superblock for each subvol in memory would
>   get prohibively expensive - imagine having 8000 copies of struct
>   super_block for a file system just because we wanted some separation
>   of say, s_dev.

That's no different to using individual overlay mounts for the
thousands of containers that are on the system. This doesn't seem to
be a major problem...

> - Writeback would also have to walk all of these superblocks -
>   again not very good for system performance.

Background writeback is backing device focussed, not superblock
focussed. It will only iterate the superblocks that have dirty
inodes on the bdi writeback lists, not all the superblocks on the
bdi. IOWs, this isn't a major problem except for sync() operations
that iterate superblocks.

> - Anyone wanting to lock down I/O on a filesystem would have to
> freeze all the superblocks. This goes for most things related to
> I/O really - we simply can't afford to have the kernel walking
> thousands of superblocks to sync a single fs.

Not with XFS subvolumes. Freezing the underlying parent filesystem
will effectively stop all IO from the mounted subvolumes by freezing
remapping calls before IO. Sure, those subvolumes aren't in a
consistent state, but we don't freeze userspace so none of the
application data is ever in a consistent state when filesystems are
frozen.

So, again, I'm not sure there's /subvolume/ problem here. There's
definitely a "freeze heirarchy" problem, but that already exists and
it's something we talked about at LSFMM because we need to solve it
for reliable hibernation.

> It's far more efficient then to pull those fields we need for a
> subvolume namespace into their own structure.

I'm not convinced yet - it still feels like it's the wrong layer to
be solving the multiple namespace per superblock problem

Cheers,

Dave.
-- 
Dave Chinner
da...@fromorbit.com
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to 

Re: send ioctl failed with -2

2018-05-08 Thread Nicolas Porcel
On Tue, May 08, 2018 at 02:16:06PM -0400, Noah Massey wrote:
> Silly question, but is 'mysnapshot' actually accessible at './mysnapshot' ?
> Because the output from btrfs send should immediately output
> 'At subvol mysnapshot'

Inded. This is not even the right command considering I only kept the
error when writing this email. It takes 5-10 minutes to run for 40GB of
data so I did not want to do it again.

> 
> If 'btrfs send' is actually generating output, 'btrfs receive -vv' may
> help "parse" the send stream enough to figure out where it is
> terminating.

I tried it and I did not find anything related to the error. The output
is basically the list of files received and their chmod but nothing
more. Unless I can find which file is causing problem with that.

> 
> ~ Noah
> 
> ps - I was going to suggest 'btrfs send -v'. According the the
> manpage, that would "enable verbose output, print generated commands
> in a readable form". But it does not seem to be working for me, and
> after a quick glance at the code I'm not seeing how the ioctl call is
> setting up any kind of verbose feedback. So that may be out-of-date
> documentation.

I also tried it with 5 'v' and nothing happened.

-- 
Nicolas
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 2/2] btrfs: incremental send, improve rmdir performance for large directory

2018-05-08 Thread Filipe Manana
On Tue, May 8, 2018 at 11:11 AM, robbieko  wrote:
> From: Robbie Ko 
>
> Currently when checking if we can delete a directory, we always
> check if all its children have been processed.
>
> Example: A directory with 2,000,000 files was deleted
> Result:
> original : 1994m57.071s
> patch : 1m38.554s
>
> [FIX]
> Instead of checking all children on all calls to can_rmdir(),
> we keep track of the directory index offset of the child last
> checked in the last call to can_rmdir(), and then use it as the
> starting point for future calls to can_rmdir().
>
> Signed-off-by: Robbie Ko 
Reviewed-by: Filipe Manana 

> ---
> V2:
>  fix comments
>  split optimization allocations orphan_dir_info
>
>  fs/btrfs/send.c | 31 ++-
>  1 file changed, 22 insertions(+), 9 deletions(-)
>
> diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
> index 2830871..a477268 100644
> --- a/fs/btrfs/send.c
> +++ b/fs/btrfs/send.c
> @@ -247,6 +247,7 @@ struct orphan_dir_info {
> struct rb_node node;
> u64 ino;
> u64 gen;
> +   u64 last_dir_index_offset;
>  };
>
>  struct name_cache_entry {
> @@ -2872,6 +2873,7 @@ static int orphanize_inode(struct send_ctx *sctx, u64 
> ino, u64 gen,
> return ERR_PTR(-ENOMEM);
> odi->ino = dir_ino;
> odi->gen = 0;
> +   odi->last_dir_index_offset = 0;
>
> rb_link_node(>node, parent, p);
> rb_insert_color(>node, >orphan_dirs);
> @@ -2927,6 +2929,7 @@ static int can_rmdir(struct send_ctx *sctx, u64 dir, 
> u64 dir_gen,
> struct btrfs_key found_key;
> struct btrfs_key loc;
> struct btrfs_dir_item *di;
> +   struct orphan_dir_info *odi = NULL;
>
> /*
>  * Don't try to rmdir the top/root subvolume dir.
> @@ -2941,6 +2944,11 @@ static int can_rmdir(struct send_ctx *sctx, u64 dir, 
> u64 dir_gen,
> key.objectid = dir;
> key.type = BTRFS_DIR_INDEX_KEY;
> key.offset = 0;
> +
> +   odi = get_orphan_dir_info(sctx, dir);
> +   if (odi)
> +   key.offset = odi->last_dir_index_offset;
> +
> ret = btrfs_search_slot(NULL, root, , path, 0, 0);
> if (ret < 0)
> goto out;
> @@ -2968,30 +2976,33 @@ static int can_rmdir(struct send_ctx *sctx, u64 dir, 
> u64 dir_gen,
>
> dm = get_waiting_dir_move(sctx, loc.objectid);
> if (dm) {
> -   struct orphan_dir_info *odi;
> -
> odi = add_orphan_dir_info(sctx, dir);
> if (IS_ERR(odi)) {
> ret = PTR_ERR(odi);
> goto out;
> }
> odi->gen = dir_gen;
> +   odi->last_dir_index_offset = found_key.offset;
> dm->rmdir_ino = dir;
> ret = 0;
> goto out;
> }
>
> if (loc.objectid > send_progress) {
> -   struct orphan_dir_info *odi;
> -
> -   odi = get_orphan_dir_info(sctx, dir);
> -   free_orphan_dir_info(sctx, odi);
> +   odi = add_orphan_dir_info(sctx, dir);
> +   if (IS_ERR(odi)) {
> +   ret = PTR_ERR(odi);
> +   goto out;
> +   }
> +   odi->gen = dir_gen;
> +   odi->last_dir_index_offset = found_key.offset;
> ret = 0;
> goto out;
> }
>
> path->slots[0]++;
> }
> +   free_orphan_dir_info(sctx, odi);
>
> ret = 1;
>
> @@ -3269,13 +3280,16 @@ static int apply_dir_move(struct send_ctx *sctx, 
> struct pending_dir_move *pm)
>
> if (rmdir_ino) {
> struct orphan_dir_info *odi;
> +   u64 gen;
>
> odi = get_orphan_dir_info(sctx, rmdir_ino);
> if (!odi) {
> /* already deleted */
> goto finish;
> }
> -   ret = can_rmdir(sctx, rmdir_ino, odi->gen, sctx->cur_ino);
> +   gen = odi->gen;
> +
> +   ret = can_rmdir(sctx, rmdir_ino, gen, sctx->cur_ino);
> if (ret < 0)
> goto out;
> if (!ret)
> @@ -3286,13 +3300,12 @@ static int apply_dir_move(struct send_ctx *sctx, 
> struct pending_dir_move *pm)
> ret = -ENOMEM;
> goto out;
> }
> -   ret = get_cur_path(sctx, rmdir_ino, odi->gen, name);
> +   ret = get_cur_path(sctx, rmdir_ino, gen, name);
> if (ret < 0)
> goto out;
> ret = send_rmdir(sctx, name);
>  

Re: [PATCH v2 1/2] btrfs: incremental send, optimization add orphan_dir_info

2018-05-08 Thread Filipe Manana
On Tue, May 8, 2018 at 11:11 AM, robbieko  wrote:
> From: Robbie Ko 
>
> moving the allocation to the end in order to avoid unnecessary
> allocations
>
> Signed-off-by: Robbie Ko 
Reviewed-by: Filipe Manana 

> ---
>  fs/btrfs/send.c | 13 ++---
>  1 file changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
> index 484e2af..2830871 100644
> --- a/fs/btrfs/send.c
> +++ b/fs/btrfs/send.c
> @@ -2855,12 +2855,6 @@ static int orphanize_inode(struct send_ctx *sctx, u64 
> ino, u64 gen,
> struct rb_node *parent = NULL;
> struct orphan_dir_info *entry, *odi;
>
> -   odi = kmalloc(sizeof(*odi), GFP_KERNEL);
> -   if (!odi)
> -   return ERR_PTR(-ENOMEM);
> -   odi->ino = dir_ino;
> -   odi->gen = 0;
> -
> while (*p) {
> parent = *p;
> entry = rb_entry(parent, struct orphan_dir_info, node);
> @@ -2869,11 +2863,16 @@ static int orphanize_inode(struct send_ctx *sctx, u64 
> ino, u64 gen,
> } else if (dir_ino > entry->ino) {
> p = &(*p)->rb_right;
> } else {
> -   kfree(odi);
> return entry;
> }
> }
>
> +   odi = kmalloc(sizeof(*odi), GFP_KERNEL);
> +   if (!odi)
> +   return ERR_PTR(-ENOMEM);
> +   odi->ino = dir_ino;
> +   odi->gen = 0;
> +
> rb_link_node(>node, parent, p);
> rb_insert_color(>node, >orphan_dirs);
> return odi;
> --
> 1.9.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Filipe David Manana,

“Whether you think you can, or you think you can't — you're right.”
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root

2018-05-08 Thread Mark Fasheh
Hi,

The VFS's super_block covers a variety of filesystem functionality. In
particular we have a single structure representing both I/O and
namespace domains.

There are requirements to de-couple this functionality. For example,
filesystems with more than one root (such as btrfs subvolumes) can
have multiple inode namespaces. This starts to confuse userspace when
it notices multiple inodes with the same inode/device tuple on a
filesystem.

In addition, it's currently impossible for a filesystem subvolume to
have a different security context from it's parent. If we could allow
for subvolumes to optionally specify their own security context, we
could use them as containers directly instead of having to go through
an overlay.


I ran into this particular problem with respect to Btrfs some years
ago and sent out a very naive set of patches which were (rightfully)
not incorporated:

https://marc.info/?l=linux-btrfs=130074451403261=2
https://marc.info/?l=linux-btrfs=130532890824992=2

During the discussion, one question did come up - why can't
filesystems like Btrfs use a superblock per subvolume? There's a
couple of problems with that:

- It's common for a single Btrfs filesystem to have thousands of
  subvolumes. So keeping a superblock for each subvol in memory would
  get prohibively expensive - imagine having 8000 copies of struct
  super_block for a file system just because we wanted some separation
  of say, s_dev.

- Writeback would also have to walk all of these superblocks -
  again not very good for system performance.

- Anyone wanting to lock down I/O on a filesystem would have to freeze
  all the superblocks. This goes for most things related to I/O really
  - we simply can't afford to have the kernel walking thousands of
  superblocks to sync a single fs.

It's far more efficient then to pull those fields we need for a
subvolume namespace into their own structure.


The following patches attempt to fix this issue by introducing a
structure, fs_view, which can be used to represent a 'view' into a
filesystem. We can migrate super_block fields to this structure one at
a time. Struct super_block gets a default view embedded into
it. Inodes get a new field, i_view, which can be dereferenced to get
the view that an inode belgongs to. By default, we point i_view to the
view on struct super_block. That way existing filesystems don't have
to do anything different.

The patches are careful not to grow the size of struct inode.

For the first patch series, we migrate s_dev over from struct
super_block to struct fs_view. This fixes a long standing bug in how
the kernel reports inode devices to userspace.

The series follows an order:

- We first introduce the fs_view structure and embed it into struct
  super_block. As discussed, struct inode gets a pointer to the
  fs_view, i_view. The only member on fs_view at this point is a
  super_block * so that we can replace i_sb. A helper function is
  provided to get to the super_block from a struct inode.

- Convert the kernel to using our helper function to get to i_sb. This
  is done on in a per-filesystem patch. The other parts of the kernel
  referencing i_sb get their changes batched up in logical groupings.

- Move s_dev from struct super_block to struct fs_view.

- Convert the kernel from inode->i_sb->s_dev to the device from our
  fs_view. In the end, these lines will look like inode_view(inode)->v_dev.

- Add an fs_view struct to each Btrfs root, point inodes to that view
  when we initialize them.


The patches are available via git and are based off Linux
v4.16. There's two branches, with identical code.

- With the inode_sb() changeover patch broken out (as is sent here):

https://github.com/markfasheh/linux fs_view-broken-out

- With the inode_sb() changeover patch in one big change:

https://github.com/markfasheh/linux fs_view


Comments are appreciated.

Thanks,
  --Mark
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 01/76] vfs: Introduce struct fs_view

2018-05-08 Thread Mark Fasheh
We want to de-couple some items from struct super_block, in particular those
that provide a 'fiew' into an fs.

Introduce a small struct, fs_view to contain these fields. This first patch
has a mostly empty fs_view. We do however, link it into the VFS:

Each super_block gets a default fs_view which is filled in via the
usual superblock intialization methods.

struct inode is updated to point to an fs_view structure via a new
'i_view' pointer, which replaces i_sb.

A filesystem can now optionally provide their own fs_view to point i_view
to.

So we don't lose our link from inode to superblock, fs_view gets
an embedded super_block pointer. A helper function, inode_sb() is
introduced to make getting the superblock from an inode less clunky.

Filesystems need no functional changes, and the only additional memory
usage here is the added pointer on struct super_block.

Signed-off-by: Mark Fasheh 
---
 fs/inode.c |  2 +-
 fs/super.c |  1 +
 include/linux/fs.h | 21 -
 3 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/fs/inode.c b/fs/inode.c
index ef362364d396..4f08fdc2c60f 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -133,7 +133,7 @@ int inode_init_always(struct super_block *sb, struct inode 
*inode)
static const struct file_operations no_open_fops = {.open = no_open};
struct address_space *const mapping = >i_data;
 
-   inode->i_sb = sb;
+   inode->i_view = >s_view;
inode->i_blkbits = sb->s_blocksize_bits;
inode->i_flags = 0;
atomic_set(>i_count, 1);
diff --git a/fs/super.c b/fs/super.c
index 672538ca9831..5258a57d410a 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -245,6 +245,7 @@ static struct super_block *alloc_super(struct 
file_system_type *type, int flags,
s->s_op = _op;
s->s_time_gran = 10;
s->cleancache_poolid = CLEANCACHE_NO_POOL;
+   s->s_view.v_sb = s;
 
s->s_shrink.seeks = DEFAULT_SEEKS;
s->s_shrink.scan_objects = super_cache_scan;
diff --git a/include/linux/fs.h b/include/linux/fs.h
index c6baf767619e..4561cb9156d4 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -580,7 +580,7 @@ struct inode {
 #endif
 
const struct inode_operations   *i_op;
-   struct super_block  *i_sb;
+   struct fs_view  *i_view;
struct address_space*i_mapping;
 
 #ifdef CONFIG_SECURITY
@@ -1340,6 +1340,24 @@ struct sb_writers {
struct percpu_rw_semaphore  rw_sem[SB_FREEZE_LEVELS];
 };
 
+/*
+ * "View" into a filesystem. Allows us to abstract out those
+ * superblock fields which change between the roots on a given
+ * filesystem. Most filesystems can ignore this - inodes are pointed
+ * to the default view 's_view' during initialization.
+ *
+ * A file system with multiple roots should allocate a view structure
+ * per root and point each inodes view pointer to it in iget.
+ */
+struct fs_view {
+   struct super_block  *v_sb;
+};
+
+static inline struct super_block *inode_sb(const struct inode *inode)
+{
+   return inode->i_view->v_sb;
+}
+
 struct super_block {
struct list_heads_list; /* Keep this first */
dev_t   s_dev;  /* search index; _not_ kdev_t */
@@ -1358,6 +1376,7 @@ struct super_block {
struct rw_semaphore s_umount;
int s_count;
atomic_ts_active;
+   struct fs_view  s_view; /* default view into the fs */
 #ifdef CONFIG_SECURITY
void*s_security;
 #endif
-- 
2.15.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 04/76] fs: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/aio.c |  6 ++--
 fs/attr.c| 12 +++
 fs/binfmt_misc.c |  6 ++--
 fs/block_dev.c   |  2 +-
 fs/cachefiles/rdwr.c |  4 +--
 fs/dcache.c  |  8 ++---
 fs/direct-io.c   |  8 ++---
 fs/eventpoll.c   |  2 +-
 fs/fs-writeback.c| 30 
 fs/inode.c   | 96 +++-
 fs/ioctl.c   |  8 ++---
 fs/iomap.c   |  7 ++--
 fs/libfs.c   |  2 +-
 fs/locks.c   | 15 
 fs/namei.c   | 14 
 fs/namespace.c   |  6 ++--
 fs/open.c|  6 ++--
 fs/pipe.c|  6 ++--
 fs/posix_acl.c   |  2 +-
 fs/stat.c|  2 +-
 fs/xattr.c   |  2 +-
 21 files changed, 125 insertions(+), 119 deletions(-)

diff --git a/fs/aio.c b/fs/aio.c
index 6bcd3fb5265a..bd2a187ca6d1 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -1115,7 +1115,8 @@ static void aio_complete(struct kiocb *kiocb, long res, 
long res2)
 * thread.
 */
if (S_ISREG(file_inode(file)->i_mode))
-   __sb_writers_acquired(file_inode(file)->i_sb, 
SB_FREEZE_WRITE);
+   __sb_writers_acquired(inode_sb(file_inode(file)),
+ SB_FREEZE_WRITE);
file_end_write(file);
}
 
@@ -1546,7 +1547,8 @@ static ssize_t aio_write(struct kiocb *req, struct iocb 
*iocb, bool vectored,
 * complain about held lock when we return to userspace.
 */
if (S_ISREG(file_inode(file)->i_mode))
-   __sb_writers_release(file_inode(file)->i_sb, 
SB_FREEZE_WRITE);
+   __sb_writers_release(inode_sb(file_inode(file)),
+SB_FREEZE_WRITE);
}
kfree(iovec);
return ret;
diff --git a/fs/attr.c b/fs/attr.c
index 12ffdb6fb63c..456c082fe636 100644
--- a/fs/attr.c
+++ b/fs/attr.c
@@ -119,7 +119,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t 
offset)
limit = rlimit(RLIMIT_FSIZE);
if (limit != RLIM_INFINITY && offset > limit)
goto out_sig;
-   if (offset > inode->i_sb->s_maxbytes)
+   if (offset > inode_sb(inode)->s_maxbytes)
goto out_big;
} else {
/*
@@ -164,13 +164,13 @@ void setattr_copy(struct inode *inode, const struct iattr 
*attr)
inode->i_gid = attr->ia_gid;
if (ia_valid & ATTR_ATIME)
inode->i_atime = timespec_trunc(attr->ia_atime,
-   inode->i_sb->s_time_gran);
+   inode_sb(inode)->s_time_gran);
if (ia_valid & ATTR_MTIME)
inode->i_mtime = timespec_trunc(attr->ia_mtime,
-   inode->i_sb->s_time_gran);
+   inode_sb(inode)->s_time_gran);
if (ia_valid & ATTR_CTIME)
inode->i_ctime = timespec_trunc(attr->ia_ctime,
-   inode->i_sb->s_time_gran);
+   inode_sb(inode)->s_time_gran);
if (ia_valid & ATTR_MODE) {
umode_t mode = attr->ia_mode;
 
@@ -288,10 +288,10 @@ int notify_change(struct dentry * dentry, struct iattr * 
attr, struct inode **de
 * namespace of the superblock.
 */
if (ia_valid & ATTR_UID &&
-   !kuid_has_mapping(inode->i_sb->s_user_ns, attr->ia_uid))
+   !kuid_has_mapping(inode_sb(inode)->s_user_ns, attr->ia_uid))
return -EOVERFLOW;
if (ia_valid & ATTR_GID &&
-   !kgid_has_mapping(inode->i_sb->s_user_ns, attr->ia_gid))
+   !kgid_has_mapping(inode_sb(inode)->s_user_ns, attr->ia_gid))
return -EOVERFLOW;
 
/* Don't allow modifications of files with invalid uids or
diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
index a7c5a9861bef..c5f84bf4506b 100644
--- a/fs/binfmt_misc.c
+++ b/fs/binfmt_misc.c
@@ -657,7 +657,7 @@ static ssize_t bm_entry_write(struct file *file, const char 
__user *buffer,
break;
case 3:
/* Delete this handler. */
-   root = file_inode(file)->i_sb->s_root;
+   root = inode_sb(file_inode(file))->s_root;
inode_lock(d_inode(root));
 
if (!list_empty(>list))
@@ -685,7 +685,7 @@ static ssize_t bm_register_write(struct file *file, const 
char __user *buffer,
 {
Node *e;
struct inode *inode;
-   struct super_block *sb = file_inode(file)->i_sb;
+   struct super_block *sb = inode_sb(file_inode(file));
struct dentry *root = sb->s_root, *dentry;
int err = 0;
 
@@ -786,7 +786,7 @@ static ssize_t bm_status_write(struct 

[PATCH 02/76] arch: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 arch/arc/kernel/troubleshoot.c| 2 +-
 arch/powerpc/platforms/cell/spufs/inode.c | 6 +++---
 arch/s390/hypfs/inode.c   | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/arc/kernel/troubleshoot.c b/arch/arc/kernel/troubleshoot.c
index 6e9a0a9a6a04..18eb4984d555 100644
--- a/arch/arc/kernel/troubleshoot.c
+++ b/arch/arc/kernel/troubleshoot.c
@@ -104,7 +104,7 @@ static void show_faulting_vma(unsigned long address, char 
*buf)
if (file) {
nm = file_path(file, buf, PAGE_SIZE - 1);
inode = file_inode(vma->vm_file);
-   dev = inode->i_sb->s_dev;
+   dev = inode_sb(inode)->s_dev;
ino = inode->i_ino;
}
pr_info("@off 0x%lx in [%s]\n"
diff --git a/arch/powerpc/platforms/cell/spufs/inode.c 
b/arch/powerpc/platforms/cell/spufs/inode.c
index db329d4bf1c3..d04460e86728 100644
--- a/arch/powerpc/platforms/cell/spufs/inode.c
+++ b/arch/powerpc/platforms/cell/spufs/inode.c
@@ -251,7 +251,7 @@ spufs_mkdir(struct inode *dir, struct dentry *dentry, 
unsigned int flags,
struct inode *inode;
struct spu_context *ctx;
 
-   inode = spufs_new_inode(dir->i_sb, mode | S_IFDIR);
+   inode = spufs_new_inode(inode_sb(dir), mode | S_IFDIR);
if (!inode)
return -ENOSPC;
 
@@ -284,7 +284,7 @@ spufs_mkdir(struct inode *dir, struct dentry *dentry, 
unsigned int flags,
else
ret = spufs_fill_dir(dentry, spufs_dir_contents, mode, ctx);
 
-   if (!ret && spufs_get_sb_info(dir->i_sb)->debug)
+   if (!ret && spufs_get_sb_info(inode_sb(dir))->debug)
ret = spufs_fill_dir(dentry, spufs_dir_debug_contents,
mode, ctx);
 
@@ -484,7 +484,7 @@ spufs_mkgang(struct inode *dir, struct dentry *dentry, 
umode_t mode)
struct spu_gang *gang;
 
ret = -ENOSPC;
-   inode = spufs_new_inode(dir->i_sb, mode | S_IFDIR);
+   inode = spufs_new_inode(inode_sb(dir), mode | S_IFDIR);
if (!inode)
goto out;
 
diff --git a/arch/s390/hypfs/inode.c b/arch/s390/hypfs/inode.c
index 43bbe63e2992..6a7679dcd9b7 100644
--- a/arch/s390/hypfs/inode.c
+++ b/arch/s390/hypfs/inode.c
@@ -128,7 +128,7 @@ static int hypfs_open(struct inode *inode, struct file 
*filp)
return -EACCES;
}
 
-   fs_info = inode->i_sb->s_fs_info;
+   fs_info = inode_sb(inode)->s_fs_info;
if(data) {
mutex_lock(_info->lock);
filp->private_data = kstrdup(data, GFP_KERNEL);
@@ -164,7 +164,7 @@ static ssize_t hypfs_read_iter(struct kiocb *iocb, struct 
iov_iter *to)
 static ssize_t hypfs_write_iter(struct kiocb *iocb, struct iov_iter *from)
 {
int rc;
-   struct super_block *sb = file_inode(iocb->ki_filp)->i_sb;
+   struct super_block *sb = inode_sb(file_inode(iocb->ki_filp));
struct hypfs_sb_info *fs_info = sb->s_fs_info;
size_t count = iov_iter_count(from);
 
-- 
2.15.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 05/76] include: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 include/linux/backing-dev.h  |   4 +-
 include/linux/cleancache.h   |   2 +-
 include/linux/fs.h   |  29 +-
 include/linux/fscrypt_supp.h |   4 +-
 include/linux/hugetlb.h  |   2 +-
 include/linux/nfs_fs.h   |   2 +-
 include/trace/events/btrfs.h |  10 ++--
 include/trace/events/ext4.h  | 118 +++
 include/trace/events/f2fs.h  |  52 -
 include/trace/events/filelock.h  |   8 +--
 include/trace/events/filemap.h   |  12 ++--
 include/trace/events/fs_dax.h|  14 ++---
 include/trace/events/jbd2.h  |   2 +-
 include/trace/events/writeback.h |   2 +-
 include/uapi/linux/iso_fs.h  |   4 +-
 15 files changed, 134 insertions(+), 131 deletions(-)

diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h
index 3e4ce54d84ab..0fb241c9324a 100644
--- a/include/linux/backing-dev.h
+++ b/include/linux/backing-dev.h
@@ -157,7 +157,7 @@ static inline struct backing_dev_info *inode_to_bdi(struct 
inode *inode)
if (!inode)
return _backing_dev_info;
 
-   sb = inode->i_sb;
+   sb = inode_sb(inode);
 #ifdef CONFIG_BLOCK
if (sb_is_blkdev_sb(sb))
return I_BDEV(inode)->bd_bdi;
@@ -251,7 +251,7 @@ static inline bool inode_cgwb_enabled(struct inode *inode)
cgroup_subsys_on_dfl(io_cgrp_subsys) &&
bdi_cap_account_dirty(bdi) &&
(bdi->capabilities & BDI_CAP_CGROUP_WRITEBACK) &&
-   (inode->i_sb->s_iflags & SB_I_CGROUPWB);
+   (inode_sb(inode)->s_iflags & SB_I_CGROUPWB);
 }
 
 /**
diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
index 5f5730c1d324..74f89782f70e 100644
--- a/include/linux/cleancache.h
+++ b/include/linux/cleancache.h
@@ -51,7 +51,7 @@ extern void __cleancache_invalidate_fs(struct super_block *);
 #define cleancache_enabled (1)
 static inline bool cleancache_fs_enabled_mapping(struct address_space *mapping)
 {
-   return mapping->host->i_sb->cleancache_poolid >= 0;
+   return inode_sb(mapping->host)->cleancache_poolid >= 0;
 }
 static inline bool cleancache_fs_enabled(struct page *page)
 {
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 4561cb9156d4..5d4bb19b2a43 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1475,22 +1475,22 @@ struct super_block {
  */
 static inline uid_t i_uid_read(const struct inode *inode)
 {
-   return from_kuid(inode->i_sb->s_user_ns, inode->i_uid);
+   return from_kuid(inode_sb(inode)->s_user_ns, inode->i_uid);
 }
 
 static inline gid_t i_gid_read(const struct inode *inode)
 {
-   return from_kgid(inode->i_sb->s_user_ns, inode->i_gid);
+   return from_kgid(inode_sb(inode)->s_user_ns, inode->i_gid);
 }
 
 static inline void i_uid_write(struct inode *inode, uid_t uid)
 {
-   inode->i_uid = make_kuid(inode->i_sb->s_user_ns, uid);
+   inode->i_uid = make_kuid(inode_sb(inode)->s_user_ns, uid);
 }
 
 static inline void i_gid_write(struct inode *inode, gid_t gid)
 {
-   inode->i_gid = make_kgid(inode->i_sb->s_user_ns, gid);
+   inode->i_gid = make_kgid(inode_sb(inode)->s_user_ns, gid);
 }
 
 extern struct timespec current_time(struct inode *inode);
@@ -1899,10 +1899,10 @@ struct super_operations {
  * i_flags updated.  Hence, i_flags no longer inherit the superblock mount
  * flags, so these have to be checked separately. -- r...@arm.uk.linux.org
  */
-#define __IS_FLG(inode, flg)   ((inode)->i_sb->s_flags & (flg))
+#define __IS_FLG(inode, flg)   (inode_sb((inode))->s_flags & (flg))
 
 static inline bool sb_rdonly(const struct super_block *sb) { return 
sb->s_flags & SB_RDONLY; }
-#define IS_RDONLY(inode)   sb_rdonly((inode)->i_sb)
+#define IS_RDONLY(inode)   sb_rdonly(inode_sb((inode)))
 #define IS_SYNC(inode) (__IS_FLG(inode, SB_SYNCHRONOUS) || \
((inode)->i_flags & S_SYNC))
 #define IS_DIRSYNC(inode)  (__IS_FLG(inode, SB_SYNCHRONOUS|SB_DIRSYNC) || \
@@ -2725,21 +2725,22 @@ static inline void file_start_write(struct file *file)
 {
if (!S_ISREG(file_inode(file)->i_mode))
return;
-   __sb_start_write(file_inode(file)->i_sb, SB_FREEZE_WRITE, true);
+   __sb_start_write(inode_sb(file_inode(file)), SB_FREEZE_WRITE, true);
 }
 
 static inline bool file_start_write_trylock(struct file *file)
 {
if (!S_ISREG(file_inode(file)->i_mode))
return true;
-   return __sb_start_write(file_inode(file)->i_sb, SB_FREEZE_WRITE, false);
+   return __sb_start_write(inode_sb(file_inode(file)), SB_FREEZE_WRITE,
+   false);
 }
 
 static inline void file_end_write(struct file *file)
 {
if (!S_ISREG(file_inode(file)->i_mode))
return;
-   __sb_end_write(file_inode(file)->i_sb, SB_FREEZE_WRITE);
+   __sb_end_write(inode_sb(file_inode(file)), SB_FREEZE_WRITE);

[PATCH 06/76] ipc: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 ipc/mqueue.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ipc/mqueue.c b/ipc/mqueue.c
index a808f29d4c5a..ac65b309c393 100644
--- a/ipc/mqueue.c
+++ b/ipc/mqueue.c
@@ -106,7 +106,7 @@ static inline struct mqueue_inode_info *MQUEUE_I(struct 
inode *inode)
  */
 static inline struct ipc_namespace *__get_ns_from_inode(struct inode *inode)
 {
-   return get_ipc_ns(inode->i_sb->s_fs_info);
+   return get_ipc_ns(inode_sb(inode)->s_fs_info);
 }
 
 static struct ipc_namespace *get_ns_from_inode(struct inode *inode)
@@ -456,7 +456,7 @@ static int mqueue_create_attr(struct dentry *dentry, 
umode_t mode, void *arg)
ipc_ns->mq_queues_count++;
spin_unlock(_lock);
 
-   inode = mqueue_get_inode(dir->i_sb, ipc_ns, mode, attr);
+   inode = mqueue_get_inode(inode_sb(dir), ipc_ns, mode, attr);
if (IS_ERR(inode)) {
error = PTR_ERR(inode);
spin_lock(_lock);
-- 
2.15.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 03/76] drivers: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 drivers/block/loop.c   |  6 ++---
 drivers/infiniband/hw/qib/qib_fs.c |  2 +-
 drivers/md/md-bitmap.c |  2 +-
 drivers/staging/lustre/lustre/llite/dir.c  | 18 +++---
 drivers/staging/lustre/lustre/llite/file.c | 28 +++---
 .../staging/lustre/lustre/llite/llite_internal.h   |  6 ++---
 drivers/staging/lustre/lustre/llite/llite_lib.c| 20 +---
 drivers/staging/lustre/lustre/llite/llite_nfs.c| 10 
 drivers/staging/lustre/lustre/llite/namei.c|  8 +++
 drivers/staging/lustre/lustre/llite/statahead.c|  8 +++
 drivers/staging/lustre/lustre/llite/symlink.c  |  4 ++--
 drivers/staging/lustre/lustre/llite/vvp_io.c   |  4 ++--
 drivers/staging/lustre/lustre/llite/xattr.c|  2 +-
 drivers/staging/ncpfs/dir.c| 17 ++---
 drivers/staging/ncpfs/file.c   |  4 ++--
 drivers/staging/ncpfs/ioctl.c  |  6 ++---
 drivers/staging/ncpfs/ncp_fs.h |  2 +-
 17 files changed, 76 insertions(+), 71 deletions(-)

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index ee62d2d517bf..1b2452b7ae09 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -173,8 +173,8 @@ static void __loop_update_dio(struct loop_device *lo, bool 
dio)
unsigned dio_align = 0;
bool use_dio;
 
-   if (inode->i_sb->s_bdev) {
-   sb_bsize = bdev_logical_block_size(inode->i_sb->s_bdev);
+   if (inode_sb(inode)->s_bdev) {
+   sb_bsize = bdev_logical_block_size(inode_sb(inode)->s_bdev);
dio_align = sb_bsize - 1;
}
 
@@ -821,7 +821,7 @@ static void loop_config_discard(struct loop_device *lo)
return;
}
 
-   q->limits.discard_granularity = inode->i_sb->s_blocksize;
+   q->limits.discard_granularity = inode_sb(inode)->s_blocksize;
q->limits.discard_alignment = 0;
 
blk_queue_max_discard_sectors(q, UINT_MAX >> 9);
diff --git a/drivers/infiniband/hw/qib/qib_fs.c 
b/drivers/infiniband/hw/qib/qib_fs.c
index 1d940a2885c9..8eab4149c7d1 100644
--- a/drivers/infiniband/hw/qib/qib_fs.c
+++ b/drivers/infiniband/hw/qib/qib_fs.c
@@ -52,7 +52,7 @@ static int qibfs_mknod(struct inode *dir, struct dentry 
*dentry,
   void *data)
 {
int error;
-   struct inode *inode = new_inode(dir->i_sb);
+   struct inode *inode = new_inode(inode_sb(dir));
 
if (!inode) {
error = -EPERM;
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index 239c7bb3929b..2355a7c18ecb 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -385,7 +385,7 @@ static int read_page(struct file *file, unsigned long index,
ret = -EINVAL;
goto out;
}
-   bh->b_bdev = inode->i_sb->s_bdev;
+   bh->b_bdev = inode_sb(inode)->s_bdev;
if (count < (1i_sb, NULL);
+   err = ll_prep_inode(, request, inode_sb(parent), NULL);
if (err)
goto err_exit;
 
@@ -470,7 +470,7 @@ int ll_dir_setstripe(struct inode *inode, struct 
lov_user_md *lump,
struct md_op_data *op_data;
struct ptlrpc_request *req = NULL;
int rc = 0;
-   struct lustre_sb_info *lsi = s2lsi(inode->i_sb);
+   struct lustre_sb_info *lsi = s2lsi(inode_sb(inode));
struct obd_device *mgc = lsi->lsi_mgc;
int lum_size;
 
@@ -544,7 +544,7 @@ int ll_dir_setstripe(struct inode *inode, struct 
lov_user_md *lump,
 
buf = param;
/* Get fsname and assume devname to be -MDT. */
-   ll_get_fsname(inode->i_sb, buf, MTI_NAME_MAXLEN);
+   ll_get_fsname(inode_sb(inode), buf, MTI_NAME_MAXLEN);
strcat(buf, "-MDT.lov");
buf += strlen(buf);
 
@@ -1093,7 +1093,8 @@ static long ll_dir_ioctl(struct file *file, unsigned int 
cmd, unsigned long arg)
rc = ll_get_fid_by_name(inode, filename, namelen, NULL, NULL);
if (rc < 0) {
CERROR("%s: lookup %.*s failed: rc = %d\n",
-  ll_get_fsname(inode->i_sb, NULL, 0), namelen,
+   

[PATCH 10/76] security: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 security/apparmor/apparmorfs.c   |  4 ++--
 security/commoncap.c |  8 
 security/inode.c |  2 +-
 security/integrity/evm/evm_crypto.c  |  4 ++--
 security/integrity/ima/ima_policy.c  |  4 ++--
 security/integrity/integrity_audit.c |  2 +-
 security/lsm_audit.c | 10 +-
 security/selinux/hooks.c | 23 ---
 security/smack/smack_lsm.c   | 26 +-
 security/tomoyo/condition.c  |  2 +-
 10 files changed, 43 insertions(+), 42 deletions(-)

diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
index a9428daa69f3..862a4bd89597 100644
--- a/security/apparmor/apparmorfs.c
+++ b/security/apparmor/apparmorfs.c
@@ -181,7 +181,7 @@ static int __aafs_setup_d_inode(struct inode *dir, struct 
dentry *dentry,
   const struct file_operations *fops,
   const struct inode_operations *iops)
 {
-   struct inode *inode = new_inode(dir->i_sb);
+   struct inode *inode = new_inode(inode_sb(dir));
 
AA_BUG(!dir);
AA_BUG(!dentry);
@@ -2349,7 +2349,7 @@ static int aa_mk_null_file(struct dentry *parent)
error = PTR_ERR(dentry);
goto out;
}
-   inode = new_inode(parent->d_inode->i_sb);
+   inode = new_inode(inode_sb(parent->d_inode));
if (!inode) {
error = -ENOMEM;
goto out1;
diff --git a/security/commoncap.c b/security/commoncap.c
index 48620c93d697..f85a10da2ba2 100644
--- a/security/commoncap.c
+++ b/security/commoncap.c
@@ -400,7 +400,7 @@ int cap_inode_getsecurity(struct inode *inode, const char 
*name, void **buffer,
if (ret < 0)
return ret;
 
-   fs_ns = inode->i_sb->s_user_ns;
+   fs_ns = inode_sb(inode)->s_user_ns;
cap = (struct vfs_cap_data *) tmpbuf;
if (is_v2header((size_t) ret, cap)) {
/* If this is sizeof(vfs_cap_data) then we're ok with the
@@ -486,7 +486,7 @@ int cap_convert_nscap(struct dentry *dentry, void **ivalue, 
size_t size)
__u32 magic, nsmagic;
struct inode *inode = d_backing_inode(dentry);
struct user_namespace *task_ns = current_user_ns(),
-   *fs_ns = inode->i_sb->s_user_ns;
+   *fs_ns = inode_sb(inode)->s_user_ns;
kuid_t rootid;
size_t newsize;
 
@@ -497,7 +497,7 @@ int cap_convert_nscap(struct dentry *dentry, void **ivalue, 
size_t size)
if (!capable_wrt_inode_uidgid(inode, CAP_SETFCAP))
return -EPERM;
if (size == XATTR_CAPS_SZ_2)
-   if (ns_capable(inode->i_sb->s_user_ns, CAP_SETFCAP))
+   if (ns_capable(inode_sb(inode)->s_user_ns, CAP_SETFCAP))
/* user is privileged, just write the v2 */
return size;
 
@@ -589,7 +589,7 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, 
struct cpu_vfs_cap_data
if (!inode)
return -ENODATA;
 
-   fs_ns = inode->i_sb->s_user_ns;
+   fs_ns = inode_sb(inode)->s_user_ns;
size = __vfs_getxattr((struct dentry *)dentry, inode,
  XATTR_NAME_CAPS, , XATTR_CAPS_SZ);
if (size == -ENODATA || size == -EOPNOTSUPP)
diff --git a/security/inode.c b/security/inode.c
index 8dd9ca8848e4..6a3d08901054 100644
--- a/security/inode.c
+++ b/security/inode.c
@@ -131,7 +131,7 @@ static struct dentry *securityfs_create_dentry(const char 
*name, umode_t mode,
goto out1;
}
 
-   inode = new_inode(dir->i_sb);
+   inode = new_inode(inode_sb(dir));
if (!inode) {
error = -ENOMEM;
goto out1;
diff --git a/security/integrity/evm/evm_crypto.c 
b/security/integrity/evm/evm_crypto.c
index 691f3e09154c..979bf5068d46 100644
--- a/security/integrity/evm/evm_crypto.c
+++ b/security/integrity/evm/evm_crypto.c
@@ -170,8 +170,8 @@ static void hmac_add_misc(struct shash_desc *desc, struct 
inode *inode,
crypto_shash_update(desc, (const u8 *)_misc, sizeof(hmac_misc));
if ((evm_hmac_attrs & EVM_ATTR_FSUUID) &&
type != EVM_XATTR_PORTABLE_DIGSIG)
-   crypto_shash_update(desc, >i_sb->s_uuid.b[0],
-   sizeof(inode->i_sb->s_uuid));
+   crypto_shash_update(desc, _sb(inode)->s_uuid.b[0],
+   sizeof(inode_sb(inode)->s_uuid));
crypto_shash_final(desc, digest);
 }
 
diff --git a/security/integrity/ima/ima_policy.c 
b/security/integrity/ima/ima_policy.c
index 915f5572c6ff..61ded57e0427 100644
--- a/security/integrity/ima/ima_policy.c
+++ b/security/integrity/ima/ima_policy.c
@@ -265,10 +265,10 @@ static bool ima_match_rules(struct ima_rule_entry *rule, 
struct inode *inode,
(!(rule->mask & mask) && func != POST_SETATTR))
return 

[PATCH 07/76] kernel: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 kernel/audit.c  | 2 +-
 kernel/audit_fsnotify.c | 2 +-
 kernel/audit_watch.c| 5 +++--
 kernel/auditsc.c| 8 
 kernel/bpf/inode.c  | 6 +++---
 kernel/bpf/offload.c| 4 ++--
 kernel/events/core.c| 4 ++--
 7 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/kernel/audit.c b/kernel/audit.c
index 227db99b0f19..23159573aafd 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -2050,7 +2050,7 @@ void audit_copy_inode(struct audit_names *name, const 
struct dentry *dentry,
  struct inode *inode)
 {
name->ino   = inode->i_ino;
-   name->dev   = inode->i_sb->s_dev;
+   name->dev   = inode_sb(inode)->s_dev;
name->mode  = inode->i_mode;
name->uid   = inode->i_uid;
name->gid   = inode->i_gid;
diff --git a/kernel/audit_fsnotify.c b/kernel/audit_fsnotify.c
index 52f368b6561e..981432cef19c 100644
--- a/kernel/audit_fsnotify.c
+++ b/kernel/audit_fsnotify.c
@@ -76,7 +76,7 @@ int audit_mark_compare(struct audit_fsnotify_mark *mark, 
unsigned long ino, dev_
 static void audit_update_mark(struct audit_fsnotify_mark *audit_mark,
 const struct inode *inode)
 {
-   audit_mark->dev = inode ? inode->i_sb->s_dev : AUDIT_DEV_UNSET;
+   audit_mark->dev = inode ? inode_sb(inode)->s_dev : AUDIT_DEV_UNSET;
audit_mark->ino = inode ? inode->i_ino : AUDIT_INO_UNSET;
 }
 
diff --git a/kernel/audit_watch.c b/kernel/audit_watch.c
index 9eb8b3511636..3e785d4cf8aa 100644
--- a/kernel/audit_watch.c
+++ b/kernel/audit_watch.c
@@ -499,7 +499,8 @@ static int audit_watch_handle_event(struct fsnotify_group 
*group,
}
 
if (mask & (FS_CREATE|FS_MOVED_TO) && inode)
-   audit_update_watch(parent, dname, inode->i_sb->s_dev, 
inode->i_ino, 0);
+   audit_update_watch(parent, dname, inode_sb(inode)->s_dev,
+  inode->i_ino, 0);
else if (mask & (FS_DELETE|FS_MOVED_FROM))
audit_update_watch(parent, dname, AUDIT_DEV_UNSET, 
AUDIT_INO_UNSET, 1);
else if (mask & (FS_DELETE_SELF|FS_UNMOUNT|FS_MOVE_SELF))
@@ -553,7 +554,7 @@ int audit_exe_compare(struct task_struct *tsk, struct 
audit_fsnotify_mark *mark)
if (!exe_file)
return 0;
ino = file_inode(exe_file)->i_ino;
-   dev = file_inode(exe_file)->i_sb->s_dev;
+   dev = inode_sb(file_inode(exe_file))->s_dev;
fput(exe_file);
return audit_mark_compare(mark, ino, dev);
 }
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index e80459f7e132..9cb16a1ebedd 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -1797,7 +1797,7 @@ void __audit_inode(struct filename *name, const struct 
dentry *dentry,
if (n->ino) {
/* valid inode number, use that for the comparison */
if (n->ino != inode->i_ino ||
-   n->dev != inode->i_sb->s_dev)
+   n->dev != inode_sb(inode)->s_dev)
continue;
} else if (n->name) {
/* inode number has not been set, check the name */
@@ -1883,8 +1883,8 @@ void __audit_inode_child(struct inode *parent,
struct audit_field *f = >rule.fields[i];
 
if (f->type == AUDIT_FSTYPE) {
-   if 
(audit_comparator(parent->i_sb->s_magic,
-   f->op, f->val)) {
+   if 
(audit_comparator(inode_sb(parent)->s_magic,
+f->op, f->val)) {
if (e->rule.action == 
AUDIT_NEVER) {
rcu_read_unlock();
return;
@@ -1906,7 +1906,7 @@ void __audit_inode_child(struct inode *parent,
 n->type != AUDIT_TYPE_UNKNOWN))
continue;
 
-   if (n->ino == parent->i_ino && n->dev == parent->i_sb->s_dev &&
+   if (n->ino == parent->i_ino && n->dev == 
inode_sb(parent)->s_dev &&
!audit_compare_dname_path(dname,
  n->name->name, n->name_len)) {
if (n->type == AUDIT_TYPE_UNKNOWN)
diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c
index 81e2f6995adb..130d9edc11eb 100644
--- a/kernel/bpf/inode.c
+++ b/kernel/bpf/inode.c
@@ -136,7 +136,7 @@ static int bpf_mkdir(struct inode *dir, struct dentry 
*dentry, umode_t mode)
 {
struct inode *inode;
 
-   inode = bpf_get_inode(dir->i_sb, dir, mode | S_IFDIR);
+   inode = bpf_get_inode(inode_sb(dir), dir, mode | S_IFDIR);
if (IS_ERR(inode))
return PTR_ERR(inode);
 
@@ -154,7 +154,7 @@ static int 

[PATCH 11/76] fs/9p: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/9p/acl.c|  3 ++-
 fs/9p/v9fs.h   |  2 +-
 fs/9p/vfs_inode.c  |  8 
 fs/9p/vfs_inode_dotl.c | 14 +++---
 4 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/fs/9p/acl.c b/fs/9p/acl.c
index 082d227fa56b..ccd91eb83725 100644
--- a/fs/9p/acl.c
+++ b/fs/9p/acl.c
@@ -266,7 +266,8 @@ static int v9fs_xattr_set_acl(const struct xattr_handler 
*handler,
if (IS_ERR(acl))
return PTR_ERR(acl);
else if (acl) {
-   retval = posix_acl_valid(inode->i_sb->s_user_ns, acl);
+   retval = posix_acl_valid(inode_sb(inode)->s_user_ns,
+acl);
if (retval)
goto err_out;
}
diff --git a/fs/9p/v9fs.h b/fs/9p/v9fs.h
index 982e017acadb..9e27ef7ebeaa 100644
--- a/fs/9p/v9fs.h
+++ b/fs/9p/v9fs.h
@@ -171,7 +171,7 @@ extern struct inode *v9fs_inode_from_fid_dotl(struct 
v9fs_session_info *v9ses,
 
 static inline struct v9fs_session_info *v9fs_inode2v9ses(struct inode *inode)
 {
-   return (inode->i_sb->s_fs_info);
+   return (inode_sb(inode)->s_fs_info);
 }
 
 static inline struct v9fs_session_info *v9fs_dentry2v9ses(struct dentry 
*dentry)
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index bdabb2765d1b..fb6220552fc6 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -690,7 +690,7 @@ v9fs_create(struct v9fs_session_info *v9ses, struct inode 
*dir,
/*
 * instantiate inode and assign the unopened fid to the dentry
 */
-   inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb);
+   inode = v9fs_get_new_inode_from_fid(v9ses, fid, inode_sb(dir));
if (IS_ERR(inode)) {
err = PTR_ERR(inode);
p9_debug(P9_DEBUG_VFS,
@@ -820,9 +820,9 @@ struct dentry *v9fs_vfs_lookup(struct inode *dir, struct 
dentry *dentry,
 * inode. But with cache disabled, lookup should do this.
 */
if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE)
-   inode = v9fs_get_inode_from_fid(v9ses, fid, dir->i_sb);
+   inode = v9fs_get_inode_from_fid(v9ses, fid, inode_sb(dir));
else
-   inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb);
+   inode = v9fs_get_new_inode_from_fid(v9ses, fid, inode_sb(dir));
if (IS_ERR(inode)) {
p9_client_clunk(fid);
return ERR_CAST(inode);
@@ -1425,7 +1425,7 @@ int v9fs_refresh_inode(struct p9_fid *fid, struct inode 
*inode)
 * because we may have cached data
 */
i_size = inode->i_size;
-   v9fs_stat2inode(st, inode, inode->i_sb);
+   v9fs_stat2inode(st, inode, inode_sb(inode));
if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE)
inode->i_size = i_size;
spin_unlock(>i_lock);
diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
index 7f6ae21a27b3..ed462264239c 100644
--- a/fs/9p/vfs_inode_dotl.c
+++ b/fs/9p/vfs_inode_dotl.c
@@ -318,7 +318,7 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry 
*dentry,
fid = NULL;
goto error;
}
-   inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb);
+   inode = v9fs_get_new_inode_from_fid(v9ses, fid, inode_sb(dir));
if (IS_ERR(inode)) {
err = PTR_ERR(inode);
p9_debug(P9_DEBUG_VFS, "inode creation failed %d\n", err);
@@ -435,7 +435,7 @@ static int v9fs_vfs_mkdir_dotl(struct inode *dir,
 
/* instantiate inode and assign the unopened fid to the dentry */
if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) {
-   inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb);
+   inode = v9fs_get_new_inode_from_fid(v9ses, fid, inode_sb(dir));
if (IS_ERR(inode)) {
err = PTR_ERR(inode);
p9_debug(P9_DEBUG_VFS, "inode creation failed %d\n",
@@ -453,7 +453,7 @@ static int v9fs_vfs_mkdir_dotl(struct inode *dir,
 * inode with stat. We need to get an inode
 * so that we can set the acl with dentry
 */
-   inode = v9fs_get_inode(dir->i_sb, mode, 0);
+   inode = v9fs_get_inode(inode_sb(dir), mode, 0);
if (IS_ERR(inode)) {
err = PTR_ERR(inode);
goto error;
@@ -723,7 +723,7 @@ v9fs_vfs_symlink_dotl(struct inode *dir, struct dentry 
*dentry,
}
 
/* instantiate inode and assign the unopened fid to dentry */
-   inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb);
+   inode = v9fs_get_new_inode_from_fid(v9ses, fid, inode_sb(dir));
   

[PATCH 12/76] fs/adfs: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/adfs/dir.c   | 6 +++---
 fs/adfs/inode.c | 8 
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/fs/adfs/dir.c b/fs/adfs/dir.c
index 29444c83da48..e28357fcb2d4 100644
--- a/fs/adfs/dir.c
+++ b/fs/adfs/dir.c
@@ -20,7 +20,7 @@ static int
 adfs_readdir(struct file *file, struct dir_context *ctx)
 {
struct inode *inode = file_inode(file);
-   struct super_block *sb = inode->i_sb;
+   struct super_block *sb = inode_sb(inode);
const struct adfs_dir_ops *ops = ADFS_SB(sb)->s_dir;
struct object_info obj;
struct adfs_dir dir;
@@ -128,7 +128,7 @@ adfs_match(const struct qstr *name, struct object_info *obj)
 static int
 adfs_dir_lookup_byname(struct inode *inode, const struct qstr *name, struct 
object_info *obj)
 {
-   struct super_block *sb = inode->i_sb;
+   struct super_block *sb = inode_sb(inode);
const struct adfs_dir_ops *ops = ADFS_SB(sb)->s_dir;
struct adfs_dir dir;
int ret;
@@ -271,7 +271,7 @@ adfs_lookup(struct inode *dir, struct dentry *dentry, 
unsigned int flags)
 * This only returns NULL if get_empty_inode
 * fails.
 */
-   inode = adfs_iget(dir->i_sb, );
+   inode = adfs_iget(inode_sb(dir), );
if (inode)
error = 0;
}
diff --git a/fs/adfs/inode.c b/fs/adfs/inode.c
index 8dbd36f5e581..c946b072ef7f 100644
--- a/fs/adfs/inode.c
+++ b/fs/adfs/inode.c
@@ -23,9 +23,9 @@ adfs_get_block(struct inode *inode, sector_t block, struct 
buffer_head *bh,
if (block >= inode->i_blocks)
goto abort_toobig;
 
-   block = __adfs_block_map(inode->i_sb, inode->i_ino, block);
+   block = __adfs_block_map(inode_sb(inode), inode->i_ino, block);
if (block)
-   map_bh(bh, inode->i_sb, block);
+   map_bh(bh, inode_sb(inode), block);
return 0;
}
/* don't support allocation of blocks yet */
@@ -299,7 +299,7 @@ int
 adfs_notify_change(struct dentry *dentry, struct iattr *attr)
 {
struct inode *inode = d_inode(dentry);
-   struct super_block *sb = inode->i_sb;
+   struct super_block *sb = inode_sb(inode);
unsigned int ia_valid = attr->ia_valid;
int error;

@@ -354,7 +354,7 @@ adfs_notify_change(struct dentry *dentry, struct iattr 
*attr)
  */
 int adfs_write_inode(struct inode *inode, struct writeback_control *wbc)
 {
-   struct super_block *sb = inode->i_sb;
+   struct super_block *sb = inode_sb(inode);
struct object_info obj;
int ret;
 
-- 
2.15.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 13/76] fs/affs: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/affs/amigaffs.c | 10 +-
 fs/affs/bitmap.c   |  2 +-
 fs/affs/dir.c  |  2 +-
 fs/affs/file.c | 28 ++--
 fs/affs/inode.c| 16 
 fs/affs/namei.c| 12 ++--
 fs/affs/symlink.c  |  4 ++--
 7 files changed, 37 insertions(+), 37 deletions(-)

diff --git a/fs/affs/amigaffs.c b/fs/affs/amigaffs.c
index 14a6c1b90c9f..42dacf56dd0e 100644
--- a/fs/affs/amigaffs.c
+++ b/fs/affs/amigaffs.c
@@ -25,7 +25,7 @@
 int
 affs_insert_hash(struct inode *dir, struct buffer_head *bh)
 {
-   struct super_block *sb = dir->i_sb;
+   struct super_block *sb = inode_sb(dir);
struct buffer_head *dir_bh;
u32 ino, hash_ino;
int offset;
@@ -80,7 +80,7 @@ affs_remove_hash(struct inode *dir, struct buffer_head 
*rem_bh)
__be32 ino;
int offset, retval;
 
-   sb = dir->i_sb;
+   sb = inode_sb(dir);
rem_ino = rem_bh->b_blocknr;
offset = affs_hash_name(sb, AFFS_TAIL(sb, rem_bh)->name+1, 
AFFS_TAIL(sb, rem_bh)->name[0]);
pr_debug("%s(dir=%lu, ino=%d, hashval=%d)\n", __func__, dir->i_ino,
@@ -142,7 +142,7 @@ static int
 affs_remove_link(struct dentry *dentry)
 {
struct inode *dir, *inode = d_inode(dentry);
-   struct super_block *sb = inode->i_sb;
+   struct super_block *sb = inode_sb(inode);
struct buffer_head *bh, *link_bh = NULL;
u32 link_ino, ino;
int retval;
@@ -233,7 +233,7 @@ affs_remove_link(struct dentry *dentry)
 static int
 affs_empty_dir(struct inode *inode)
 {
-   struct super_block *sb = inode->i_sb;
+   struct super_block *sb = inode_sb(inode);
struct buffer_head *bh;
int retval, size;
 
@@ -272,7 +272,7 @@ affs_remove_header(struct dentry *dentry)
int retval;
 
dir = d_inode(dentry->d_parent);
-   sb = dir->i_sb;
+   sb = inode_sb(dir);
 
retval = -ENOENT;
inode = d_inode(dentry);
diff --git a/fs/affs/bitmap.c b/fs/affs/bitmap.c
index 5ba9ef2742f6..b6f7955680c4 100644
--- a/fs/affs/bitmap.c
+++ b/fs/affs/bitmap.c
@@ -122,7 +122,7 @@ affs_alloc_block(struct inode *inode, u32 goal)
u32 blk, bmap, bit, mask, mask2, tmp;
int i;
 
-   sb = inode->i_sb;
+   sb = inode_sb(inode);
sbi = AFFS_SB(sb);
 
pr_debug("balloc(inode=%lu,goal=%u): ", inode->i_ino, goal);
diff --git a/fs/affs/dir.c b/fs/affs/dir.c
index b2bf7016e1b3..098b52a09634 100644
--- a/fs/affs/dir.c
+++ b/fs/affs/dir.c
@@ -45,7 +45,7 @@ static int
 affs_readdir(struct file *file, struct dir_context *ctx)
 {
struct inode*inode = file_inode(file);
-   struct super_block  *sb = inode->i_sb;
+   struct super_block  *sb = inode_sb(inode);
struct buffer_head  *dir_bh = NULL;
struct buffer_head  *fh_bh = NULL;
unsigned char   *name;
diff --git a/fs/affs/file.c b/fs/affs/file.c
index a85817f54483..e253f1137921 100644
--- a/fs/affs/file.c
+++ b/fs/affs/file.c
@@ -47,7 +47,7 @@ affs_file_release(struct inode *inode, struct file *filp)
 static int
 affs_grow_extcache(struct inode *inode, u32 lc_idx)
 {
-   struct super_block  *sb = inode->i_sb;
+   struct super_block  *sb = inode_sb(inode);
struct buffer_head  *bh;
u32 lc_max;
int i, j, key;
@@ -117,7 +117,7 @@ affs_grow_extcache(struct inode *inode, u32 lc_idx)
 static struct buffer_head *
 affs_alloc_extblock(struct inode *inode, struct buffer_head *bh, u32 ext)
 {
-   struct super_block *sb = inode->i_sb;
+   struct super_block *sb = inode_sb(inode);
struct buffer_head *new_bh;
u32 blocknr, tmp;
 
@@ -169,7 +169,7 @@ affs_get_extblock(struct inode *inode, u32 ext)
 static struct buffer_head *
 affs_get_extblock_slow(struct inode *inode, u32 ext)
 {
-   struct super_block *sb = inode->i_sb;
+   struct super_block *sb = inode_sb(inode);
struct buffer_head *bh;
u32 ext_key;
u32 lc_idx, lc_off, ac_idx;
@@ -294,7 +294,7 @@ affs_get_extblock_slow(struct inode *inode, u32 ext)
 static int
 affs_get_block(struct inode *inode, sector_t block, struct buffer_head 
*bh_result, int create)
 {
-   struct super_block  *sb = inode->i_sb;
+   struct super_block  *sb = inode_sb(inode);
struct buffer_head  *ext_bh;
u32  ext;
 
@@ -353,7 +353,7 @@ affs_get_block(struct inode *inode, sector_t block, struct 
buffer_head *bh_resul
return 0;
 
 err_big:
-   affs_error(inode->i_sb, "get_block", "strange block request %llu",
+   affs_error(inode_sb(inode), "get_block", "strange block request %llu",
   (unsigned long long)block);
return -EIO;
 err_ext:
@@ -451,7 +451,7 @@ affs_bread_ino(struct inode *inode, int block, int create)
tmp_bh.b_state = 0;
err = affs_get_block(inode, block, _bh, create);
if (!err) {
-   bh = 

[PATCH 14/76] fs/afs: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/afs/callback.c | 2 +-
 fs/afs/dir.c  | 8 
 fs/afs/file.c | 2 +-
 fs/afs/write.c| 4 ++--
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/fs/afs/callback.c b/fs/afs/callback.c
index f4291b576054..73371c83b646 100644
--- a/fs/afs/callback.c
+++ b/fs/afs/callback.c
@@ -63,7 +63,7 @@ int afs_register_server_cb_interest(struct afs_vnode *vnode,
return -ENOMEM;
 
refcount_set(>usage, 1);
-   new->sb = vnode->vfs_inode.i_sb;
+   new->sb = vnode->vfs_inode.i_view->v_sb;
new->vid = vnode->volume->vid;
new->server = afs_get_server(server);
INIT_LIST_HEAD(>cb_link);
diff --git a/fs/afs/dir.c b/fs/afs/dir.c
index ba2b458b36d1..1a828b1da90f 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -453,7 +453,7 @@ static int afs_lookup_filldir(struct dir_context *ctx, 
const char *name,
 static int afs_do_lookup(struct inode *dir, struct dentry *dentry,
 struct afs_fid *fid, struct key *key)
 {
-   struct afs_super_info *as = dir->i_sb->s_fs_info;
+   struct afs_super_info *as = inode_sb(dir)->s_fs_info;
struct afs_lookup_cookie cookie = {
.ctx.actor = afs_lookup_filldir,
.name = dentry->d_name,
@@ -533,7 +533,7 @@ static struct inode *afs_try_auto_mntpt(struct dentry 
*dentry,
if (ret < 0)
goto out;
 
-   inode = afs_iget_pseudo_dir(dir->i_sb, false);
+   inode = afs_iget_pseudo_dir(inode_sb(dir), false);
if (IS_ERR(inode)) {
ret = PTR_ERR(inode);
goto out;
@@ -614,7 +614,7 @@ static struct dentry *afs_lookup(struct inode *dir, struct 
dentry *dentry,
dentry->d_fsdata = (void *)(unsigned long) vnode->status.data_version;
 
/* instantiate the dentry */
-   inode = afs_iget(dir->i_sb, key, , NULL, NULL, NULL);
+   inode = afs_iget(inode_sb(dir), key, , NULL, NULL, NULL);
key_put(key);
if (IS_ERR(inode)) {
_leave(" = %ld", PTR_ERR(inode));
@@ -861,7 +861,7 @@ static void afs_vnode_new_inode(struct afs_fs_cursor *fc,
 
d_drop(new_dentry);
 
-   inode = afs_iget(fc->vnode->vfs_inode.i_sb, fc->key,
+   inode = afs_iget(fc->vnode->vfs_inode.i_view->v_sb, fc->key,
 newfid, newstatus, newcb, fc->cbi);
if (IS_ERR(inode)) {
/* ENOMEM or EINTR at a really inconvenient time - just abandon
diff --git a/fs/afs/file.c b/fs/afs/file.c
index a39192ced99e..1abbe9f37163 100644
--- a/fs/afs/file.c
+++ b/fs/afs/file.c
@@ -376,7 +376,7 @@ static int afs_readpage(struct file *file, struct page 
*page)
ret = afs_page_filler(key, page);
} else {
struct inode *inode = page->mapping->host;
-   key = afs_request_key(AFS_FS_S(inode->i_sb)->cell);
+   key = afs_request_key(AFS_FS_S(inode_sb(inode))->cell);
if (IS_ERR(key)) {
ret = PTR_ERR(key);
} else {
diff --git a/fs/afs/write.c b/fs/afs/write.c
index 9370e2feb999..df5a30e0d46e 100644
--- a/fs/afs/write.c
+++ b/fs/afs/write.c
@@ -761,7 +761,7 @@ int afs_page_mkwrite(struct vm_fault *vmf)
_enter("{{%x:%u}},{%lx}",
   vnode->fid.vid, vnode->fid.vnode, vmf->page->index);
 
-   sb_start_pagefault(inode->i_sb);
+   sb_start_pagefault(inode_sb(inode));
 
/* Wait for the page to be written to the cache before we allow it to
 * be modified.  We then assume the entire page will need writing back.
@@ -790,7 +790,7 @@ int afs_page_mkwrite(struct vm_fault *vmf)
SetPagePrivate(vmf->page);
set_page_private(vmf->page, priv);
 
-   sb_end_pagefault(inode->i_sb);
+   sb_end_pagefault(inode_sb(inode));
return VM_FAULT_LOCKED;
 }
 
-- 
2.15.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 09/76] net: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 net/sunrpc/auth_gss/auth_gss.c | 4 ++--
 net/sunrpc/rpc_pipe.c  | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c
index 9463af4b32e8..3560956424fe 100644
--- a/net/sunrpc/auth_gss/auth_gss.c
+++ b/net/sunrpc/auth_gss/auth_gss.c
@@ -769,7 +769,7 @@ gss_pipe_downcall(struct file *filp, const char __user 
*src, size_t mlen)
 
 static int gss_pipe_open(struct inode *inode, int new_version)
 {
-   struct net *net = inode->i_sb->s_fs_info;
+   struct net *net = inode_sb(inode)->s_fs_info;
struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
int ret = 0;
 
@@ -804,7 +804,7 @@ static int gss_pipe_open_v1(struct inode *inode)
 static void
 gss_pipe_release(struct inode *inode)
 {
-   struct net *net = inode->i_sb->s_fs_info;
+   struct net *net = inode_sb(inode)->s_fs_info;
struct rpc_pipe *pipe = RPC_I(inode)->pipe;
struct gss_upcall_msg *gss_msg;
 
diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
index fc97fc3ed637..c2851a1ee91c 100644
--- a/net/sunrpc/rpc_pipe.c
+++ b/net/sunrpc/rpc_pipe.c
@@ -497,10 +497,10 @@ static int __rpc_create_common(struct inode *dir, struct 
dentry *dentry,
struct inode *inode;
 
d_drop(dentry);
-   inode = rpc_get_inode(dir->i_sb, mode);
+   inode = rpc_get_inode(inode_sb(dir), mode);
if (!inode)
goto out_err;
-   inode->i_ino = iunique(dir->i_sb, 100);
+   inode->i_ino = iunique(inode_sb(dir), 100);
if (i_fop)
inode->i_fop = i_fop;
if (private)
-- 
2.15.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 08/76] mm: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 mm/cleancache.c | 10 +-
 mm/filemap.c| 12 ++--
 mm/hugetlb.c|  2 +-
 mm/memory-failure.c |  2 +-
 mm/shmem.c  | 29 +++--
 mm/swapfile.c   |  4 ++--
 6 files changed, 30 insertions(+), 29 deletions(-)

diff --git a/mm/cleancache.c b/mm/cleancache.c
index f7b9fdc79d97..b4cabc316aea 100644
--- a/mm/cleancache.c
+++ b/mm/cleancache.c
@@ -147,7 +147,7 @@ static int cleancache_get_key(struct inode *inode,
 {
int (*fhfn)(struct inode *, __u32 *fh, int *, struct inode *);
int len = 0, maxlen = CLEANCACHE_KEY_MAX;
-   struct super_block *sb = inode->i_sb;
+   struct super_block *sb = inode_sb(inode);
 
key->u.ino = inode->i_ino;
if (sb->s_export_op != NULL) {
@@ -186,7 +186,7 @@ int __cleancache_get_page(struct page *page)
}
 
VM_BUG_ON_PAGE(!PageLocked(page), page);
-   pool_id = page->mapping->host->i_sb->cleancache_poolid;
+   pool_id = inode_sb(page->mapping->host)->cleancache_poolid;
if (pool_id < 0)
goto out;
 
@@ -224,7 +224,7 @@ void __cleancache_put_page(struct page *page)
}
 
VM_BUG_ON_PAGE(!PageLocked(page), page);
-   pool_id = page->mapping->host->i_sb->cleancache_poolid;
+   pool_id = inode_sb(page->mapping->host)->cleancache_poolid;
if (pool_id >= 0 &&
cleancache_get_key(page->mapping->host, ) >= 0) {
cleancache_ops->put_page(pool_id, key, page->index, page);
@@ -245,7 +245,7 @@ void __cleancache_invalidate_page(struct address_space 
*mapping,
struct page *page)
 {
/* careful... page->mapping is NULL sometimes when this is called */
-   int pool_id = mapping->host->i_sb->cleancache_poolid;
+   int pool_id = inode_sb(mapping->host)->cleancache_poolid;
struct cleancache_filekey key = { .u.key = { 0 } };
 
if (!cleancache_ops)
@@ -273,7 +273,7 @@ EXPORT_SYMBOL(__cleancache_invalidate_page);
  */
 void __cleancache_invalidate_inode(struct address_space *mapping)
 {
-   int pool_id = mapping->host->i_sb->cleancache_poolid;
+   int pool_id = inode_sb(mapping->host)->cleancache_poolid;
struct cleancache_filekey key = { .u.key = { 0 } };
 
if (!cleancache_ops)
diff --git a/mm/filemap.c b/mm/filemap.c
index 693f62212a59..c81943b5ab3d 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2064,9 +2064,9 @@ static ssize_t generic_file_buffered_read(struct kiocb 
*iocb,
unsigned int prev_offset;
int error = 0;
 
-   if (unlikely(*ppos >= inode->i_sb->s_maxbytes))
+   if (unlikely(*ppos >= inode_sb(inode)->s_maxbytes))
return 0;
-   iov_iter_truncate(iter, inode->i_sb->s_maxbytes);
+   iov_iter_truncate(iter, inode_sb(inode)->s_maxbytes);
 
index = *ppos >> PAGE_SHIFT;
prev_index = ra->prev_pos >> PAGE_SHIFT;
@@ -2702,7 +2702,7 @@ int filemap_page_mkwrite(struct vm_fault *vmf)
struct inode *inode = file_inode(vmf->vma->vm_file);
int ret = VM_FAULT_LOCKED;
 
-   sb_start_pagefault(inode->i_sb);
+   sb_start_pagefault(inode_sb(inode));
file_update_time(vmf->vma->vm_file);
lock_page(page);
if (page->mapping != inode->i_mapping) {
@@ -2718,7 +2718,7 @@ int filemap_page_mkwrite(struct vm_fault *vmf)
set_page_dirty(page);
wait_for_stable_page(page);
 out:
-   sb_end_pagefault(inode->i_sb);
+   sb_end_pagefault(inode_sb(inode));
return ret;
 }
 EXPORT_SYMBOL(filemap_page_mkwrite);
@@ -2965,10 +2965,10 @@ inline ssize_t generic_write_checks(struct kiocb *iocb, 
struct iov_iter *from)
 * exceeded without writing data we send a signal and return EFBIG.
 * Linus frestrict idea will clean these up nicely..
 */
-   if (unlikely(pos >= inode->i_sb->s_maxbytes))
+   if (unlikely(pos >= inode_sb(inode)->s_maxbytes))
return -EFBIG;
 
-   iov_iter_truncate(from, inode->i_sb->s_maxbytes - pos);
+   iov_iter_truncate(from, inode_sb(inode)->s_maxbytes - pos);
return iov_iter_count(from);
 }
 EXPORT_SYMBOL(generic_write_checks);
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 976bbc5646fe..350ca2f2a05e 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -209,7 +209,7 @@ static long hugepage_subpool_put_pages(struct 
hugepage_subpool *spool,
 
 static inline struct hugepage_subpool *subpool_inode(struct inode *inode)
 {
-   return HUGETLBFS_SB(inode->i_sb)->spool;
+   return HUGETLBFS_SB(inode_sb(inode))->spool;
 }
 
 static inline struct hugepage_subpool *subpool_vma(struct vm_area_struct *vma)
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 8291b75f42c8..08e2367985f8 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -98,7 +98,7 @@ static int hwpoison_filter_dev(struct page *p)
if (mapping == NULL || mapping->host == NULL)
   

[PATCH 15/76] fs/autofs4: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/autofs4/dev-ioctl.c |  2 +-
 fs/autofs4/root.c  | 20 ++--
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/fs/autofs4/dev-ioctl.c b/fs/autofs4/dev-ioctl.c
index b7c816f39404..6b28b01e5022 100644
--- a/fs/autofs4/dev-ioctl.c
+++ b/fs/autofs4/dev-ioctl.c
@@ -166,7 +166,7 @@ static struct autofs_sb_info *autofs_dev_ioctl_sbi(struct 
file *f)
 
if (f) {
inode = file_inode(f);
-   sbi = autofs4_sbi(inode->i_sb);
+   sbi = autofs4_sbi(inode_sb(inode));
}
return sbi;
 }
diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c
index 82e8f6edfb48..41b0a0b73bce 100644
--- a/fs/autofs4/root.c
+++ b/fs/autofs4/root.c
@@ -513,7 +513,7 @@ static struct dentry *autofs4_lookup(struct inode *dir,
if (dentry->d_name.len > NAME_MAX)
return ERR_PTR(-ENAMETOOLONG);
 
-   sbi = autofs4_sbi(dir->i_sb);
+   sbi = autofs4_sbi(inode_sb(dir));
 
pr_debug("pid = %u, pgrp = %u, catatonic = %d, oz_mode = %d\n",
 current->pid, task_pgrp_nr(current), sbi->catatonic,
@@ -553,7 +553,7 @@ static int autofs4_dir_symlink(struct inode *dir,
   struct dentry *dentry,
   const char *symname)
 {
-   struct autofs_sb_info *sbi = autofs4_sbi(dir->i_sb);
+   struct autofs_sb_info *sbi = autofs4_sbi(inode_sb(dir));
struct autofs_info *ino = autofs4_dentry_ino(dentry);
struct autofs_info *p_ino;
struct inode *inode;
@@ -577,7 +577,7 @@ static int autofs4_dir_symlink(struct inode *dir,
 
strcpy(cp, symname);
 
-   inode = autofs4_get_inode(dir->i_sb, S_IFLNK | 0555);
+   inode = autofs4_get_inode(inode_sb(dir), S_IFLNK | 0555);
if (!inode) {
kfree(cp);
return -ENOMEM;
@@ -614,7 +614,7 @@ static int autofs4_dir_symlink(struct inode *dir,
  */
 static int autofs4_dir_unlink(struct inode *dir, struct dentry *dentry)
 {
-   struct autofs_sb_info *sbi = autofs4_sbi(dir->i_sb);
+   struct autofs_sb_info *sbi = autofs4_sbi(inode_sb(dir));
struct autofs_info *ino = autofs4_dentry_ino(dentry);
struct autofs_info *p_ino;
 
@@ -694,7 +694,7 @@ static void autofs_clear_leaf_automount_flags(struct dentry 
*dentry)
 
 static int autofs4_dir_rmdir(struct inode *dir, struct dentry *dentry)
 {
-   struct autofs_sb_info *sbi = autofs4_sbi(dir->i_sb);
+   struct autofs_sb_info *sbi = autofs4_sbi(inode_sb(dir));
struct autofs_info *ino = autofs4_dentry_ino(dentry);
struct autofs_info *p_ino;
 
@@ -733,7 +733,7 @@ static int autofs4_dir_rmdir(struct inode *dir, struct 
dentry *dentry)
 static int autofs4_dir_mkdir(struct inode *dir,
 struct dentry *dentry, umode_t mode)
 {
-   struct autofs_sb_info *sbi = autofs4_sbi(dir->i_sb);
+   struct autofs_sb_info *sbi = autofs4_sbi(inode_sb(dir));
struct autofs_info *ino = autofs4_dentry_ino(dentry);
struct autofs_info *p_ino;
struct inode *inode;
@@ -749,7 +749,7 @@ static int autofs4_dir_mkdir(struct inode *dir,
 
autofs4_del_active(dentry);
 
-   inode = autofs4_get_inode(dir->i_sb, S_IFDIR | 0555);
+   inode = autofs4_get_inode(inode_sb(dir), S_IFDIR | 0555);
if (!inode)
return -ENOMEM;
d_add(dentry, inode);
@@ -868,7 +868,7 @@ int is_autofs4_dentry(struct dentry *dentry)
 static int autofs4_root_ioctl_unlocked(struct inode *inode, struct file *filp,
   unsigned int cmd, unsigned long arg)
 {
-   struct autofs_sb_info *sbi = autofs4_sbi(inode->i_sb);
+   struct autofs_sb_info *sbi = autofs4_sbi(inode_sb(inode));
void __user *p = (void __user *)arg;
 
pr_debug("cmd = 0x%08x, arg = 0x%08lx, sbi = %p, pgrp = %u\n",
@@ -905,11 +905,11 @@ static int autofs4_root_ioctl_unlocked(struct inode 
*inode, struct file *filp,
 
/* return a single thing to expire */
case AUTOFS_IOC_EXPIRE:
-   return autofs4_expire_run(inode->i_sb,
+   return autofs4_expire_run(inode_sb(inode),
  filp->f_path.mnt, sbi, p);
/* same as above, but can send multiple expires through pipe */
case AUTOFS_IOC_EXPIRE_MULTI:
-   return autofs4_expire_multi(inode->i_sb,
+   return autofs4_expire_multi(inode_sb(inode),
filp->f_path.mnt, sbi, p);
 
default:
-- 
2.15.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 16/76] fs/befs: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/befs/linuxvfs.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
index af2832aaeec5..fc997025b9a0 100644
--- a/fs/befs/linuxvfs.c
+++ b/fs/befs/linuxvfs.c
@@ -131,7 +131,7 @@ static int
 befs_get_block(struct inode *inode, sector_t block,
   struct buffer_head *bh_result, int create)
 {
-   struct super_block *sb = inode->i_sb;
+   struct super_block *sb = inode_sb(inode);
befs_data_stream *ds = _I(inode)->i_data.ds;
befs_block_run run = BAD_IADDR;
int res;
@@ -157,7 +157,7 @@ befs_get_block(struct inode *inode, sector_t block,
 
disk_off = (ulong) iaddr2blockno(sb, );
 
-   map_bh(bh_result, inode->i_sb, disk_off);
+   map_bh(bh_result, inode_sb(inode), disk_off);
 
befs_debug(sb, "<--- %s for inode %lu, block %ld, disk address %lu",
  __func__, (unsigned long)inode->i_ino, (long)block,
@@ -170,7 +170,7 @@ static struct dentry *
 befs_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
 {
struct inode *inode;
-   struct super_block *sb = dir->i_sb;
+   struct super_block *sb = inode_sb(dir);
const befs_data_stream *ds = _I(dir)->i_data.ds;
befs_off_t offset;
int ret;
@@ -206,7 +206,7 @@ befs_lookup(struct inode *dir, struct dentry *dentry, 
unsigned int flags)
return ERR_PTR(-ENODATA);
}
 
-   inode = befs_iget(dir->i_sb, (ino_t) offset);
+   inode = befs_iget(inode_sb(dir), (ino_t) offset);
if (IS_ERR(inode))
return ERR_CAST(inode);
 
@@ -221,7 +221,7 @@ static int
 befs_readdir(struct file *file, struct dir_context *ctx)
 {
struct inode *inode = file_inode(file);
-   struct super_block *sb = inode->i_sb;
+   struct super_block *sb = inode_sb(inode);
const befs_data_stream *ds = _I(inode)->i_data.ds;
befs_off_t value;
int result;
@@ -482,7 +482,7 @@ befs_destroy_inodecache(void)
 static int befs_symlink_readpage(struct file *unused, struct page *page)
 {
struct inode *inode = page->mapping->host;
-   struct super_block *sb = inode->i_sb;
+   struct super_block *sb = inode_sb(inode);
struct befs_inode_info *befs_ino = BEFS_I(inode);
befs_data_stream *data = _ino->i_data.ds;
befs_off_t len = data->size;
-- 
2.15.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 19/76] fs/ceph: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/ceph/addr.c   |  2 +-
 fs/ceph/caps.c   | 16 
 fs/ceph/dir.c| 24 
 fs/ceph/file.c   | 16 
 fs/ceph/inode.c  | 16 
 fs/ceph/ioctl.c  |  6 +++---
 fs/ceph/locks.c  |  2 +-
 fs/ceph/mds_client.c |  2 +-
 fs/ceph/snap.c   |  2 +-
 fs/ceph/super.h  |  2 +-
 fs/ceph/xattr.c  |  8 
 11 files changed, 48 insertions(+), 48 deletions(-)

diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index b4336b42ce3b..8741e928fca0 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -776,7 +776,7 @@ static void writepages_finish(struct ceph_osd_request *req)
osd_data = osd_req_op_extent_osd_data(req, 0);
if (osd_data->pages_from_pool)
mempool_free(osd_data->pages,
-ceph_sb_to_client(inode->i_sb)->wb_pagevec_pool);
+
ceph_sb_to_client(inode_sb(inode))->wb_pagevec_pool);
else
kfree(osd_data->pages);
ceph_osdc_put_request(req);
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index 0e5bd3e3344e..d92e6e9ff6e2 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -977,7 +977,7 @@ static void drop_inode_snap_realm(struct ceph_inode_info 
*ci)
ci->i_snap_realm_counter++;
ci->i_snap_realm = NULL;
spin_unlock(>inodes_with_caps_lock);
-   ceph_put_snap_realm(ceph_sb_to_client(ci->vfs_inode.i_sb)->mdsc,
+   ceph_put_snap_realm(ceph_sb_to_client(inode_sb(>vfs_inode))->mdsc,
realm);
 }
 
@@ -992,7 +992,7 @@ void __ceph_remove_cap(struct ceph_cap *cap, bool 
queue_release)
struct ceph_mds_session *session = cap->session;
struct ceph_inode_info *ci = cap->ci;
struct ceph_mds_client *mdsc =
-   ceph_sb_to_client(ci->vfs_inode.i_sb)->mdsc;
+   ceph_sb_to_client(inode_sb(>vfs_inode))->mdsc;
int removed = 0;
 
dout("__ceph_remove_cap %p from %p\n", cap, >vfs_inode);
@@ -1551,7 +1551,7 @@ int __ceph_mark_dirty_caps(struct ceph_inode_info *ci, 
int mask,
   struct ceph_cap_flush **pcf)
 {
struct ceph_mds_client *mdsc =
-   ceph_sb_to_client(ci->vfs_inode.i_sb)->mdsc;
+   ceph_sb_to_client(inode_sb(>vfs_inode))->mdsc;
struct inode *inode = >vfs_inode;
int was = ci->i_dirty_caps;
int dirty = 0;
@@ -1660,7 +1660,7 @@ static int __mark_caps_flushing(struct inode *inode,
struct ceph_mds_session *session, bool wake,
u64 *flush_tid, u64 *oldest_flush_tid)
 {
-   struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc;
+   struct ceph_mds_client *mdsc = ceph_sb_to_client(inode_sb(inode))->mdsc;
struct ceph_inode_info *ci = ceph_inode(inode);
struct ceph_cap_flush *cf = NULL;
int flushing;
@@ -2029,7 +2029,7 @@ void ceph_check_caps(struct ceph_inode_info *ci, int 
flags,
  */
 static int try_flush_caps(struct inode *inode, u64 *ptid)
 {
-   struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc;
+   struct ceph_mds_client *mdsc = ceph_sb_to_client(inode_sb(inode))->mdsc;
struct ceph_inode_info *ci = ceph_inode(inode);
struct ceph_mds_session *session = NULL;
int flushing = 0;
@@ -2217,7 +2217,7 @@ int ceph_write_inode(struct inode *inode, struct 
writeback_control *wbc)
   caps_are_flushed(inode, flush_tid));
} else {
struct ceph_mds_client *mdsc =
-   ceph_sb_to_client(inode->i_sb)->mdsc;
+   ceph_sb_to_client(inode_sb(inode))->mdsc;
 
spin_lock(>i_ceph_lock);
if (__ceph_caps_dirty(ci))
@@ -3228,7 +3228,7 @@ static void handle_cap_flush_ack(struct inode *inode, u64 
flush_tid,
__releases(ci->i_ceph_lock)
 {
struct ceph_inode_info *ci = ceph_inode(inode);
-   struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc;
+   struct ceph_mds_client *mdsc = ceph_sb_to_client(inode_sb(inode))->mdsc;
struct ceph_cap_flush *cf, *tmp_cf;
LIST_HEAD(to_remove);
unsigned seq = le32_to_cpu(m->seq);
@@ -3331,7 +3331,7 @@ static void handle_cap_flushsnap_ack(struct inode *inode, 
u64 flush_tid,
 struct ceph_mds_session *session)
 {
struct ceph_inode_info *ci = ceph_inode(inode);
-   struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc;
+   struct ceph_mds_client *mdsc = ceph_sb_to_client(inode_sb(inode))->mdsc;
u64 follows = le64_to_cpu(m->snap_follows);
struct ceph_cap_snap *capsnap;
bool flushed = false;
diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
index f1d9c6cc0491..f41c584cdae7 100644
--- a/fs/ceph/dir.c
+++ b/fs/ceph/dir.c
@@ -317,7 +317,7 @@ static int 

[PATCH 18/76] fs/btrfs: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/btrfs/compression.c  |   4 +-
 fs/btrfs/ctree.h|   2 +-
 fs/btrfs/delayed-inode.c|   4 +-
 fs/btrfs/disk-io.c  |   8 +--
 fs/btrfs/export.c   |   4 +-
 fs/btrfs/extent-tree.c  |  14 ++---
 fs/btrfs/extent_io.c|  24 
 fs/btrfs/file-item.c|  10 ++--
 fs/btrfs/file.c |  30 +-
 fs/btrfs/free-space-cache.c |   6 +-
 fs/btrfs/inode.c| 133 ++--
 fs/btrfs/ioctl.c|  72 
 fs/btrfs/ordered-data.c |  12 ++--
 fs/btrfs/relocation.c   |   6 +-
 fs/btrfs/tree-log.c |   8 +--
 15 files changed, 169 insertions(+), 168 deletions(-)

diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index 07d049c0c20f..63ac953b18c3 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -312,7 +312,7 @@ blk_status_t btrfs_submit_compressed_write(struct inode 
*inode, u64 start,
 unsigned long nr_pages,
 unsigned int write_flags)
 {
-   struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+   struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
struct bio *bio = NULL;
struct compressed_bio *cb;
unsigned long bytes_left;
@@ -547,7 +547,7 @@ static noinline int add_ra_bio_pages(struct inode *inode,
 blk_status_t btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
 int mirror_num, unsigned long bio_flags)
 {
-   struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+   struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
struct extent_io_tree *tree;
struct extent_map_tree *em_tree;
struct compressed_bio *cb;
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index da308774b8a4..a3cca35642e2 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -1271,7 +1271,7 @@ struct btrfs_file_private {
 
 static inline u32 btrfs_inode_sectorsize(const struct inode *inode)
 {
-   return btrfs_sb(inode->i_sb)->sectorsize;
+   return btrfs_sb(inode_sb(inode))->sectorsize;
 }
 
 static inline u32 BTRFS_LEAF_DATA_SIZE(const struct btrfs_fs_info *info)
diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
index 0530f6f2e4ba..adc07604156e 100644
--- a/fs/btrfs/delayed-inode.c
+++ b/fs/btrfs/delayed-inode.c
@@ -1214,7 +1214,7 @@ int btrfs_commit_inode_delayed_items(struct 
btrfs_trans_handle *trans,
 
 int btrfs_commit_inode_delayed_inode(struct btrfs_inode *inode)
 {
-   struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb);
+   struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(>vfs_inode));
struct btrfs_trans_handle *trans;
struct btrfs_delayed_node *delayed_node = btrfs_get_delayed_node(inode);
struct btrfs_path *path;
@@ -1829,7 +1829,7 @@ int btrfs_delayed_update_inode(struct btrfs_trans_handle 
*trans,
 
 int btrfs_delayed_delete_inode_ref(struct btrfs_inode *inode)
 {
-   struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb);
+   struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(>vfs_inode));
struct btrfs_delayed_node *delayed_node;
 
/*
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 21f34ad0d411..334234da997c 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -226,7 +226,7 @@ struct extent_map *btree_get_extent(struct btrfs_inode 
*inode,
struct page *page, size_t pg_offset, u64 start, u64 len,
int create)
 {
-   struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb);
+   struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(>vfs_inode));
struct extent_map_tree *em_tree = >extent_tree;
struct extent_map *em;
int ret;
@@ -829,7 +829,7 @@ static blk_status_t __btree_submit_bio_done(void 
*private_data, struct bio *bio,
 * when we're called for a write, we're already in the async
 * submission context.  Just jump into btrfs_map_bio
 */
-   ret = btrfs_map_bio(btrfs_sb(inode->i_sb), bio, mirror_num, 1);
+   ret = btrfs_map_bio(btrfs_sb(inode_sb(inode)), bio, mirror_num, 1);
if (ret) {
bio->bi_status = ret;
bio_endio(bio);
@@ -853,7 +853,7 @@ static blk_status_t btree_submit_bio_hook(void 
*private_data, struct bio *bio,
  u64 bio_offset)
 {
struct inode *inode = private_data;
-   struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
+   struct btrfs_fs_info *fs_info = btrfs_sb(inode_sb(inode));
int async = check_async_write(BTRFS_I(inode));
blk_status_t ret;
 
@@ -4438,7 +4438,7 @@ static int btrfs_cleanup_transaction(struct btrfs_fs_info 
*fs_info)
 static struct btrfs_fs_info *btree_fs_info(void *private_data)
 {
struct inode *inode = private_data;
-   return 

[PATCH 20/76] fs/cifs: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/cifs/cifsacl.c   |  4 ++--
 fs/cifs/cifsfs.c|  4 ++--
 fs/cifs/cifsglob.h  |  2 +-
 fs/cifs/dir.c   | 29 -
 fs/cifs/file.c  | 42 ++
 fs/cifs/fscache.c   |  4 ++--
 fs/cifs/inode.c | 43 +++
 fs/cifs/ioctl.c |  2 +-
 fs/cifs/link.c  | 10 +-
 fs/cifs/readdir.c   |  2 +-
 fs/cifs/smb1ops.c   |  4 ++--
 fs/cifs/smb2inode.c |  2 +-
 fs/cifs/smb2ops.c   |  4 ++--
 13 files changed, 80 insertions(+), 72 deletions(-)

diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c
index 13a8a77322c9..d7b37ff7d57f 100644
--- a/fs/cifs/cifsacl.c
+++ b/fs/cifs/cifsacl.c
@@ -1081,7 +1081,7 @@ int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen,
unsigned int xid;
int rc, access_flags, create_options = 0;
struct cifs_tcon *tcon;
-   struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
+   struct cifs_sb_info *cifs_sb = CIFS_SB(inode_sb(inode));
struct tcon_link *tlink = cifs_sb_tlink(cifs_sb);
struct cifs_fid fid;
struct cifs_open_parms oparms;
@@ -1178,7 +1178,7 @@ id_mode_to_cifs_acl(struct inode *inode, const char 
*path, __u64 nmode,
__u32 secdesclen = 0;
struct cifs_ntsd *pntsd = NULL; /* acl obtained from server */
struct cifs_ntsd *pnntsd = NULL; /* modified acl to be sent to server */
-   struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
+   struct cifs_sb_info *cifs_sb = CIFS_SB(inode_sb(inode));
struct tcon_link *tlink = cifs_sb_tlink(cifs_sb);
struct smb_version_operations *ops;
 
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 32cdea67bbfd..54741739c5e6 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -231,7 +231,7 @@ static int cifs_permission(struct inode *inode, int mask)
 {
struct cifs_sb_info *cifs_sb;
 
-   cifs_sb = CIFS_SB(inode->i_sb);
+   cifs_sb = CIFS_SB(inode_sb(inode));
 
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM) {
if ((mask & MAY_EXEC) && !execute_ok(inode))
@@ -581,7 +581,7 @@ static int cifs_remount(struct super_block *sb, int *flags, 
char *data)
 
 static int cifs_drop_inode(struct inode *inode)
 {
-   struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
+   struct cifs_sb_info *cifs_sb = CIFS_SB(inode_sb(inode));
 
/* no serverino => unconditional eviction */
return !(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) ||
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index 48f7c197cd2d..35910ece3526 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -1265,7 +1265,7 @@ CIFS_SB(struct super_block *sb)
 static inline struct cifs_sb_info *
 CIFS_FILE_SB(struct file *file)
 {
-   return CIFS_SB(file_inode(file)->i_sb);
+   return CIFS_SB(inode_sb(file_inode(file)));
 }
 
 static inline char CIFS_DIR_SEP(const struct cifs_sb_info *cifs_sb)
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index 81ba6e0d88d8..201ec5c3d4fe 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -231,7 +231,7 @@ cifs_do_create(struct inode *inode, struct dentry 
*direntry, unsigned int xid,
int rc = -ENOENT;
int create_options = CREATE_NOT_DIR;
int desired_access;
-   struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
+   struct cifs_sb_info *cifs_sb = CIFS_SB(inode_sb(inode));
struct cifs_tcon *tcon = tlink_tcon(tlink);
char *full_path = NULL;
FILE_ALL_INFO *buf = NULL;
@@ -253,7 +253,8 @@ cifs_do_create(struct inode *inode, struct dentry 
*direntry, unsigned int xid,
if (tcon->unix_ext && cap_unix(tcon->ses) && !tcon->broken_posix_open &&
(CIFS_UNIX_POSIX_PATH_OPS_CAP &
le64_to_cpu(tcon->fsUnixInfo.Capability))) {
-   rc = cifs_posix_open(full_path, , inode->i_sb, mode,
+   rc = cifs_posix_open(full_path, , inode_sb(inode),
+mode,
 oflags, oplock, >netfid, xid);
switch (rc) {
case 0:
@@ -414,10 +415,12 @@ cifs_do_create(struct inode *inode, struct dentry 
*direntry, unsigned int xid,
 cifs_create_get_file_info:
/* server might mask mode so we have to query for it */
if (tcon->unix_ext)
-   rc = cifs_get_inode_info_unix(, full_path, inode->i_sb,
+   rc = cifs_get_inode_info_unix(, full_path,
+ inode_sb(inode),
  xid);
else {
-   rc = cifs_get_inode_info(, full_path, buf, inode->i_sb,
+   rc = cifs_get_inode_info(, full_path, buf,
+inode_sb(inode),
 xid, fid);
if (newinode) {
if (server->ops->set_lease_key)
@@ -511,7 +514,7 @@ 

[PATCH 17/76] fs/bfs: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/bfs/dir.c   | 23 ---
 fs/bfs/file.c  |  4 ++--
 fs/bfs/inode.c | 16 +---
 3 files changed, 23 insertions(+), 20 deletions(-)

diff --git a/fs/bfs/dir.c b/fs/bfs/dir.c
index ee832ca5f734..124c1eedb53c 100644
--- a/fs/bfs/dir.c
+++ b/fs/bfs/dir.c
@@ -38,14 +38,14 @@ static int bfs_readdir(struct file *f, struct dir_context 
*ctx)
if (ctx->pos & (BFS_DIRENT_SIZE - 1)) {
printf("Bad f_pos=%08lx for %s:%08lx\n",
(unsigned long)ctx->pos,
-   dir->i_sb->s_id, dir->i_ino);
+   inode_sb(dir)->s_id, dir->i_ino);
return -EINVAL;
}
 
while (ctx->pos < dir->i_size) {
offset = ctx->pos & (BFS_BSIZE - 1);
block = BFS_I(dir)->i_sblock + (ctx->pos >> BFS_BSIZE_BITS);
-   bh = sb_bread(dir->i_sb, block);
+   bh = sb_bread(inode_sb(dir), block);
if (!bh) {
ctx->pos += BFS_BSIZE - offset;
continue;
@@ -81,7 +81,7 @@ static int bfs_create(struct inode *dir, struct dentry 
*dentry, umode_t mode,
 {
int err;
struct inode *inode;
-   struct super_block *s = dir->i_sb;
+   struct super_block *s = inode_sb(dir);
struct bfs_sb_info *info = BFS_SB(s);
unsigned long ino;
 
@@ -130,7 +130,7 @@ static struct dentry *bfs_lookup(struct inode *dir, struct 
dentry *dentry,
struct inode *inode = NULL;
struct buffer_head *bh;
struct bfs_dirent *de;
-   struct bfs_sb_info *info = BFS_SB(dir->i_sb);
+   struct bfs_sb_info *info = BFS_SB(inode_sb(dir));
 
if (dentry->d_name.len > BFS_NAMELEN)
return ERR_PTR(-ENAMETOOLONG);
@@ -140,7 +140,7 @@ static struct dentry *bfs_lookup(struct inode *dir, struct 
dentry *dentry,
if (bh) {
unsigned long ino = (unsigned long)le16_to_cpu(de->ino);
brelse(bh);
-   inode = bfs_iget(dir->i_sb, ino);
+   inode = bfs_iget(inode_sb(dir), ino);
if (IS_ERR(inode)) {
mutex_unlock(>bfs_lock);
return ERR_CAST(inode);
@@ -155,7 +155,7 @@ static int bfs_link(struct dentry *old, struct inode *dir,
struct dentry *new)
 {
struct inode *inode = d_inode(old);
-   struct bfs_sb_info *info = BFS_SB(inode->i_sb);
+   struct bfs_sb_info *info = BFS_SB(inode_sb(inode));
int err;
 
mutex_lock(>bfs_lock);
@@ -180,7 +180,7 @@ static int bfs_unlink(struct inode *dir, struct dentry 
*dentry)
struct inode *inode = d_inode(dentry);
struct buffer_head *bh;
struct bfs_dirent *de;
-   struct bfs_sb_info *info = BFS_SB(inode->i_sb);
+   struct bfs_sb_info *info = BFS_SB(inode_sb(inode));
 
mutex_lock(>bfs_lock);
bh = bfs_find_entry(dir, dentry->d_name.name, dentry->d_name.len, );
@@ -189,7 +189,7 @@ static int bfs_unlink(struct inode *dir, struct dentry 
*dentry)
 
if (!inode->i_nlink) {
printf("unlinking non-existent file %s:%lu (nlink=%d)\n",
-   inode->i_sb->s_id, inode->i_ino,
+   inode_sb(inode)->s_id, inode->i_ino,
inode->i_nlink);
set_nlink(inode, 1);
}
@@ -225,7 +225,7 @@ static int bfs_rename(struct inode *old_dir, struct dentry 
*old_dentry,
if (S_ISDIR(old_inode->i_mode))
return -EINVAL;
 
-   info = BFS_SB(old_inode->i_sb);
+   info = BFS_SB(inode_sb(old_inode));
 
mutex_lock(>bfs_lock);
old_bh = bfs_find_entry(old_dir, 
@@ -296,7 +296,7 @@ static int bfs_add_entry(struct inode *dir, const unsigned 
char *name,
sblock = BFS_I(dir)->i_sblock;
eblock = BFS_I(dir)->i_eblock;
for (block = sblock; block <= eblock; block++) {
-   bh = sb_bread(dir->i_sb, block);
+   bh = sb_bread(inode_sb(dir), block);
if (!bh)
return -EIO;
for (off = 0; off < BFS_BSIZE; off += BFS_DIRENT_SIZE) {
@@ -345,7 +345,8 @@ static struct buffer_head *bfs_find_entry(struct inode *dir,
 
while (block * BFS_BSIZE + offset < dir->i_size) {
if (!bh) {
-   bh = sb_bread(dir->i_sb, BFS_I(dir)->i_sblock + block);
+   bh = sb_bread(inode_sb(dir),
+ BFS_I(dir)->i_sblock + block);
if (!bh) {
block++;
continue;
diff --git a/fs/bfs/file.c b/fs/bfs/file.c
index 1476cdd90cfb..159ef9ebca2d 100644
--- a/fs/bfs/file.c
+++ b/fs/bfs/file.c
@@ -66,7 +66,7 @@ static int 

[PATCH 21/76] fs/coda: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/coda/dir.c | 25 +
 fs/coda/file.c|  7 ---
 fs/coda/inode.c   |  4 ++--
 fs/coda/pioctl.c  |  4 ++--
 fs/coda/symlink.c |  2 +-
 5 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/fs/coda/dir.c b/fs/coda/dir.c
index 00876ddadb43..89deb3532f5e 100644
--- a/fs/coda/dir.c
+++ b/fs/coda/dir.c
@@ -40,7 +40,7 @@ static int coda_return_EIO(void)
 /* access routines: lookup, readlink, permission */
 static struct dentry *coda_lookup(struct inode *dir, struct dentry *entry, 
unsigned int flags)
 {
-   struct super_block *sb = dir->i_sb;
+   struct super_block *sb = inode_sb(dir);
const char *name = entry->d_name.name;
size_t length = entry->d_name.len;
struct inode *inode;
@@ -91,7 +91,7 @@ int coda_permission(struct inode *inode, int mask)
if (coda_cache_check(inode, mask))
return 0;
 
-   error = venus_access(inode->i_sb, coda_i2f(inode), mask);
+   error = venus_access(inode_sb(inode), coda_i2f(inode), mask);
 
if (!error)
coda_cache_enter(inode, mask);
@@ -144,12 +144,12 @@ static int coda_create(struct inode *dir, struct dentry 
*de, umode_t mode, bool
if (is_root_inode(dir) && coda_iscontrol(name, length))
return -EPERM;
 
-   error = venus_create(dir->i_sb, coda_i2f(dir), name, length, 
+   error = venus_create(inode_sb(dir), coda_i2f(dir), name, length, 
0, mode, , );
if (error)
goto err_out;
 
-   inode = coda_iget(dir->i_sb, , );
+   inode = coda_iget(inode_sb(dir), , );
if (IS_ERR(inode)) {
error = PTR_ERR(inode);
goto err_out;
@@ -177,12 +177,12 @@ static int coda_mkdir(struct inode *dir, struct dentry 
*de, umode_t mode)
return -EPERM;
 
attrs.va_mode = mode;
-   error = venus_mkdir(dir->i_sb, coda_i2f(dir), 
+   error = venus_mkdir(inode_sb(dir), coda_i2f(dir), 
   name, len, , );
if (error)
goto err_out;
  
-   inode = coda_iget(dir->i_sb, , );
+   inode = coda_iget(inode_sb(dir), , );
if (IS_ERR(inode)) {
error = PTR_ERR(inode);
goto err_out;
@@ -210,7 +210,7 @@ static int coda_link(struct dentry *source_de, struct inode 
*dir_inode,
if (is_root_inode(dir_inode) && coda_iscontrol(name, len))
return -EPERM;
 
-   error = venus_link(dir_inode->i_sb, coda_i2f(inode),
+   error = venus_link(inode_sb(dir_inode), coda_i2f(inode),
   coda_i2f(dir_inode), (const char *)name, len);
if (error) {
d_drop(de);
@@ -245,7 +245,8 @@ static int coda_symlink(struct inode *dir_inode, struct 
dentry *de,
 * an inode for the entry we have to drop it.
 */
d_drop(de);
-   error = venus_symlink(dir_inode->i_sb, coda_i2f(dir_inode), name, len,
+   error = venus_symlink(inode_sb(dir_inode), coda_i2f(dir_inode), name,
+ len,
  symname, symlen);
 
/* mtime is no good anymore */
@@ -262,7 +263,7 @@ static int coda_unlink(struct inode *dir, struct dentry *de)
const char *name = de->d_name.name;
int len = de->d_name.len;
 
-   error = venus_remove(dir->i_sb, coda_i2f(dir), name, len);
+   error = venus_remove(inode_sb(dir), coda_i2f(dir), name, len);
if (error)
return error;
 
@@ -277,7 +278,7 @@ static int coda_rmdir(struct inode *dir, struct dentry *de)
int len = de->d_name.len;
int error;
 
-   error = venus_rmdir(dir->i_sb, coda_i2f(dir), name, len);
+   error = venus_rmdir(inode_sb(dir), coda_i2f(dir), name, len);
if (!error) {
/* VFS may delete the child */
if (d_really_is_positive(de))
@@ -304,7 +305,7 @@ static int coda_rename(struct inode *old_dir, struct dentry 
*old_dentry,
if (flags)
return -EINVAL;
 
-   error = venus_rename(old_dir->i_sb, coda_i2f(old_dir),
+   error = venus_rename(inode_sb(old_dir), coda_i2f(old_dir),
 coda_i2f(new_dir), old_length, new_length,
 (const char *) old_name, (const char *)new_name);
if (!error) {
@@ -529,7 +530,7 @@ int coda_revalidate_inode(struct inode *inode)
return 0;
 
if (cii->c_flags & (C_VATTR | C_PURGE | C_FLUSH)) {
-   error = venus_getattr(inode->i_sb, &(cii->c_fid), );
+   error = venus_getattr(inode_sb(inode), &(cii->c_fid), );
if (error)
return -EIO;
 
diff --git a/fs/coda/file.c b/fs/coda/file.c
index 1cbc1f2298ee..6f84de9d1197 100644
--- a/fs/coda/file.c
+++ b/fs/coda/file.c
@@ -112,7 +112,8 @@ int coda_open(struct inode *coda_inode, struct file 

[PATCH 22/76] fs/configfs: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/configfs/inode.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/configfs/inode.c b/fs/configfs/inode.c
index ad718e5e37bb..4f28a7445336 100644
--- a/fs/configfs/inode.c
+++ b/fs/configfs/inode.c
@@ -91,13 +91,13 @@ int configfs_setattr(struct dentry * dentry, struct iattr * 
iattr)
sd_iattr->ia_gid = iattr->ia_gid;
if (ia_valid & ATTR_ATIME)
sd_iattr->ia_atime = timespec_trunc(iattr->ia_atime,
-   inode->i_sb->s_time_gran);
+   inode_sb(inode)->s_time_gran);
if (ia_valid & ATTR_MTIME)
sd_iattr->ia_mtime = timespec_trunc(iattr->ia_mtime,
-   inode->i_sb->s_time_gran);
+   inode_sb(inode)->s_time_gran);
if (ia_valid & ATTR_CTIME)
sd_iattr->ia_ctime = timespec_trunc(iattr->ia_ctime,
-   inode->i_sb->s_time_gran);
+   inode_sb(inode)->s_time_gran);
if (ia_valid & ATTR_MODE) {
umode_t mode = iattr->ia_mode;
 
-- 
2.15.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 24/76] fs/crypto: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/crypto/bio.c | 10 +-
 fs/crypto/crypto.c  |  4 ++--
 fs/crypto/fname.c   |  4 ++--
 fs/crypto/keyinfo.c |  8 
 fs/crypto/policy.c  | 12 ++--
 5 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/fs/crypto/bio.c b/fs/crypto/bio.c
index 0d5e6a569d58..0f7daacfa3de 100644
--- a/fs/crypto/bio.c
+++ b/fs/crypto/bio.c
@@ -92,7 +92,7 @@ int fscrypt_zeroout_range(const struct inode *inode, pgoff_t 
lblk,
struct bio *bio;
int ret, err = 0;
 
-   BUG_ON(inode->i_sb->s_blocksize != PAGE_SIZE);
+   BUG_ON(inode_sb(inode)->s_blocksize != PAGE_SIZE);
 
ctx = fscrypt_get_ctx(inode, GFP_NOFS);
if (IS_ERR(ctx))
@@ -116,13 +116,13 @@ int fscrypt_zeroout_range(const struct inode *inode, 
pgoff_t lblk,
err = -ENOMEM;
goto errout;
}
-   bio_set_dev(bio, inode->i_sb->s_bdev);
+   bio_set_dev(bio, inode_sb(inode)->s_bdev);
bio->bi_iter.bi_sector =
-   pblk << (inode->i_sb->s_blocksize_bits - 9);
+   pblk << (inode_sb(inode)->s_blocksize_bits - 9);
bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
ret = bio_add_page(bio, ciphertext_page,
-   inode->i_sb->s_blocksize, 0);
-   if (ret != inode->i_sb->s_blocksize) {
+   inode_sb(inode)->s_blocksize, 0);
+   if (ret != inode_sb(inode)->s_blocksize) {
/* should never happen! */
WARN_ON(1);
bio_put(bio);
diff --git a/fs/crypto/crypto.c b/fs/crypto/crypto.c
index ce654526c0fb..94b88687fe3f 100644
--- a/fs/crypto/crypto.c
+++ b/fs/crypto/crypto.c
@@ -240,7 +240,7 @@ struct page *fscrypt_encrypt_page(const struct inode *inode,
 
BUG_ON(len % FS_CRYPTO_BLOCK_SIZE != 0);
 
-   if (inode->i_sb->s_cop->flags & FS_CFLG_OWN_PAGES) {
+   if (inode_sb(inode)->s_cop->flags & FS_CFLG_OWN_PAGES) {
/* with inplace-encryption we just encrypt the page */
err = fscrypt_do_page_crypto(inode, FS_ENCRYPT, lblk_num, page,
 ciphertext_page, len, offs,
@@ -299,7 +299,7 @@ EXPORT_SYMBOL(fscrypt_encrypt_page);
 int fscrypt_decrypt_page(const struct inode *inode, struct page *page,
unsigned int len, unsigned int offs, u64 lblk_num)
 {
-   if (!(inode->i_sb->s_cop->flags & FS_CFLG_OWN_PAGES))
+   if (!(inode_sb(inode)->s_cop->flags & FS_CFLG_OWN_PAGES))
BUG_ON(!PageLocked(page));
 
return fscrypt_do_page_crypto(inode, FS_DECRYPT, lblk_num, page, page,
diff --git a/fs/crypto/fname.c b/fs/crypto/fname.c
index e33f3d3c5ade..cc0e7632e2d6 100644
--- a/fs/crypto/fname.c
+++ b/fs/crypto/fname.c
@@ -102,7 +102,7 @@ static int fname_decrypt(struct inode *inode,
char iv[FS_CRYPTO_BLOCK_SIZE];
unsigned lim;
 
-   lim = inode->i_sb->s_cop->max_namelen(inode);
+   lim = inode_sb(inode)->s_cop->max_namelen(inode);
if (iname->len <= 0 || iname->len > lim)
return -EIO;
 
@@ -346,7 +346,7 @@ int fscrypt_setup_filename(struct inode *dir, const struct 
qstr *iname,
 
if (dir->i_crypt_info) {
if (!fscrypt_fname_encrypted_size(dir, iname->len,
- 
dir->i_sb->s_cop->max_namelen(dir),
+ 
inode_sb(dir)->s_cop->max_namelen(dir),
  >crypto_buf.len))
return -ENAMETOOLONG;
fname->crypto_buf.name = kmalloc(fname->crypto_buf.len,
diff --git a/fs/crypto/keyinfo.c b/fs/crypto/keyinfo.c
index 05f5ee1f0705..13beafec4355 100644
--- a/fs/crypto/keyinfo.c
+++ b/fs/crypto/keyinfo.c
@@ -253,11 +253,11 @@ int fscrypt_get_encryption_info(struct inode *inode)
if (inode->i_crypt_info)
return 0;
 
-   res = fscrypt_initialize(inode->i_sb->s_cop->flags);
+   res = fscrypt_initialize(inode_sb(inode)->s_cop->flags);
if (res)
return res;
 
-   res = inode->i_sb->s_cop->get_context(inode, , sizeof(ctx));
+   res = inode_sb(inode)->s_cop->get_context(inode, , sizeof(ctx));
if (res < 0) {
if (!fscrypt_dummy_context_enabled(inode) ||
IS_ENCRYPTED(inode))
@@ -305,9 +305,9 @@ int fscrypt_get_encryption_info(struct inode *inode)
 
res = validate_user_key(crypt_info, , raw_key, FS_KEY_DESC_PREFIX,
keysize);
-   if (res && inode->i_sb->s_cop->key_prefix) {
+   if (res && inode_sb(inode)->s_cop->key_prefix) {
int res2 = validate_user_key(crypt_info, , raw_key,
-inode->i_sb->s_cop->key_prefix,
+

[PATCH 23/76] fs/cramfs: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/cramfs/inode.c | 19 ++-
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c
index 017b0ab19bc4..eb633de7ccbe 100644
--- a/fs/cramfs/inode.c
+++ b/fs/cramfs/inode.c
@@ -294,7 +294,7 @@ static void *cramfs_read(struct super_block *sb, unsigned 
int offset,
  */
 static u32 cramfs_get_block_range(struct inode *inode, u32 pgoff, u32 *pages)
 {
-   struct cramfs_sb_info *sbi = CRAMFS_SB(inode->i_sb);
+   struct cramfs_sb_info *sbi = CRAMFS_SB(inode_sb(inode));
int i;
u32 *blockptrs, first_block_addr;
 
@@ -335,7 +335,7 @@ static u32 cramfs_get_block_range(struct inode *inode, u32 
pgoff, u32 *pages)
  */
 static bool cramfs_last_page_is_shared(struct inode *inode)
 {
-   struct cramfs_sb_info *sbi = CRAMFS_SB(inode->i_sb);
+   struct cramfs_sb_info *sbi = CRAMFS_SB(inode_sb(inode));
u32 partial, last_page, blockaddr, *blockptrs;
char *tail_data;
 
@@ -353,7 +353,7 @@ static bool cramfs_last_page_is_shared(struct inode *inode)
 static int cramfs_physmem_mmap(struct file *file, struct vm_area_struct *vma)
 {
struct inode *inode = file_inode(file);
-   struct cramfs_sb_info *sbi = CRAMFS_SB(inode->i_sb);
+   struct cramfs_sb_info *sbi = CRAMFS_SB(inode_sb(inode));
unsigned int pages, max_pages, offset;
unsigned long address, pgoff = vma->vm_pgoff;
char *bailout_reason;
@@ -451,7 +451,7 @@ static unsigned long 
cramfs_physmem_get_unmapped_area(struct file *file,
unsigned long pgoff, unsigned long flags)
 {
struct inode *inode = file_inode(file);
-   struct super_block *sb = inode->i_sb;
+   struct super_block *sb = inode_sb(inode);
struct cramfs_sb_info *sbi = CRAMFS_SB(sb);
unsigned int pages, block_pages, max_pages, offset;
 
@@ -696,7 +696,7 @@ static int cramfs_statfs(struct dentry *dentry, struct 
kstatfs *buf)
 static int cramfs_readdir(struct file *file, struct dir_context *ctx)
 {
struct inode *inode = file_inode(file);
-   struct super_block *sb = inode->i_sb;
+   struct super_block *sb = inode_sb(inode);
char *buf;
unsigned int offset;
 
@@ -763,14 +763,15 @@ static struct dentry *cramfs_lookup(struct inode *dir, 
struct dentry *dentry, un
int sorted;
 
mutex_lock(_mutex);
-   sorted = CRAMFS_SB(dir->i_sb)->flags & CRAMFS_FLAG_SORTED_DIRS;
+   sorted = CRAMFS_SB(inode_sb(dir))->flags & CRAMFS_FLAG_SORTED_DIRS;
while (offset < dir->i_size) {
struct cramfs_inode *de;
char *name;
int namelen, retval;
int dir_off = OFFSET(dir) + offset;
 
-   de = cramfs_read(dir->i_sb, dir_off, 
sizeof(*de)+CRAMFS_MAXPATHLEN);
+   de = cramfs_read(inode_sb(dir), dir_off,
+sizeof(*de)+CRAMFS_MAXPATHLEN);
name = (char *)(de+1);
 
/* Try to take advantage of sorted directories */
@@ -799,7 +800,7 @@ static struct dentry *cramfs_lookup(struct inode *dir, 
struct dentry *dentry, un
if (retval > 0)
continue;
if (!retval) {
-   inode = get_cramfs_inode(dir->i_sb, de, dir_off);
+   inode = get_cramfs_inode(inode_sb(dir), de, dir_off);
break;
}
/* else (retval < 0) */
@@ -826,7 +827,7 @@ static int cramfs_readpage(struct file *file, struct page 
*page)
pgdata = kmap(page);
 
if (page->index < maxblock) {
-   struct super_block *sb = inode->i_sb;
+   struct super_block *sb = inode_sb(inode);
u32 blkptr_offset = OFFSET(inode) + page->index * 4;
u32 block_ptr, block_start, block_len;
bool uncompressed, direct;
-- 
2.15.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 25/76] fs/ecryptfs: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/ecryptfs/crypto.c |  5 ++---
 fs/ecryptfs/file.c   |  5 ++---
 fs/ecryptfs/inode.c  | 15 +++
 3 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
index 846ca150d52e..ae979420d9d1 100644
--- a/fs/ecryptfs/crypto.c
+++ b/fs/ecryptfs/crypto.c
@@ -800,8 +800,7 @@ int ecryptfs_new_file_context(struct inode *ecryptfs_inode)
struct ecryptfs_crypt_stat *crypt_stat =
_inode_to_private(ecryptfs_inode)->crypt_stat;
struct ecryptfs_mount_crypt_stat *mount_crypt_stat =
-   _superblock_to_private(
-   ecryptfs_inode->i_sb)->mount_crypt_stat;
+   
_superblock_to_private(inode_sb(ecryptfs_inode))->mount_crypt_stat;
int cipher_name_len;
int rc = 0;
 
@@ -1263,7 +1262,7 @@ void ecryptfs_i_size_init(const char *page_virt, struct 
inode *inode)
 
crypt_stat = _inode_to_private(inode)->crypt_stat;
mount_crypt_stat =
-   _superblock_to_private(inode->i_sb)->mount_crypt_stat;
+   
_superblock_to_private(inode_sb(inode))->mount_crypt_stat;
if (mount_crypt_stat->flags & ECRYPTFS_ENCRYPTED_VIEW_ENABLED) {
file_size = i_size_read(ecryptfs_inode_to_lower(inode));
if (crypt_stat->flags & ECRYPTFS_METADATA_IN_XATTR)
diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c
index c74ed3ca3372..0fa5050bcbc2 100644
--- a/fs/ecryptfs/file.c
+++ b/fs/ecryptfs/file.c
@@ -109,7 +109,7 @@ static int ecryptfs_readdir(struct file *file, struct 
dir_context *ctx)
struct ecryptfs_getdents_callback buf = {
.ctx.actor = ecryptfs_filldir,
.caller = ctx,
-   .sb = inode->i_sb,
+   .sb = inode_sb(inode),
};
lower_file = ecryptfs_file_to_lower(file);
rc = iterate_dir(lower_file, );
@@ -135,8 +135,7 @@ static int read_or_initialize_metadata(struct dentry 
*dentry)
int rc;
 
crypt_stat = _inode_to_private(inode)->crypt_stat;
-   mount_crypt_stat = _superblock_to_private(
-   inode->i_sb)->mount_crypt_stat;
+   mount_crypt_stat = 
_superblock_to_private(inode_sb(inode))->mount_crypt_stat;
mutex_lock(_stat->cs_mutex);
 
if (crypt_stat->flags & ECRYPTFS_POLICY_APPLIED &&
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index 847904aa63a9..ea205c666f5b 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -88,7 +88,7 @@ static struct inode *__ecryptfs_get_inode(struct inode 
*lower_inode,
 {
struct inode *inode;
 
-   if (lower_inode->i_sb != ecryptfs_superblock_to_lower(sb))
+   if (inode_sb(lower_inode) != ecryptfs_superblock_to_lower(sb))
return ERR_PTR(-EXDEV);
if (!igrab(lower_inode))
return ERR_PTR(-ESTALE);
@@ -194,7 +194,7 @@ ecryptfs_do_create(struct inode *directory_inode,
goto out_lock;
}
inode = __ecryptfs_get_inode(d_inode(lower_dentry),
-directory_inode->i_sb);
+inode_sb(directory_inode));
if (IS_ERR(inode)) {
vfs_unlink(d_inode(lower_dir_dentry), lower_dentry, NULL);
goto out_lock;
@@ -441,7 +441,7 @@ static int ecryptfs_link(struct dentry *old_dentry, struct 
inode *dir,
  lower_new_dentry, NULL);
if (rc || d_really_is_negative(lower_new_dentry))
goto out_lock;
-   rc = ecryptfs_interpose(lower_new_dentry, new_dentry, dir->i_sb);
+   rc = ecryptfs_interpose(lower_new_dentry, new_dentry, inode_sb(dir));
if (rc)
goto out_lock;
fsstack_copy_attr_times(dir, d_inode(lower_dir_dentry));
@@ -474,8 +474,7 @@ static int ecryptfs_symlink(struct inode *dir, struct 
dentry *dentry,
lower_dentry = ecryptfs_dentry_to_lower(dentry);
dget(lower_dentry);
lower_dir_dentry = lock_parent(lower_dentry);
-   mount_crypt_stat = _superblock_to_private(
-   dir->i_sb)->mount_crypt_stat;
+   mount_crypt_stat = 
_superblock_to_private(inode_sb(dir))->mount_crypt_stat;
rc = ecryptfs_encrypt_and_encode_filename(_symname,
  _symlen,
  mount_crypt_stat, symname,
@@ -487,7 +486,7 @@ static int ecryptfs_symlink(struct inode *dir, struct 
dentry *dentry,
kfree(encoded_symname);
if (rc || d_really_is_negative(lower_dentry))
goto out_lock;
-   rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb);
+   rc = ecryptfs_interpose(lower_dentry, dentry, inode_sb(dir));
if (rc)
goto out_lock;
fsstack_copy_attr_times(dir, d_inode(lower_dir_dentry));
@@ -511,7 +510,7 @@ static int ecryptfs_mkdir(struct inode *dir, struct dentry 
*dentry, 

[PATCH 29/76] fs/exportfs: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/exportfs/expfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/exportfs/expfs.c b/fs/exportfs/expfs.c
index 329a5d103846..d0ce48374bda 100644
--- a/fs/exportfs/expfs.c
+++ b/fs/exportfs/expfs.c
@@ -383,7 +383,7 @@ static int export_encode_fh(struct inode *inode, struct fid 
*fid,
 int exportfs_encode_inode_fh(struct inode *inode, struct fid *fid,
 int *max_len, struct inode *parent)
 {
-   const struct export_operations *nop = inode->i_sb->s_export_op;
+   const struct export_operations *nop = inode_sb(inode)->s_export_op;
 
if (nop && nop->encode_fh)
return nop->encode_fh(inode, fid->raw, max_len, parent);
-- 
2.15.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 26/76] fs/efivarfs: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/efivarfs/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/efivarfs/inode.c b/fs/efivarfs/inode.c
index 71ff317e..5e0de72476bf 100644
--- a/fs/efivarfs/inode.c
+++ b/fs/efivarfs/inode.c
@@ -92,7 +92,7 @@ static int efivarfs_create(struct inode *dir, struct dentry 
*dentry,
 dentry->d_name.name, namelen))
is_removable = true;
 
-   inode = efivarfs_get_inode(dir->i_sb, dir, mode, 0, is_removable);
+   inode = efivarfs_get_inode(inode_sb(dir), dir, mode, 0, is_removable);
if (!inode) {
err = -ENOMEM;
goto out;
-- 
2.15.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 30/76] fs/ext2: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/ext2/balloc.c | 10 +++
 fs/ext2/dir.c| 32 ++--
 fs/ext2/file.c   |  6 ++--
 fs/ext2/ialloc.c | 16 +-
 fs/ext2/inode.c  | 82 +++-
 fs/ext2/ioctl.c  |  4 +--
 fs/ext2/namei.c  | 14 -
 fs/ext2/xattr.c  | 59 ++---
 fs/ext2/xattr_user.c |  4 +--
 9 files changed, 115 insertions(+), 112 deletions(-)

diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
index 33db13365c5e..0ac54114ea9a 100644
--- a/fs/ext2/balloc.c
+++ b/fs/ext2/balloc.c
@@ -413,7 +413,7 @@ void ext2_init_block_alloc_info(struct inode *inode)
 {
struct ext2_inode_info *ei = EXT2_I(inode);
struct ext2_block_alloc_info *block_i;
-   struct super_block *sb = inode->i_sb;
+   struct super_block *sb = inode_sb(inode);
 
block_i = kmalloc(sizeof(*block_i), GFP_NOFS);
if (block_i) {
@@ -455,7 +455,7 @@ void ext2_discard_reservation(struct inode *inode)
struct ext2_inode_info *ei = EXT2_I(inode);
struct ext2_block_alloc_info *block_i = ei->i_block_alloc_info;
struct ext2_reserve_window_node *rsv;
-   spinlock_t *rsv_lock = _SB(inode->i_sb)->s_rsv_window_lock;
+   spinlock_t *rsv_lock = _SB(inode_sb(inode))->s_rsv_window_lock;
 
if (!block_i)
return;
@@ -464,7 +464,7 @@ void ext2_discard_reservation(struct inode *inode)
if (!rsv_is_empty(>rsv_window)) {
spin_lock(rsv_lock);
if (!rsv_is_empty(>rsv_window))
-   rsv_window_remove(inode->i_sb, rsv);
+   rsv_window_remove(inode_sb(inode), rsv);
spin_unlock(rsv_lock);
}
 }
@@ -484,7 +484,7 @@ void ext2_free_blocks (struct inode * inode, unsigned long 
block,
unsigned long bit;
unsigned long i;
unsigned long overflow;
-   struct super_block * sb = inode->i_sb;
+   struct super_block * sb = inode_sb(inode);
struct ext2_sb_info * sbi = EXT2_SB(sb);
struct ext2_group_desc * desc;
struct ext2_super_block * es = sbi->s_es;
@@ -1255,7 +1255,7 @@ ext2_fsblk_t ext2_new_blocks(struct inode *inode, 
ext2_fsblk_t goal,
int ret;
 
*errp = -ENOSPC;
-   sb = inode->i_sb;
+   sb = inode_sb(inode);
 
/*
 * Check quota for allocation of this block.
diff --git a/fs/ext2/dir.c b/fs/ext2/dir.c
index 3b8114def693..b9565d7b86e8 100644
--- a/fs/ext2/dir.c
+++ b/fs/ext2/dir.c
@@ -63,7 +63,7 @@ static inline __le16 ext2_rec_len_to_disk(unsigned len)
  */
 static inline unsigned ext2_chunk_size(struct inode *inode)
 {
-   return inode->i_sb->s_blocksize;
+   return inode_sb(inode)->s_blocksize;
 }
 
 static inline void ext2_put_page(struct page *page)
@@ -115,7 +115,7 @@ static int ext2_commit_chunk(struct page *page, loff_t pos, 
unsigned len)
 static bool ext2_check_page(struct page *page, int quiet)
 {
struct inode *dir = page->mapping->host;
-   struct super_block *sb = dir->i_sb;
+   struct super_block *sb = inode_sb(dir);
unsigned chunk_size = ext2_chunk_size(dir);
char *kaddr = page_address(page);
u32 max_inumber = le32_to_cpu(EXT2_SB(sb)->s_es->s_inodes_count);
@@ -277,7 +277,7 @@ static unsigned char ext2_type_by_mode[S_IFMT >> S_SHIFT] = 
{
 static inline void ext2_set_de_type(ext2_dirent *de, struct inode *inode)
 {
umode_t mode = inode->i_mode;
-   if (EXT2_HAS_INCOMPAT_FEATURE(inode->i_sb, 
EXT2_FEATURE_INCOMPAT_FILETYPE))
+   if (EXT2_HAS_INCOMPAT_FEATURE(inode_sb(inode), 
EXT2_FEATURE_INCOMPAT_FILETYPE))
de->file_type = ext2_type_by_mode[(mode & S_IFMT)>>S_SHIFT];
else
de->file_type = 0;
@@ -288,7 +288,7 @@ ext2_readdir(struct file *file, struct dir_context *ctx)
 {
loff_t pos = ctx->pos;
struct inode *inode = file_inode(file);
-   struct super_block *sb = inode->i_sb;
+   struct super_block *sb = inode_sb(inode);
unsigned int offset = pos & ~PAGE_MASK;
unsigned long n = pos >> PAGE_SHIFT;
unsigned long npages = dir_pages(inode);
@@ -392,8 +392,8 @@ struct ext2_dir_entry_2 *ext2_find_entry (struct inode *dir,
kaddr += ext2_last_byte(dir, n) - reclen;
while ((char *) de <= kaddr) {
if (de->rec_len == 0) {
-   ext2_error(dir->i_sb, __func__,
-   "zero-length directory entry");
+   ext2_error(inode_sb(dir), __func__,
+  "zero-length directory 
entry");
ext2_put_page(page);
goto out;
}
@@ -409,10 +409,10 @@ struct ext2_dir_entry_2 

[PATCH 32/76] fs/f2fs: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/f2fs/data.c |  6 +++---
 fs/f2fs/f2fs.h |  2 +-
 fs/f2fs/file.c | 36 ++--
 fs/f2fs/inline.c   |  4 ++--
 fs/f2fs/inode.c|  6 +++---
 fs/f2fs/namei.c| 11 ++-
 fs/f2fs/recovery.c | 11 ++-
 fs/f2fs/super.c|  6 +++---
 fs/f2fs/trace.c|  7 ---
 fs/f2fs/xattr.c|  4 ++--
 10 files changed, 48 insertions(+), 45 deletions(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 7578ed1a85e0..f3e29f386f6e 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -1129,7 +1129,7 @@ static int __get_data_block(struct inode *inode, sector_t 
iblock,
 
err = f2fs_map_blocks(inode, , create, flag);
if (!err) {
-   map_bh(bh, inode->i_sb, map.m_pblk);
+   map_bh(bh, inode_sb(inode), map.m_pblk);
bh->b_state = (bh->b_state & ~F2FS_MAP_FLAGS) | map.m_flags;
bh->b_size = (u64)map.m_len << inode->i_blkbits;
}
@@ -1225,7 +1225,7 @@ static int f2fs_xattr_fiemap(struct inode *inode,
get_node_info(sbi, xnid, );
 
phys = (__u64)blk_to_logical(inode, ni.blk_addr);
-   len = inode->i_sb->s_blocksize;
+   len = inode_sb(inode)->s_blocksize;
 
f2fs_put_page(page, 1);
 
@@ -2272,7 +2272,7 @@ static int f2fs_write_end(struct file *file,
 static int check_direct_IO(struct inode *inode, struct iov_iter *iter,
   loff_t offset)
 {
-   unsigned blocksize_mask = inode->i_sb->s_blocksize - 1;
+   unsigned blocksize_mask = inode_sb(inode)->s_blocksize - 1;
 
if (offset & blocksize_mask)
return -EINVAL;
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 6300ac5bcbe4..504c84b68636 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1331,7 +1331,7 @@ static inline struct f2fs_sb_info *F2FS_SB(struct 
super_block *sb)
 
 static inline struct f2fs_sb_info *F2FS_I_SB(struct inode *inode)
 {
-   return F2FS_SB(inode->i_sb);
+   return F2FS_SB(inode_sb(inode));
 }
 
 static inline struct f2fs_sb_info *F2FS_M_SB(struct address_space *mapping)
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 672a542e5464..837333b9153d 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -58,7 +58,7 @@ static int f2fs_vm_page_mkwrite(struct vm_fault *vmf)
goto err;
}
 
-   sb_start_pagefault(inode->i_sb);
+   sb_start_pagefault(inode_sb(inode));
 
f2fs_bug_on(sbi, f2fs_has_inline_data(inode));
 
@@ -117,7 +117,7 @@ static int f2fs_vm_page_mkwrite(struct vm_fault *vmf)
 out_sem:
up_read(_I(inode)->i_mmap_sem);
 out:
-   sb_end_pagefault(inode->i_sb);
+   sb_end_pagefault(inode_sb(inode));
f2fs_update_time(sbi, REQ_TIME);
 err:
return block_page_mkwrite_return(err);
@@ -211,7 +211,7 @@ static int f2fs_do_sync_file(struct file *file, loff_t 
start, loff_t end,
.for_reclaim = 0,
};
 
-   if (unlikely(f2fs_readonly(inode->i_sb)))
+   if (unlikely(f2fs_readonly(inode_sb(inode
return 0;
 
trace_f2fs_sync_file_enter(inode);
@@ -259,7 +259,7 @@ static int f2fs_do_sync_file(struct file *file, loff_t 
start, loff_t end,
 
if (cp_reason) {
/* all the dirty node pages should be flushed for POR */
-   ret = f2fs_sync_fs(inode->i_sb, 1);
+   ret = f2fs_sync_fs(inode_sb(inode), 1);
 
/*
 * We've secured consistency through sync_fs. Following pino
@@ -365,7 +365,7 @@ static bool __found_offset(block_t blkaddr, pgoff_t dirty, 
pgoff_t pgofs,
 static loff_t f2fs_seek_block(struct file *file, loff_t offset, int whence)
 {
struct inode *inode = file->f_mapping->host;
-   loff_t maxbytes = inode->i_sb->s_maxbytes;
+   loff_t maxbytes = inode_sb(inode)->s_maxbytes;
struct dnode_of_data dn;
pgoff_t pgofs, end_offset, dirty;
loff_t data_ofs = offset;
@@ -437,7 +437,7 @@ static loff_t f2fs_seek_block(struct file *file, loff_t 
offset, int whence)
 static loff_t f2fs_llseek(struct file *file, loff_t offset, int whence)
 {
struct inode *inode = file->f_mapping->host;
-   loff_t maxbytes = inode->i_sb->s_maxbytes;
+   loff_t maxbytes = inode_sb(inode)->s_maxbytes;
 
switch (whence) {
case SEEK_SET:
@@ -569,7 +569,7 @@ static int truncate_partial_data_page(struct inode *inode, 
u64 from,
 int truncate_blocks(struct inode *inode, u64 from, bool lock)
 {
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
-   unsigned int blocksize = inode->i_sb->s_blocksize;
+   unsigned int blocksize = inode_sb(inode)->s_blocksize;
struct dnode_of_data dn;
pgoff_t free_from;
int count = 0, err = 0;
@@ -676,7 +676,7 @@ int f2fs_getattr(const struct path *path, struct kstat 
*stat,
unsigned int flags;
 
if (f2fs_has_extra_attr(inode) &&
-  

[PATCH 28/76] fs/exofs: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/exofs/dir.c   |  6 +++---
 fs/exofs/inode.c | 12 ++--
 fs/exofs/namei.c |  4 ++--
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/fs/exofs/dir.c b/fs/exofs/dir.c
index f0138674c1ed..592471362243 100644
--- a/fs/exofs/dir.c
+++ b/fs/exofs/dir.c
@@ -36,7 +36,7 @@
 
 static inline unsigned exofs_chunk_size(struct inode *inode)
 {
-   return inode->i_sb->s_blocksize;
+   return inode_sb(inode)->s_blocksize;
 }
 
 static inline void exofs_put_page(struct page *page)
@@ -430,7 +430,7 @@ int exofs_add_link(struct dentry *dentry, struct inode 
*inode)
unsigned reclen = EXOFS_DIR_REC_LEN(namelen);
unsigned short rec_len, name_len;
struct page *page = NULL;
-   struct exofs_sb_info *sbi = inode->i_sb->s_fs_info;
+   struct exofs_sb_info *sbi = inode_sb(inode)->s_fs_info;
struct exofs_dir_entry *de;
unsigned long npages = dir_pages(dir);
unsigned long n;
@@ -520,7 +520,7 @@ int exofs_delete_entry(struct exofs_dir_entry *dir, struct 
page *page)
 {
struct address_space *mapping = page->mapping;
struct inode *inode = mapping->host;
-   struct exofs_sb_info *sbi = inode->i_sb->s_fs_info;
+   struct exofs_sb_info *sbi = inode_sb(inode)->s_fs_info;
char *kaddr = page_address(page);
unsigned from = ((char *)dir - kaddr) & ~(exofs_chunk_size(inode)-1);
unsigned to = ((char *)dir - kaddr) + le16_to_cpu(dir->rec_len);
diff --git a/fs/exofs/inode.c b/fs/exofs/inode.c
index 0ac62811b341..c52a83f76a7a 100644
--- a/fs/exofs/inode.c
+++ b/fs/exofs/inode.c
@@ -66,7 +66,7 @@ struct page_collect {
 static void _pcol_init(struct page_collect *pcol, unsigned expected_pages,
   struct inode *inode)
 {
-   struct exofs_sb_info *sbi = inode->i_sb->s_fs_info;
+   struct exofs_sb_info *sbi = inode_sb(inode)->s_fs_info;
 
pcol->sbi = sbi;
pcol->inode = inode;
@@ -996,7 +996,7 @@ static inline int exofs_inode_is_fast_symlink(struct inode 
*inode)
 static int _do_truncate(struct inode *inode, loff_t newsize)
 {
struct exofs_i_info *oi = exofs_i(inode);
-   struct exofs_sb_info *sbi = inode->i_sb->s_fs_info;
+   struct exofs_sb_info *sbi = inode_sb(inode)->s_fs_info;
int ret;
 
inode->i_mtime = inode->i_ctime = current_time(inode);
@@ -1256,7 +1256,7 @@ static void create_done(struct ore_io_state *ios, void *p)
 {
struct inode *inode = p;
struct exofs_i_info *oi = exofs_i(inode);
-   struct exofs_sb_info *sbi = inode->i_sb->s_fs_info;
+   struct exofs_sb_info *sbi = inode_sb(inode)->s_fs_info;
int ret;
 
ret = ore_check_io(ios, NULL);
@@ -1286,7 +1286,7 @@ static void create_done(struct ore_io_state *ios, void *p)
  */
 struct inode *exofs_new_inode(struct inode *dir, umode_t mode)
 {
-   struct super_block *sb = dir->i_sb;
+   struct super_block *sb = inode_sb(dir);
struct exofs_sb_info *sbi = sb->s_fs_info;
struct inode *inode;
struct exofs_i_info *oi;
@@ -1366,7 +1366,7 @@ static void updatei_done(struct ore_io_state *ios, void 
*p)
 static int exofs_update_inode(struct inode *inode, int do_sync)
 {
struct exofs_i_info *oi = exofs_i(inode);
-   struct super_block *sb = inode->i_sb;
+   struct super_block *sb = inode_sb(inode);
struct exofs_sb_info *sbi = sb->s_fs_info;
struct ore_io_state *ios;
struct osd_attr attr;
@@ -1468,7 +1468,7 @@ static void delete_done(struct ore_io_state *ios, void *p)
 void exofs_evict_inode(struct inode *inode)
 {
struct exofs_i_info *oi = exofs_i(inode);
-   struct super_block *sb = inode->i_sb;
+   struct super_block *sb = inode_sb(inode);
struct exofs_sb_info *sbi = sb->s_fs_info;
struct ore_io_state *ios;
int ret;
diff --git a/fs/exofs/namei.c b/fs/exofs/namei.c
index 7295cd722770..655400486da5 100644
--- a/fs/exofs/namei.c
+++ b/fs/exofs/namei.c
@@ -55,7 +55,7 @@ static struct dentry *exofs_lookup(struct inode *dir, struct 
dentry *dentry,
return ERR_PTR(-ENAMETOOLONG);
 
ino = exofs_inode_by_name(dir, dentry);
-   inode = ino ? exofs_iget(dir->i_sb, ino) : NULL;
+   inode = ino ? exofs_iget(inode_sb(dir), ino) : NULL;
return d_splice_alias(inode, dentry);
 }
 
@@ -93,7 +93,7 @@ static int exofs_mknod(struct inode *dir, struct dentry 
*dentry, umode_t mode,
 static int exofs_symlink(struct inode *dir, struct dentry *dentry,
  const char *symname)
 {
-   struct super_block *sb = dir->i_sb;
+   struct super_block *sb = inode_sb(dir);
int err = -ENAMETOOLONG;
unsigned l = strlen(symname)+1;
struct inode *inode;
-- 
2.15.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  

[PATCH 27/76] fs/efs: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/efs/dir.c | 2 +-
 fs/efs/file.c| 2 +-
 fs/efs/inode.c   | 6 +++---
 fs/efs/namei.c   | 4 ++--
 fs/efs/symlink.c | 4 ++--
 5 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/fs/efs/dir.c b/fs/efs/dir.c
index f892ac7c2a35..55663c4f49ce 100644
--- a/fs/efs/dir.c
+++ b/fs/efs/dir.c
@@ -42,7 +42,7 @@ static int efs_readdir(struct file *file, struct dir_context 
*ctx)
struct buffer_head *bh;
 
/* read the dir block */
-   bh = sb_bread(inode->i_sb, efs_bmap(inode, block));
+   bh = sb_bread(inode_sb(inode), efs_bmap(inode, block));
 
if (!bh) {
pr_err("%s(): failed to read dir block %d\n",
diff --git a/fs/efs/file.c b/fs/efs/file.c
index 9e641da6fab2..4e7cf6d70872 100644
--- a/fs/efs/file.c
+++ b/fs/efs/file.c
@@ -30,7 +30,7 @@ int efs_get_block(struct inode *inode, sector_t iblock,
}
phys = efs_map_block(inode, iblock);
if (phys)
-   map_bh(bh_result, inode->i_sb, phys);
+   map_bh(bh_result, inode_sb(inode), phys);
return 0;
 }
 
diff --git a/fs/efs/inode.c b/fs/efs/inode.c
index cdf0872382af..a62f6029fc1c 100644
--- a/fs/efs/inode.c
+++ b/fs/efs/inode.c
@@ -87,7 +87,7 @@ struct inode *efs_iget(struct super_block *super, unsigned 
long ino)
(EFS_BLOCKSIZE / sizeof(struct efs_dinode))) *
sizeof(struct efs_dinode);
 
-   bh = sb_bread(inode->i_sb, block);
+   bh = sb_bread(inode_sb(inode), block);
if (!bh) {
pr_warn("%s() failed at block %d\n", __func__, block);
goto read_inode_error;
@@ -196,7 +196,7 @@ efs_extent_check(efs_extent *ptr, efs_block_t block, struct 
efs_sb_info *sb) {
 }
 
 efs_block_t efs_map_block(struct inode *inode, efs_block_t block) {
-   struct efs_sb_info*sb = SUPER_INFO(inode->i_sb);
+   struct efs_sb_info*sb = SUPER_INFO(inode_sb(inode));
struct efs_inode_info *in = INODE_INFO(inode);
struct buffer_head*bh = NULL;
 
@@ -275,7 +275,7 @@ efs_block_t efs_map_block(struct inode *inode, efs_block_t 
block) {
if (first || lastblock != iblock) {
if (bh) brelse(bh);
 
-   bh = sb_bread(inode->i_sb, iblock);
+   bh = sb_bread(inode_sb(inode), iblock);
if (!bh) {
pr_err("%s() failed at block %d\n",
   __func__, iblock);
diff --git a/fs/efs/namei.c b/fs/efs/namei.c
index 38961ee1d1af..d1f3132b50a8 100644
--- a/fs/efs/namei.c
+++ b/fs/efs/namei.c
@@ -30,7 +30,7 @@ static efs_ino_t efs_find_entry(struct inode *inode, const 
char *name, int len)
 
for(block = 0; block < inode->i_blocks; block++) {
 
-   bh = sb_bread(inode->i_sb, efs_bmap(inode, block));
+   bh = sb_bread(inode_sb(inode), efs_bmap(inode, block));
if (!bh) {
pr_err("%s(): failed to read dir block %d\n",
   __func__, block);
@@ -69,7 +69,7 @@ struct dentry *efs_lookup(struct inode *dir, struct dentry 
*dentry, unsigned int
 
inodenum = efs_find_entry(dir, dentry->d_name.name, dentry->d_name.len);
if (inodenum)
-   inode = efs_iget(dir->i_sb, inodenum);
+   inode = efs_iget(inode_sb(dir), inodenum);
 
return d_splice_alias(inode, dentry);
 }
diff --git a/fs/efs/symlink.c b/fs/efs/symlink.c
index 923eb91654d5..f6b8b33e9600 100644
--- a/fs/efs/symlink.c
+++ b/fs/efs/symlink.c
@@ -26,13 +26,13 @@ static int efs_symlink_readpage(struct file *file, struct 
page *page)
   
/* read first 512 bytes of link target */
err = -EIO;
-   bh = sb_bread(inode->i_sb, efs_bmap(inode, 0));
+   bh = sb_bread(inode_sb(inode), efs_bmap(inode, 0));
if (!bh)
goto fail;
memcpy(link, bh->b_data, (size > EFS_BLOCKSIZE) ? EFS_BLOCKSIZE : size);
brelse(bh);
if (size > EFS_BLOCKSIZE) {
-   bh = sb_bread(inode->i_sb, efs_bmap(inode, 1));
+   bh = sb_bread(inode_sb(inode), efs_bmap(inode, 1));
if (!bh)
goto fail;
memcpy(link + EFS_BLOCKSIZE, bh->b_data, size - EFS_BLOCKSIZE);
-- 
2.15.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 33/76] fs/fat: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/fat/cache.c   | 12 ++--
 fs/fat/dir.c | 26 +-
 fs/fat/fat.h |  2 +-
 fs/fat/fatent.c  | 10 +-
 fs/fat/file.c| 24 
 fs/fat/inode.c   | 28 ++--
 fs/fat/misc.c|  2 +-
 fs/fat/namei_msdos.c | 22 +++---
 fs/fat/namei_vfat.c  | 18 +-
 fs/fat/nfs.c |  4 ++--
 10 files changed, 74 insertions(+), 74 deletions(-)

diff --git a/fs/fat/cache.c b/fs/fat/cache.c
index e9bed49df6b7..bfe99b4a9ef8 100644
--- a/fs/fat/cache.c
+++ b/fs/fat/cache.c
@@ -224,7 +224,7 @@ static inline void cache_init(struct fat_cache_id *cid, int 
fclus, int dclus)
 
 int fat_get_cluster(struct inode *inode, int cluster, int *fclus, int *dclus)
 {
-   struct super_block *sb = inode->i_sb;
+   struct super_block *sb = inode_sb(inode);
const int limit = sb->s_maxbytes >> MSDOS_SB(sb)->cluster_bits;
struct fat_entry fatent;
struct fat_cache_id cid;
@@ -285,7 +285,7 @@ int fat_get_cluster(struct inode *inode, int cluster, int 
*fclus, int *dclus)
 
 static int fat_bmap_cluster(struct inode *inode, int cluster)
 {
-   struct super_block *sb = inode->i_sb;
+   struct super_block *sb = inode_sb(inode);
int ret, fclus, dclus;
 
if (MSDOS_I(inode)->i_start == 0)
@@ -306,7 +306,7 @@ int fat_get_mapped_cluster(struct inode *inode, sector_t 
sector,
   sector_t last_block,
   unsigned long *mapped_blocks, sector_t *bmap)
 {
-   struct super_block *sb = inode->i_sb;
+   struct super_block *sb = inode_sb(inode);
struct msdos_sb_info *sbi = MSDOS_SB(sb);
int cluster, offset;
 
@@ -328,7 +328,7 @@ int fat_get_mapped_cluster(struct inode *inode, sector_t 
sector,
 static int is_exceed_eof(struct inode *inode, sector_t sector,
 sector_t *last_block, int create)
 {
-   struct super_block *sb = inode->i_sb;
+   struct super_block *sb = inode_sb(inode);
const unsigned long blocksize = sb->s_blocksize;
const unsigned char blocksize_bits = sb->s_blocksize_bits;
 
@@ -353,7 +353,7 @@ static int is_exceed_eof(struct inode *inode, sector_t 
sector,
 int fat_bmap(struct inode *inode, sector_t sector, sector_t *phys,
 unsigned long *mapped_blocks, int create, bool from_bmap)
 {
-   struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb);
+   struct msdos_sb_info *sbi = MSDOS_SB(inode_sb(inode));
sector_t last_block;
 
*phys = 0;
@@ -371,7 +371,7 @@ int fat_bmap(struct inode *inode, sector_t sector, sector_t 
*phys,
return 0;
} else {
last_block = inode->i_blocks >>
-   (inode->i_sb->s_blocksize_bits - 9);
+   (inode_sb(inode)->s_blocksize_bits - 9);
if (sector >= last_block)
return 0;
}
diff --git a/fs/fat/dir.c b/fs/fat/dir.c
index 8e100c3bf72c..dce4b9f0c754 100644
--- a/fs/fat/dir.c
+++ b/fs/fat/dir.c
@@ -48,7 +48,7 @@ static inline loff_t fat_make_i_pos(struct super_block *sb,
 static inline void fat_dir_readahead(struct inode *dir, sector_t iblock,
 sector_t phys)
 {
-   struct super_block *sb = dir->i_sb;
+   struct super_block *sb = inode_sb(dir);
struct msdos_sb_info *sbi = MSDOS_SB(sb);
struct buffer_head *bh;
int sec;
@@ -81,7 +81,7 @@ static inline void fat_dir_readahead(struct inode *dir, 
sector_t iblock,
 static int fat__get_entry(struct inode *dir, loff_t *pos,
  struct buffer_head **bh, struct msdos_dir_entry **de)
 {
-   struct super_block *sb = dir->i_sb;
+   struct super_block *sb = inode_sb(dir);
sector_t phys, iblock;
unsigned long mapped_blocks;
int err, offset;
@@ -121,7 +121,7 @@ static inline int fat_get_entry(struct inode *dir, loff_t 
*pos,
/* Fast stuff first */
if (*bh && *de &&
   (*de - (struct msdos_dir_entry *)(*bh)->b_data) <
-   MSDOS_SB(dir->i_sb)->dir_per_block - 1) {
+   MSDOS_SB(inode_sb(dir))->dir_per_block - 1) {
*pos += sizeof(struct msdos_dir_entry);
(*de)++;
return 0;
@@ -462,7 +462,7 @@ static int fat_parse_short(struct super_block *sb,
 int fat_search_long(struct inode *inode, const unsigned char *name,
int name_len, struct fat_slot_info *sinfo)
 {
-   struct super_block *sb = inode->i_sb;
+   struct super_block *sb = inode_sb(inode);
struct msdos_sb_info *sbi = MSDOS_SB(sb);
struct buffer_head *bh = NULL;
struct msdos_dir_entry *de;
@@ -553,7 +553,7 @@ static int __fat_readdir(struct inode *inode, struct file 
*file,
 struct 

[PATCH 35/76] fs/fuse: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/fuse/dir.c| 13 +++--
 fs/fuse/file.c   |  6 +++---
 fs/fuse/fuse_i.h |  2 +-
 fs/fuse/inode.c  |  7 ---
 4 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 24967382a7b1..b68adb3bd70d 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -357,7 +357,8 @@ static struct dentry *fuse_lookup(struct inode *dir, struct 
dentry *entry,
bool outarg_valid = true;
 
fuse_lock_inode(dir);
-   err = fuse_lookup_name(dir->i_sb, get_node_id(dir), >d_name,
+   err = fuse_lookup_name(inode_sb(dir), get_node_id(dir),
+  >d_name,
   , );
fuse_unlock_inode(dir);
if (err == -ENOENT) {
@@ -456,7 +457,7 @@ static int fuse_create_open(struct inode *dir, struct 
dentry *entry,
ff->fh = outopen.fh;
ff->nodeid = outentry.nodeid;
ff->open_flags = outopen.open_flags;
-   inode = fuse_iget(dir->i_sb, outentry.nodeid, outentry.generation,
+   inode = fuse_iget(inode_sb(dir), outentry.nodeid, outentry.generation,
  , entry_attr_timeout(), 0);
if (!inode) {
flags &= ~(O_CREAT | O_EXCL | O_TRUNC);
@@ -562,7 +563,7 @@ static int create_new_entry(struct fuse_conn *fc, struct 
fuse_args *args,
if ((outarg.attr.mode ^ mode) & S_IFMT)
goto out_put_forget_req;
 
-   inode = fuse_iget(dir->i_sb, outarg.nodeid, outarg.generation,
+   inode = fuse_iget(inode_sb(dir), outarg.nodeid, outarg.generation,
  , entry_attr_timeout(), 0);
if (!inode) {
fuse_queue_forget(fc, forget, outarg.nodeid, 1);
@@ -854,7 +855,7 @@ static void fuse_fillattr(struct inode *inode, struct 
fuse_attr *attr,
attr->ctimensec = inode->i_ctime.tv_nsec;
}
 
-   stat->dev = inode->i_sb->s_dev;
+   stat->dev = inode_sb(inode)->s_dev;
stat->ino = attr->ino;
stat->mode = (inode->i_mode & S_IFMT) | (attr->mode & 0);
stat->nlink = attr->nlink;
@@ -873,7 +874,7 @@ static void fuse_fillattr(struct inode *inode, struct 
fuse_attr *attr,
if (attr->blksize != 0)
blkbits = ilog2(attr->blksize);
else
-   blkbits = inode->i_sb->s_blocksize_bits;
+   blkbits = inode_sb(inode)->s_blocksize_bits;
 
stat->blksize = 1 << blkbits;
 }
@@ -1255,7 +1256,7 @@ static int fuse_direntplus_link(struct file *file,
 * which bumps nlookup inside
 */
} else {
-   inode = fuse_iget(dir->i_sb, o->nodeid, o->generation,
+   inode = fuse_iget(inode_sb(dir), o->nodeid, o->generation,
  >attr, entry_attr_timeout(o),
  attr_version);
if (!inode)
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index a201fb0ac64f..14e55c348da7 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -2250,12 +2250,12 @@ static sector_t fuse_bmap(struct address_space 
*mapping, sector_t block)
struct fuse_bmap_out outarg;
int err;
 
-   if (!inode->i_sb->s_bdev || fc->no_bmap)
+   if (!inode_sb(inode)->s_bdev || fc->no_bmap)
return 0;
 
memset(, 0, sizeof(inarg));
inarg.block = block;
-   inarg.blocksize = inode->i_sb->s_blocksize;
+   inarg.blocksize = inode_sb(inode)->s_blocksize;
args.in.h.opcode = FUSE_BMAP;
args.in.h.nodeid = get_node_id(inode);
args.in.numargs = 1;
@@ -2305,7 +2305,7 @@ static loff_t fuse_lseek(struct file *file, loff_t 
offset, int whence)
return err;
}
 
-   return vfs_setpos(file, outarg.offset, inode->i_sb->s_maxbytes);
+   return vfs_setpos(file, outarg.offset, inode_sb(inode)->s_maxbytes);
 
 fallback:
err = fuse_update_attributes(inode, file);
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index c4c093bbf456..5ea9ddb9fa19 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -674,7 +674,7 @@ static inline struct fuse_conn *get_fuse_conn_super(struct 
super_block *sb)
 
 static inline struct fuse_conn *get_fuse_conn(struct inode *inode)
 {
-   return get_fuse_conn_super(inode->i_sb);
+   return get_fuse_conn_super(inode_sb(inode));
 }
 
 static inline struct fuse_inode *get_fuse_inode(struct inode *inode)
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 624f18bbfd2b..d6d2fbe6c3ec 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -130,7 +130,7 @@ static void fuse_evict_inode(struct inode *inode)
 {
truncate_inode_pages_final(>i_data);
clear_inode(inode);
-   if (inode->i_sb->s_flags & SB_ACTIVE) {
+   if (inode_sb(inode)->s_flags & SB_ACTIVE) {
struct fuse_conn *fc = get_fuse_conn(inode);
struct fuse_inode *fi = get_fuse_inode(inode);
fuse_queue_forget(fc, fi->forget, 

[PATCH 34/76] fs/freevxfs: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/freevxfs/vxfs_bmap.c   | 14 +++---
 fs/freevxfs/vxfs_inode.c  |  2 +-
 fs/freevxfs/vxfs_lookup.c | 10 +-
 fs/freevxfs/vxfs_subr.c   |  4 ++--
 4 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/fs/freevxfs/vxfs_bmap.c b/fs/freevxfs/vxfs_bmap.c
index 1fd41cf98b9f..55cfb03efb35 100644
--- a/fs/freevxfs/vxfs_bmap.c
+++ b/fs/freevxfs/vxfs_bmap.c
@@ -66,7 +66,7 @@ vxfs_typdump(struct vxfs_typed *typ)
 static daddr_t
 vxfs_bmap_ext4(struct inode *ip, long bn)
 {
-   struct super_block *sb = ip->i_sb;
+   struct super_block *sb = inode_sb(ip);
struct vxfs_inode_info *vip = VXFS_INO(ip);
struct vxfs_sb_info *sbi = VXFS_SBI(sb);
unsigned long bsize = sb->s_blocksize;
@@ -130,22 +130,22 @@ vxfs_bmap_ext4(struct inode *ip, long bn)
 static daddr_t
 vxfs_bmap_indir(struct inode *ip, long indir, int size, long block)
 {
-   struct vxfs_sb_info *sbi = VXFS_SBI(ip->i_sb);
+   struct vxfs_sb_info *sbi = VXFS_SBI(inode_sb(ip));
struct buffer_head  *bp = NULL;
daddr_t pblock = 0;
int i;
 
-   for (i = 0; i < size * VXFS_TYPED_PER_BLOCK(ip->i_sb); i++) {
+   for (i = 0; i < size * VXFS_TYPED_PER_BLOCK(inode_sb(ip)); i++) {
struct vxfs_typed   *typ;
int64_t off;
 
-   bp = sb_bread(ip->i_sb,
-   indir + (i / VXFS_TYPED_PER_BLOCK(ip->i_sb)));
+   bp = sb_bread(inode_sb(ip),
+   indir + (i / 
VXFS_TYPED_PER_BLOCK(inode_sb(ip;
if (!bp || !buffer_mapped(bp))
return 0;
 
typ = ((struct vxfs_typed *)bp->b_data) +
-   (i % VXFS_TYPED_PER_BLOCK(ip->i_sb));
+   (i % VXFS_TYPED_PER_BLOCK(inode_sb(ip)));
off = fs64_to_cpu(sbi, typ->vt_hdr) & VXFS_TYPED_OFFSETMASK;
 
if (block < off) {
@@ -210,7 +210,7 @@ static daddr_t
 vxfs_bmap_typed(struct inode *ip, long iblock)
 {
struct vxfs_inode_info  *vip = VXFS_INO(ip);
-   struct vxfs_sb_info *sbi = VXFS_SBI(ip->i_sb);
+   struct vxfs_sb_info *sbi = VXFS_SBI(inode_sb(ip));
daddr_t pblock = 0;
int i;
 
diff --git a/fs/freevxfs/vxfs_inode.c b/fs/freevxfs/vxfs_inode.c
index 1f41b25ef38b..fdb36340a25f 100644
--- a/fs/freevxfs/vxfs_inode.c
+++ b/fs/freevxfs/vxfs_inode.c
@@ -221,7 +221,7 @@ __vxfs_iget(struct inode *ilistp, struct vxfs_inode_info 
*vip, ino_t ino)
caddr_t kaddr = (char *)page_address(pp);
 
dip = (struct vxfs_dinode *)(kaddr + offset);
-   dip2vip_cpy(VXFS_SBI(ilistp->i_sb), vip, dip);
+   dip2vip_cpy(VXFS_SBI(inode_sb(ilistp)), vip, dip);
vip->vfs_inode.i_mapping->a_ops = _aops;
 #ifdef DIAGNOSTIC
vxfs_dumpi(vip, ino);
diff --git a/fs/freevxfs/vxfs_lookup.c b/fs/freevxfs/vxfs_lookup.c
index ce4785fd81c6..f2011edf525c 100644
--- a/fs/freevxfs/vxfs_lookup.c
+++ b/fs/freevxfs/vxfs_lookup.c
@@ -80,13 +80,13 @@ const struct file_operations vxfs_dir_operations = {
 static struct vxfs_direct *
 vxfs_find_entry(struct inode *ip, struct dentry *dp, struct page **ppp)
 {
-   u_long bsize = ip->i_sb->s_blocksize;
+   u_long bsize = inode_sb(ip)->s_blocksize;
const char *name = dp->d_name.name;
int namelen = dp->d_name.len;
loff_t limit = VXFS_DIRROUND(ip->i_size);
struct vxfs_direct *de_exit = NULL;
loff_t pos = 0;
-   struct vxfs_sb_info *sbi = VXFS_SBI(ip->i_sb);
+   struct vxfs_sb_info *sbi = VXFS_SBI(inode_sb(ip));
 
while (pos < limit) {
struct page *pp;
@@ -161,7 +161,7 @@ vxfs_inode_by_name(struct inode *dip, struct dentry *dp)
 
de = vxfs_find_entry(dip, dp, );
if (de) {
-   ino = fs32_to_cpu(VXFS_SBI(dip->i_sb), de->d_ino);
+   ino = fs32_to_cpu(VXFS_SBI(inode_sb(dip)), de->d_ino);
kunmap(pp);
put_page(pp);
}
@@ -194,7 +194,7 @@ vxfs_lookup(struct inode *dip, struct dentry *dp, unsigned 
int flags)
 
ino = vxfs_inode_by_name(dip, dp);
if (ino) {
-   ip = vxfs_iget(dip->i_sb, ino);
+   ip = vxfs_iget(inode_sb(dip), ino);
if (IS_ERR(ip))
return ERR_CAST(ip);
}
@@ -219,7 +219,7 @@ static int
 vxfs_readdir(struct file *fp, struct dir_context *ctx)
 {
struct inode*ip = file_inode(fp);
-   struct super_block  *sbp = ip->i_sb;
+   struct super_block  *sbp = inode_sb(ip);
u_long  bsize = sbp->s_blocksize;
loff_t  pos, 

[PATCH 37/76] fs/hfs: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/hfs/attr.c|  4 ++--
 fs/hfs/catalog.c | 10 +-
 fs/hfs/dir.c | 11 ++-
 fs/hfs/extent.c  | 10 +-
 fs/hfs/inode.c   | 32 
 5 files changed, 34 insertions(+), 33 deletions(-)

diff --git a/fs/hfs/attr.c b/fs/hfs/attr.c
index 74fa62643136..60075ee27192 100644
--- a/fs/hfs/attr.c
+++ b/fs/hfs/attr.c
@@ -30,7 +30,7 @@ static int __hfs_setxattr(struct inode *inode, enum 
hfs_xattr_type type,
if (!S_ISREG(inode->i_mode) || HFS_IS_RSRC(inode))
return -EOPNOTSUPP;
 
-   res = hfs_find_init(HFS_SB(inode->i_sb)->cat_tree, );
+   res = hfs_find_init(HFS_SB(inode_sb(inode))->cat_tree, );
if (res)
return res;
fd.search_key->cat = HFS_I(inode)->cat_key;
@@ -77,7 +77,7 @@ static ssize_t __hfs_getxattr(struct inode *inode, enum 
hfs_xattr_type type,
return -EOPNOTSUPP;
 
if (size) {
-   res = hfs_find_init(HFS_SB(inode->i_sb)->cat_tree, );
+   res = hfs_find_init(HFS_SB(inode_sb(inode))->cat_tree, );
if (res)
return res;
fd.search_key->cat = HFS_I(inode)->cat_key;
diff --git a/fs/hfs/catalog.c b/fs/hfs/catalog.c
index 8a66405b0f8b..790d488a2c24 100644
--- a/fs/hfs/catalog.c
+++ b/fs/hfs/catalog.c
@@ -56,8 +56,8 @@ static int hfs_cat_build_record(hfs_cat_rec *rec, u32 cnid, 
struct inode *inode)
rec->file.CrDat = mtime;
rec->file.MdDat = mtime;
rec->file.BkDat = 0;
-   rec->file.UsrWds.fdType = HFS_SB(inode->i_sb)->s_type;
-   rec->file.UsrWds.fdCreator = HFS_SB(inode->i_sb)->s_creator;
+   rec->file.UsrWds.fdType = HFS_SB(inode_sb(inode))->s_type;
+   rec->file.UsrWds.fdCreator = HFS_SB(inode_sb(inode))->s_creator;
return sizeof(struct hfs_cat_file);
}
 }
@@ -92,7 +92,7 @@ int hfs_cat_create(u32 cnid, struct inode *dir, const struct 
qstr *str, struct i
if (dir->i_size >= HFS_MAX_VALENCE)
return -ENOSPC;
 
-   sb = dir->i_sb;
+   sb = inode_sb(dir);
err = hfs_find_init(HFS_SB(sb)->cat_tree, );
if (err)
return err;
@@ -218,7 +218,7 @@ int hfs_cat_delete(u32 cnid, struct inode *dir, const 
struct qstr *str)
int res, type;
 
hfs_dbg(CAT_MOD, "delete_cat: %s,%u\n", str ? str->name : NULL, cnid);
-   sb = dir->i_sb;
+   sb = inode_sb(dir);
res = hfs_find_init(HFS_SB(sb)->cat_tree, );
if (res)
return res;
@@ -289,7 +289,7 @@ int hfs_cat_move(u32 cnid, struct inode *src_dir, const 
struct qstr *src_name,
hfs_dbg(CAT_MOD, "rename_cat: %u - %lu,%s - %lu,%s\n",
cnid, src_dir->i_ino, src_name->name,
dst_dir->i_ino, dst_name->name);
-   sb = src_dir->i_sb;
+   sb = inode_sb(src_dir);
err = hfs_find_init(HFS_SB(sb)->cat_tree, _fd);
if (err)
return err;
diff --git a/fs/hfs/dir.c b/fs/hfs/dir.c
index 75b254280ff6..ae29580b3d0c 100644
--- a/fs/hfs/dir.c
+++ b/fs/hfs/dir.c
@@ -25,10 +25,11 @@ static struct dentry *hfs_lookup(struct inode *dir, struct 
dentry *dentry,
struct inode *inode = NULL;
int res;
 
-   res = hfs_find_init(HFS_SB(dir->i_sb)->cat_tree, );
+   res = hfs_find_init(HFS_SB(inode_sb(dir))->cat_tree, );
if (res)
return ERR_PTR(res);
-   hfs_cat_build_key(dir->i_sb, fd.search_key, dir->i_ino, 
>d_name);
+   hfs_cat_build_key(inode_sb(dir), fd.search_key, dir->i_ino,
+ >d_name);
res = hfs_brec_read(, , sizeof(rec));
if (res) {
hfs_find_exit();
@@ -39,7 +40,7 @@ static struct dentry *hfs_lookup(struct inode *dir, struct 
dentry *dentry,
}
return ERR_PTR(res);
}
-   inode = hfs_iget(dir->i_sb, _key->cat, );
+   inode = hfs_iget(inode_sb(dir), _key->cat, );
hfs_find_exit();
if (!inode)
return ERR_PTR(-EACCES);
@@ -54,7 +55,7 @@ static struct dentry *hfs_lookup(struct inode *dir, struct 
dentry *dentry,
 static int hfs_readdir(struct file *file, struct dir_context *ctx)
 {
struct inode *inode = file_inode(file);
-   struct super_block *sb = inode->i_sb;
+   struct super_block *sb = inode_sb(inode);
int len, err;
char strbuf[HFS_MAX_NAMELEN];
union hfs_cat_rec entry;
@@ -305,7 +306,7 @@ static int hfs_rename(struct inode *old_dir, struct dentry 
*old_dentry,
   old_dir, _dentry->d_name,
   new_dir, _dentry->d_name);
if (!res)
-   hfs_cat_build_key(old_dir->i_sb,
+   hfs_cat_build_key(inode_sb(old_dir),
  (btree_key 
*)_I(d_inode(old_dentry))->cat_key,
  new_dir->i_ino, 

[PATCH 36/76] fs/gfs2: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/gfs2/aops.c| 9 +
 fs/gfs2/bmap.c| 9 +
 fs/gfs2/dir.c | 3 ++-
 fs/gfs2/export.c  | 2 +-
 fs/gfs2/file.c| 4 ++--
 fs/gfs2/incore.h  | 2 +-
 fs/gfs2/inode.c   | 8 
 fs/gfs2/meta_io.h | 2 +-
 fs/gfs2/super.c   | 2 +-
 9 files changed, 22 insertions(+), 19 deletions(-)

diff --git a/fs/gfs2/aops.c b/fs/gfs2/aops.c
index 2f725b4a386b..bd771df8b227 100644
--- a/fs/gfs2/aops.c
+++ b/fs/gfs2/aops.c
@@ -189,7 +189,8 @@ static int __gfs2_jdata_writepage(struct page *page, struct 
writeback_control *w
if (PageChecked(page)) {
ClearPageChecked(page);
if (!page_has_buffers(page)) {
-   create_empty_buffers(page, inode->i_sb->s_blocksize,
+   create_empty_buffers(page,
+inode_sb(inode)->s_blocksize,
 BIT(BH_Dirty)|BIT(BH_Uptodate));
}
gfs2_page_add_databufs(ip, page, 0, sdp->sd_vfs->s_blocksize);
@@ -271,7 +272,7 @@ static int gfs2_write_jdata_pagevec(struct address_space 
*mapping,
 {
struct inode *inode = mapping->host;
struct gfs2_sbd *sdp = GFS2_SB(inode);
-   unsigned nrblocks = nr_pages * (PAGE_SIZE/inode->i_sb->s_blocksize);
+   unsigned nrblocks = nr_pages * (PAGE_SIZE/inode_sb(inode)->s_blocksize);
int i;
int ret;
 
@@ -776,7 +777,7 @@ static int gfs2_write_begin(struct file *file, struct 
address_space *mapping,
  */
 static void adjust_fs_space(struct inode *inode)
 {
-   struct gfs2_sbd *sdp = inode->i_sb->s_fs_info;
+   struct gfs2_sbd *sdp = inode_sb(inode)->s_fs_info;
struct gfs2_inode *m_ip = GFS2_I(sdp->sd_statfs_inode);
struct gfs2_inode *l_ip = GFS2_I(sdp->sd_sc_inode);
struct gfs2_statfs_change_host *m_sc = >sd_statfs_master;
@@ -1112,7 +1113,7 @@ static ssize_t gfs2_direct_IO(struct kiocb *iocb, struct 
iov_iter *iter)
truncate_inode_pages_range(mapping, lstart, end);
}
 
-   rv = __blockdev_direct_IO(iocb, inode, inode->i_sb->s_bdev, iter,
+   rv = __blockdev_direct_IO(iocb, inode, inode_sb(inode)->s_bdev, iter,
  gfs2_get_block_direct, NULL, NULL, 0);
 out:
gfs2_glock_dq();
diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c
index 51f940e76c5e..f523d2e7a71a 100644
--- a/fs/gfs2/bmap.c
+++ b/fs/gfs2/bmap.c
@@ -86,7 +86,7 @@ static int gfs2_unstuffer_page(struct gfs2_inode *ip, struct 
buffer_head *dibh,
bh = page_buffers(page);
 
if (!buffer_mapped(bh))
-   map_bh(bh, inode->i_sb, block);
+   map_bh(bh, inode_sb(inode), block);
 
set_buffer_uptodate(bh);
if (!gfs2_is_jdata(ip))
@@ -856,7 +856,8 @@ int gfs2_block_map(struct inode *inode, sector_t lblock,
iomap.flags &= ~IOMAP_F_BOUNDARY;
}
if (iomap.addr != IOMAP_NULL_ADDR)
-   map_bh(bh_map, inode->i_sb, iomap.addr >> inode->i_blkbits);
+   map_bh(bh_map, inode_sb(inode),
+  iomap.addr >> inode->i_blkbits);
bh_map->b_size = iomap.length;
if (iomap.flags & IOMAP_F_BOUNDARY)
set_buffer_boundary(bh_map);
@@ -913,8 +914,8 @@ static int gfs2_block_zero_range(struct inode *inode, 
loff_t from,
if (!page)
return 0;
 
-   blocksize = inode->i_sb->s_blocksize;
-   iblock = index << (PAGE_SHIFT - inode->i_sb->s_blocksize_bits);
+   blocksize = inode_sb(inode)->s_blocksize;
+   iblock = index << (PAGE_SHIFT - inode_sb(inode)->s_blocksize_bits);
 
if (!page_has_buffers(page))
create_empty_buffers(page, blocksize, 0);
diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c
index 7c21aea0266b..5ab5ed92ce78 100644
--- a/fs/gfs2/dir.c
+++ b/fs/gfs2/dir.c
@@ -1665,7 +1665,8 @@ struct inode *gfs2_dir_search(struct inode *dir, const 
struct qstr *name,
brelse(bh);
if (fail_on_exist)
return ERR_PTR(-EEXIST);
-   inode = gfs2_inode_lookup(dir->i_sb, dtype, addr, formal_ino,
+   inode = gfs2_inode_lookup(inode_sb(dir), dtype, addr,
+ formal_ino,
  GFS2_BLKST_FREE /* ignore */);
if (!IS_ERR(inode))
GFS2_I(inode)->i_rahead = rahead;
diff --git a/fs/gfs2/export.c b/fs/gfs2/export.c
index a332f3cd925e..42e7f8e30683 100644
--- a/fs/gfs2/export.c
+++ b/fs/gfs2/export.c
@@ -32,7 +32,7 @@ static int gfs2_encode_fh(struct inode *inode, __u32 *p, int 
*len,
  struct inode *parent)
 {
__be32 *fh = (__force __be32 *)p;
-   struct super_block *sb = inode->i_sb;
+   struct super_block *sb = inode_sb(inode);
struct gfs2_inode *ip = GFS2_I(inode);
 
if (parent && (*len < GFS2_LARGE_FH_SIZE)) {

[PATCH 38/76] fs/hfsplus: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/hfsplus/attributes.c | 12 ++--
 fs/hfsplus/bnode.c  |  2 +-
 fs/hfsplus/catalog.c| 12 ++--
 fs/hfsplus/dir.c| 22 +++---
 fs/hfsplus/extents.c| 11 ++-
 fs/hfsplus/inode.c  | 18 +-
 fs/hfsplus/ioctl.c  |  2 +-
 fs/hfsplus/super.c  | 14 --
 fs/hfsplus/xattr.c  | 41 +
 9 files changed, 69 insertions(+), 65 deletions(-)

diff --git a/fs/hfsplus/attributes.c b/fs/hfsplus/attributes.c
index 2bab6b3cdba4..24af5a496912 100644
--- a/fs/hfsplus/attributes.c
+++ b/fs/hfsplus/attributes.c
@@ -169,7 +169,7 @@ int hfsplus_find_attr(struct super_block *sb, u32 cnid,
 int hfsplus_attr_exists(struct inode *inode, const char *name)
 {
int err = 0;
-   struct super_block *sb = inode->i_sb;
+   struct super_block *sb = inode_sb(inode);
struct hfs_find_data fd;
 
if (!HFSPLUS_SB(sb)->attr_tree)
@@ -195,7 +195,7 @@ int hfsplus_create_attr(struct inode *inode,
const char *name,
const void *value, size_t size)
 {
-   struct super_block *sb = inode->i_sb;
+   struct super_block *sb = inode_sb(inode);
struct hfs_find_data fd;
hfsplus_attr_entry *entry_ptr;
int entry_size;
@@ -298,7 +298,7 @@ static int __hfsplus_delete_attr(struct inode *inode, u32 
cnid,
 int hfsplus_delete_attr(struct inode *inode, const char *name)
 {
int err = 0;
-   struct super_block *sb = inode->i_sb;
+   struct super_block *sb = inode_sb(inode);
struct hfs_find_data fd;
 
hfs_dbg(ATTR_MOD, "delete_attr: %s,%ld\n",
@@ -344,17 +344,17 @@ int hfsplus_delete_all_attrs(struct inode *dir, u32 cnid)
 
hfs_dbg(ATTR_MOD, "delete_all_attrs: %d\n", cnid);
 
-   if (!HFSPLUS_SB(dir->i_sb)->attr_tree) {
+   if (!HFSPLUS_SB(inode_sb(dir))->attr_tree) {
pr_err("attributes file doesn't exist\n");
return -EINVAL;
}
 
-   err = hfs_find_init(HFSPLUS_SB(dir->i_sb)->attr_tree, );
+   err = hfs_find_init(HFSPLUS_SB(inode_sb(dir))->attr_tree, );
if (err)
return err;
 
for (;;) {
-   err = hfsplus_find_attr(dir->i_sb, cnid, NULL, );
+   err = hfsplus_find_attr(inode_sb(dir), cnid, NULL, );
if (err) {
if (err != -ENOENT)
pr_err("xattr search failed\n");
diff --git a/fs/hfsplus/bnode.c b/fs/hfsplus/bnode.c
index 177fae4e6581..9da98a7955a0 100644
--- a/fs/hfsplus/bnode.c
+++ b/fs/hfsplus/bnode.c
@@ -656,7 +656,7 @@ void hfs_bnode_put(struct hfs_bnode *node)
  */
 bool hfs_bnode_need_zeroout(struct hfs_btree *tree)
 {
-   struct super_block *sb = tree->inode->i_sb;
+   struct super_block *sb = inode_sb(tree->inode);
struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb);
const u32 volume_attr = be32_to_cpu(sbi->s_vhdr->attributes);
 
diff --git a/fs/hfsplus/catalog.c b/fs/hfsplus/catalog.c
index a196369ba779..23336c614b64 100644
--- a/fs/hfsplus/catalog.c
+++ b/fs/hfsplus/catalog.c
@@ -105,7 +105,7 @@ void hfsplus_cat_set_perms(struct inode *inode, struct 
hfsplus_perm *perms)
 static int hfsplus_cat_build_record(hfsplus_cat_entry *entry,
u32 cnid, struct inode *inode)
 {
-   struct hfsplus_sb_info *sbi = HFSPLUS_SB(inode->i_sb);
+   struct hfsplus_sb_info *sbi = HFSPLUS_SB(inode_sb(inode));
 
if (S_ISDIR(inode->i_mode)) {
struct hfsplus_cat_folder *folder;
@@ -222,7 +222,7 @@ int hfsplus_find_cat(struct super_block *sb, u32 cnid,
 
 static void hfsplus_subfolders_inc(struct inode *dir)
 {
-   struct hfsplus_sb_info *sbi = HFSPLUS_SB(dir->i_sb);
+   struct hfsplus_sb_info *sbi = HFSPLUS_SB(inode_sb(dir));
 
if (test_bit(HFSPLUS_SB_HFSX, >flags)) {
/*
@@ -235,7 +235,7 @@ static void hfsplus_subfolders_inc(struct inode *dir)
 
 static void hfsplus_subfolders_dec(struct inode *dir)
 {
-   struct hfsplus_sb_info *sbi = HFSPLUS_SB(dir->i_sb);
+   struct hfsplus_sb_info *sbi = HFSPLUS_SB(inode_sb(dir));
 
if (test_bit(HFSPLUS_SB_HFSX, >flags)) {
/*
@@ -253,7 +253,7 @@ static void hfsplus_subfolders_dec(struct inode *dir)
 int hfsplus_create_cat(u32 cnid, struct inode *dir,
const struct qstr *str, struct inode *inode)
 {
-   struct super_block *sb = dir->i_sb;
+   struct super_block *sb = inode_sb(dir);
struct hfs_find_data fd;
hfsplus_cat_entry entry;
int entry_size;
@@ -321,7 +321,7 @@ int hfsplus_create_cat(u32 cnid, struct inode *dir,
 
 int hfsplus_delete_cat(u32 cnid, struct inode *dir, const struct qstr *str)
 {
-   struct super_block *sb = dir->i_sb;
+   struct super_block *sb = inode_sb(dir);
struct hfs_find_data fd;
struct hfsplus_fork_raw fork;
   

[PATCH 40/76] fs/hpfs: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/hpfs/dir.c   |  76 +---
 fs/hpfs/dnode.c | 176 
 fs/hpfs/ea.c|   2 +-
 fs/hpfs/file.c  |  45 ---
 fs/hpfs/inode.c |  77 +
 fs/hpfs/namei.c | 130 ++---
 fs/hpfs/super.c |   6 +-
 7 files changed, 287 insertions(+), 225 deletions(-)

diff --git a/fs/hpfs/dir.c b/fs/hpfs/dir.c
index c83ece7facc5..416e6e238ee4 100644
--- a/fs/hpfs/dir.c
+++ b/fs/hpfs/dir.c
@@ -12,10 +12,10 @@
 
 static int hpfs_dir_release(struct inode *inode, struct file *filp)
 {
-   hpfs_lock(inode->i_sb);
+   hpfs_lock(inode_sb(inode));
hpfs_del_pos(inode, >f_pos);
/*hpfs_write_if_changed(inode);*/
-   hpfs_unlock(inode->i_sb);
+   hpfs_unlock(inode_sb(inode));
return 0;
 }
 
@@ -28,7 +28,7 @@ static loff_t hpfs_dir_lseek(struct file *filp, loff_t off, 
int whence)
struct quad_buffer_head qbh;
struct inode *i = file_inode(filp);
struct hpfs_inode_info *hpfs_inode = hpfs_i(i);
-   struct super_block *s = i->i_sb;
+   struct super_block *s = inode_sb(i);
 
/* Somebody else will have to figure out what to do here */
if (whence == SEEK_DATA || whence == SEEK_HOLE)
@@ -74,34 +74,38 @@ static int hpfs_readdir(struct file *file, struct 
dir_context *ctx)
int c1, c2 = 0;
int ret = 0;
 
-   hpfs_lock(inode->i_sb);
+   hpfs_lock(inode_sb(inode));
 
-   if (hpfs_sb(inode->i_sb)->sb_chk) {
-   if (hpfs_chk_sectors(inode->i_sb, inode->i_ino, 1, 
"dir_fnode")) {
+   if (hpfs_sb(inode_sb(inode))->sb_chk) {
+   if (hpfs_chk_sectors(inode_sb(inode), inode->i_ino, 1, 
"dir_fnode")) {
ret = -EFSERROR;
goto out;
}
-   if (hpfs_chk_sectors(inode->i_sb, hpfs_inode->i_dno, 4, 
"dir_dnode")) {
+   if (hpfs_chk_sectors(inode_sb(inode), hpfs_inode->i_dno, 4, 
"dir_dnode")) {
ret = -EFSERROR;
goto out;
}
}
-   if (hpfs_sb(inode->i_sb)->sb_chk >= 2) {
+   if (hpfs_sb(inode_sb(inode))->sb_chk >= 2) {
struct buffer_head *bh;
struct fnode *fno;
int e = 0;
-   if (!(fno = hpfs_map_fnode(inode->i_sb, inode->i_ino, ))) {
+   if (!(fno = hpfs_map_fnode(inode_sb(inode), inode->i_ino, 
))) {
ret = -EIOERROR;
goto out;
}
if (!fnode_is_dir(fno)) {
e = 1;
-   hpfs_error(inode->i_sb, "not a directory, fnode %08lx",
+   hpfs_error(inode_sb(inode),
+   "not a directory, fnode %08lx",
(unsigned long)inode->i_ino);
}
if (hpfs_inode->i_dno != 
le32_to_cpu(fno->u.external[0].disk_secno)) {
e = 1;
-   hpfs_error(inode->i_sb, "corrupted inode: i_dno == 
%08x, fnode -> dnode == %08x", hpfs_inode->i_dno, 
le32_to_cpu(fno->u.external[0].disk_secno));
+   hpfs_error(inode_sb(inode),
+  "corrupted inode: i_dno == %08x, fnode -> 
dnode == %08x",
+  hpfs_inode->i_dno,
+  le32_to_cpu(fno->u.external[0].disk_secno));
}
brelse(bh);
if (e) {
@@ -109,7 +113,7 @@ static int hpfs_readdir(struct file *file, struct 
dir_context *ctx)
goto out;
}
}
-   lc = hpfs_sb(inode->i_sb)->sb_lowercase;
+   lc = hpfs_sb(inode_sb(inode))->sb_lowercase;
if (ctx->pos == 12) { /* diff -r requires this (note, that diff -r */
ctx->pos = 13; /* also fails on msdos filesystem in 2.0) */
goto out;
@@ -124,8 +128,8 @@ static int hpfs_readdir(struct file *file, struct 
dir_context *ctx)
/* This won't work when cycle is longer than number of dirents
   accepted by filldir, but what can I do?
   maybe killall -9 ls helps */
-   if (hpfs_sb(inode->i_sb)->sb_chk)
-   if (hpfs_stop_cycles(inode->i_sb, ctx->pos, , , 
"hpfs_readdir")) {
+   if (hpfs_sb(inode_sb(inode))->sb_chk)
+   if (hpfs_stop_cycles(inode_sb(inode), ctx->pos, , 
, "hpfs_readdir")) {
ret = -EFSERROR;
goto out;
}
@@ -149,7 +153,7 @@ static int hpfs_readdir(struct file *file, struct 
dir_context *ctx)
ret = hpfs_add_pos(inode, >f_pos);
if (unlikely(ret < 0))
goto out;

[PATCH 39/76] fs/hostfs: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/hostfs/hostfs_kern.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index c148e7f4f451..b99d08b7ef34 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -570,7 +570,7 @@ static int hostfs_create(struct inode *dir, struct dentry 
*dentry, umode_t mode,
char *name;
int error, fd;
 
-   inode = hostfs_iget(dir->i_sb);
+   inode = hostfs_iget(inode_sb(dir));
if (IS_ERR(inode)) {
error = PTR_ERR(inode);
goto out;
@@ -609,7 +609,7 @@ static struct dentry *hostfs_lookup(struct inode *ino, 
struct dentry *dentry,
char *name;
int err;
 
-   inode = hostfs_iget(ino->i_sb);
+   inode = hostfs_iget(inode_sb(ino));
if (IS_ERR(inode)) {
err = PTR_ERR(inode);
goto out;
@@ -717,7 +717,7 @@ static int hostfs_mknod(struct inode *dir, struct dentry 
*dentry, umode_t mode,
char *name;
int err;
 
-   inode = hostfs_iget(dir->i_sb);
+   inode = hostfs_iget(inode_sb(dir));
if (IS_ERR(inode)) {
err = PTR_ERR(inode);
goto out;
-- 
2.15.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 44/76] fs/jffs2: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/jffs2/dir.c   | 16 
 fs/jffs2/file.c  |  8 
 fs/jffs2/fs.c|  8 
 fs/jffs2/xattr.c |  6 +++---
 4 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c
index 0a754f38462e..e539bb4e4687 100644
--- a/fs/jffs2/dir.c
+++ b/fs/jffs2/dir.c
@@ -106,7 +106,7 @@ static struct dentry *jffs2_lookup(struct inode *dir_i, 
struct dentry *target,
ino = fd->ino;
mutex_unlock(_f->sem);
if (ino) {
-   inode = jffs2_iget(dir_i->i_sb, ino);
+   inode = jffs2_iget(inode_sb(dir_i), ino);
if (IS_ERR(inode))
pr_warn("iget() failed for ino #%u\n", ino);
}
@@ -170,7 +170,7 @@ static int jffs2_create(struct inode *dir_i, struct dentry 
*dentry,
if (!ri)
return -ENOMEM;
 
-   c = JFFS2_SB_INFO(dir_i->i_sb);
+   c = JFFS2_SB_INFO(inode_sb(dir_i));
 
jffs2_dbg(1, "%s()\n", __func__);
 
@@ -224,7 +224,7 @@ static int jffs2_create(struct inode *dir_i, struct dentry 
*dentry,
 
 static int jffs2_unlink(struct inode *dir_i, struct dentry *dentry)
 {
-   struct jffs2_sb_info *c = JFFS2_SB_INFO(dir_i->i_sb);
+   struct jffs2_sb_info *c = JFFS2_SB_INFO(inode_sb(dir_i));
struct jffs2_inode_info *dir_f = JFFS2_INODE_INFO(dir_i);
struct jffs2_inode_info *dead_f = JFFS2_INODE_INFO(d_inode(dentry));
int ret;
@@ -300,7 +300,7 @@ static int jffs2_symlink (struct inode *dir_i, struct 
dentry *dentry, const char
if (!ri)
return -ENOMEM;
 
-   c = JFFS2_SB_INFO(dir_i->i_sb);
+   c = JFFS2_SB_INFO(inode_sb(dir_i));
 
/* Try to reserve enough space for both node and dirent.
 * Just the node will do for now, though
@@ -459,7 +459,7 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry 
*dentry, umode_t mode
if (!ri)
return -ENOMEM;
 
-   c = JFFS2_SB_INFO(dir_i->i_sb);
+   c = JFFS2_SB_INFO(inode_sb(dir_i));
 
/* Try to reserve enough space for both node and dirent.
 * Just the node will do for now, though
@@ -586,7 +586,7 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry 
*dentry, umode_t mode
 
 static int jffs2_rmdir (struct inode *dir_i, struct dentry *dentry)
 {
-   struct jffs2_sb_info *c = JFFS2_SB_INFO(dir_i->i_sb);
+   struct jffs2_sb_info *c = JFFS2_SB_INFO(inode_sb(dir_i));
struct jffs2_inode_info *dir_f = JFFS2_INODE_INFO(dir_i);
struct jffs2_inode_info *f = JFFS2_INODE_INFO(d_inode(dentry));
struct jffs2_full_dirent *fd;
@@ -627,7 +627,7 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry 
*dentry, umode_t mode
if (!ri)
return -ENOMEM;
 
-   c = JFFS2_SB_INFO(dir_i->i_sb);
+   c = JFFS2_SB_INFO(inode_sb(dir_i));
 
if (S_ISBLK(mode) || S_ISCHR(mode))
devlen = jffs2_encode_dev(, rdev);
@@ -761,7 +761,7 @@ static int jffs2_rename (struct inode *old_dir_i, struct 
dentry *old_dentry,
 unsigned int flags)
 {
int ret;
-   struct jffs2_sb_info *c = JFFS2_SB_INFO(old_dir_i->i_sb);
+   struct jffs2_sb_info *c = JFFS2_SB_INFO(inode_sb(old_dir_i));
struct jffs2_inode_info *victim_f = NULL;
uint8_t type;
uint32_t now;
diff --git a/fs/jffs2/file.c b/fs/jffs2/file.c
index bd0428bebe9b..cfab0b294897 100644
--- a/fs/jffs2/file.c
+++ b/fs/jffs2/file.c
@@ -32,7 +32,7 @@ static int jffs2_readpage (struct file *filp, struct page 
*pg);
 int jffs2_fsync(struct file *filp, loff_t start, loff_t end, int datasync)
 {
struct inode *inode = filp->f_mapping->host;
-   struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
+   struct jffs2_sb_info *c = JFFS2_SB_INFO(inode_sb(inode));
int ret;
 
ret = file_write_and_wait_range(filp, start, end);
@@ -79,7 +79,7 @@ const struct address_space_operations 
jffs2_file_address_operations =
 static int jffs2_do_readpage_nolock (struct inode *inode, struct page *pg)
 {
struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
-   struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
+   struct jffs2_sb_info *c = JFFS2_SB_INFO(inode_sb(inode));
unsigned char *pg_buf;
int ret;
 
@@ -148,7 +148,7 @@ static int jffs2_write_begin(struct file *filp, struct 
address_space *mapping,
 
if (pageofs > inode->i_size) {
/* Make new hole frag from old EOF to new page */
-   struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
+   struct jffs2_sb_info *c = JFFS2_SB_INFO(inode_sb(inode));
struct jffs2_raw_inode ri;
struct jffs2_full_dnode *fn;
uint32_t alloc_len;
@@ -241,7 +241,7 @@ static int jffs2_write_end(struct file *filp, struct 
address_space *mapping,
 */
struct inode *inode = mapping->host;
 

[PATCH 41/76] fs/hugetlbfs: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/hugetlbfs/inode.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index b9a254dcc0e7..31d2a6051bea 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -791,7 +791,7 @@ static int hugetlbfs_mknod(struct inode *dir,
struct inode *inode;
int error = -ENOSPC;
 
-   inode = hugetlbfs_get_inode(dir->i_sb, dir, mode, dev);
+   inode = hugetlbfs_get_inode(inode_sb(dir), dir, mode, dev);
if (inode) {
dir->i_ctime = dir->i_mtime = current_time(dir);
d_instantiate(dentry, inode);
@@ -820,7 +820,7 @@ static int hugetlbfs_symlink(struct inode *dir,
struct inode *inode;
int error = -ENOSPC;
 
-   inode = hugetlbfs_get_inode(dir->i_sb, dir, S_IFLNK|S_IRWXUGO, 0);
+   inode = hugetlbfs_get_inode(inode_sb(dir), dir, S_IFLNK|S_IRWXUGO, 0);
if (inode) {
int l = strlen(symname)+1;
error = page_symlink(inode, symname, l);
@@ -1021,7 +1021,7 @@ static void hugetlbfs_i_callback(struct rcu_head *head)
 
 static void hugetlbfs_destroy_inode(struct inode *inode)
 {
-   hugetlbfs_inc_free_inodes(HUGETLBFS_SB(inode->i_sb));
+   hugetlbfs_inc_free_inodes(HUGETLBFS_SB(inode_sb(inode)));
mpol_free_shared_policy(_I(inode)->policy);
call_rcu(>i_rcu, hugetlbfs_i_callback);
 }
-- 
2.15.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 43/76] fs/jbd2: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/jbd2/journal.c | 18 +++---
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index 3fbf48ec2188..e1834a69cd41 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -1262,12 +1262,16 @@ journal_t *jbd2_journal_init_inode(struct inode *inode)
}
 
jbd_debug(1, "JBD2: inode %s/%ld, size %lld, bits %d, blksize %ld\n",
- inode->i_sb->s_id, inode->i_ino, (long long) inode->i_size,
- inode->i_sb->s_blocksize_bits, inode->i_sb->s_blocksize);
-
-   journal = journal_init_common(inode->i_sb->s_bdev, inode->i_sb->s_bdev,
-   blocknr, inode->i_size >> inode->i_sb->s_blocksize_bits,
-   inode->i_sb->s_blocksize);
+ inode_sb(inode)->s_id, inode->i_ino,
+ (long long) inode->i_size,
+ inode_sb(inode)->s_blocksize_bits,
+ inode_sb(inode)->s_blocksize);
+
+   journal = journal_init_common(inode_sb(inode)->s_bdev,
+ inode_sb(inode)->s_bdev,
+ blocknr,
+ inode->i_size >> 
inode_sb(inode)->s_blocksize_bits,
+ inode_sb(inode)->s_blocksize);
if (!journal)
return NULL;
 
@@ -2233,7 +2237,7 @@ void jbd2_journal_ack_err(journal_t *journal)
 
 int jbd2_journal_blocks_per_page(struct inode *inode)
 {
-   return 1 << (PAGE_SHIFT - inode->i_sb->s_blocksize_bits);
+   return 1 << (PAGE_SHIFT - inode_sb(inode)->s_blocksize_bits);
 }
 
 /*
-- 
2.15.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 42/76] fs/isofs: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/isofs/dir.c|  2 +-
 fs/isofs/export.c |  6 +++---
 fs/isofs/inode.c  | 22 --
 fs/isofs/joliet.c |  4 ++--
 fs/isofs/namei.c  |  4 ++--
 fs/isofs/rock.c   | 29 +++--
 6 files changed, 35 insertions(+), 32 deletions(-)

diff --git a/fs/isofs/dir.c b/fs/isofs/dir.c
index 947ce22f5b3c..1d3f1d10bea3 100644
--- a/fs/isofs/dir.c
+++ b/fs/isofs/dir.c
@@ -93,7 +93,7 @@ static int do_isofs_readdir(struct inode *inode, struct file 
*file,
int first_de = 1;
char *p = NULL; /* Quiet GCC */
struct iso_directory_record *de;
-   struct isofs_sb_info *sbi = ISOFS_SB(inode->i_sb);
+   struct isofs_sb_info *sbi = ISOFS_SB(inode_sb(inode));
 
offset = ctx->pos & (bufsize - 1);
block = ctx->pos >> bufbits;
diff --git a/fs/isofs/export.c b/fs/isofs/export.c
index 85a9093769a9..2bb64a3c1130 100644
--- a/fs/isofs/export.c
+++ b/fs/isofs/export.c
@@ -75,7 +75,7 @@ static struct dentry *isofs_export_get_parent(struct dentry 
*child)
parent_block = e_child_inode->i_iget5_block;
 
/* Get the block in question. */
-   bh = sb_bread(child_inode->i_sb, parent_block);
+   bh = sb_bread(inode_sb(child_inode), parent_block);
if (bh == NULL) {
rv = ERR_PTR(-EACCES);
goto out;
@@ -99,8 +99,8 @@ static struct dentry *isofs_export_get_parent(struct dentry 
*child)
/* Normalize */
isofs_normalize_block_and_offset(de, _block, _offset);
 
-   rv = d_obtain_alias(isofs_iget(child_inode->i_sb, parent_block,
-parent_offset));
+   rv = d_obtain_alias(isofs_iget(inode_sb(child_inode), parent_block,
+  parent_offset));
  out:
if (bh)
brelse(bh);
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
index bc258a4402f6..295830250d4b 100644
--- a/fs/isofs/inode.c
+++ b/fs/isofs/inode.c
@@ -1090,7 +1090,7 @@ int isofs_get_blocks(struct inode *inode, sector_t iblock,
struct inode *ninode;
 
offset += sect_size;
-   ninode = isofs_iget(inode->i_sb, nextblk, nextoff);
+   ninode = isofs_iget(inode_sb(inode), nextblk, nextoff);
if (IS_ERR(ninode)) {
error = PTR_ERR(ninode);
goto abort;
@@ -1113,9 +1113,11 @@ int isofs_get_blocks(struct inode *inode, sector_t 
iblock,
}
 
if (*bh) {
-   map_bh(*bh, inode->i_sb, firstext + b_off - offset);
+   map_bh(*bh, inode_sb(inode),
+  firstext + b_off - offset);
} else {
-   *bh = sb_getblk(inode->i_sb, firstext+b_off-offset);
+   *bh = sb_getblk(inode_sb(inode),
+   firstext+b_off-offset);
if (!*bh)
goto abort;
}
@@ -1165,7 +1167,7 @@ struct buffer_head *isofs_bread(struct inode *inode, 
sector_t block)
sector_t blknr = isofs_bmap(inode, block);
if (!blknr)
return NULL;
-   return sb_bread(inode->i_sb, blknr);
+   return sb_bread(inode_sb(inode), blknr);
 }
 
 static int isofs_readpage(struct file *file, struct page *page)
@@ -1193,7 +1195,7 @@ static const struct address_space_operations isofs_aops = 
{
 static int isofs_read_level3_size(struct inode *inode)
 {
unsigned long bufsize = ISOFS_BUFFER_SIZE(inode);
-   int high_sierra = ISOFS_SB(inode->i_sb)->s_high_sierra;
+   int high_sierra = ISOFS_SB(inode_sb(inode))->s_high_sierra;
struct buffer_head *bh = NULL;
unsigned long block, offset, block_saved, offset_saved;
int i = 0;
@@ -1217,7 +1219,7 @@ static int isofs_read_level3_size(struct inode *inode)
unsigned int de_len;
 
if (!bh) {
-   bh = sb_bread(inode->i_sb, block);
+   bh = sb_bread(inode_sb(inode), block);
if (!bh)
goto out_noread;
}
@@ -1250,7 +1252,7 @@ static int isofs_read_level3_size(struct inode *inode)
brelse(bh);
bh = NULL;
if (offset) {
-   bh = sb_bread(inode->i_sb, block);
+   bh = sb_bread(inode_sb(inode), block);
if (!bh)
goto out_noread;
memcpy((void *)tmpde+slop, bh->b_data, offset);
@@ -1295,7 +1297,7 @@ static int isofs_read_level3_size(struct inode *inode)
 
 static int isofs_read_inode(struct inode *inode, int relocated)
 {
-   struct super_block *sb = inode->i_sb;
+   

[PATCH 45/76] fs/jfs: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/jfs/acl.c  |   2 +-
 fs/jfs/file.c |   6 +--
 fs/jfs/inode.c|  14 +++
 fs/jfs/ioctl.c|   2 +-
 fs/jfs/jfs_discard.c  |  12 +++---
 fs/jfs/jfs_dmap.c | 104 +
 fs/jfs/jfs_dmap.h |   2 +-
 fs/jfs/jfs_dtree.c|  30 +++
 fs/jfs/jfs_dtree.h|   2 +-
 fs/jfs/jfs_extent.c   |  18 -
 fs/jfs/jfs_imap.c | 105 ++
 fs/jfs/jfs_incore.h   |   2 +-
 fs/jfs/jfs_inode.c|   2 +-
 fs/jfs/jfs_metapage.c |  20 +-
 fs/jfs/jfs_txnmgr.c   |  12 +++---
 fs/jfs/jfs_xtree.c|  65 ---
 fs/jfs/namei.c|  26 ++---
 fs/jfs/super.c|   2 +-
 fs/jfs/xattr.c|   8 ++--
 19 files changed, 222 insertions(+), 212 deletions(-)

diff --git a/fs/jfs/acl.c b/fs/jfs/acl.c
index 2e71b6e7e646..051c24c59ffa 100644
--- a/fs/jfs/acl.c
+++ b/fs/jfs/acl.c
@@ -111,7 +111,7 @@ int jfs_set_acl(struct inode *inode, struct posix_acl *acl, 
int type)
int update_mode = 0;
umode_t mode = inode->i_mode;
 
-   tid = txBegin(inode->i_sb, 0);
+   tid = txBegin(inode_sb(inode), 0);
mutex_lock(_IP(inode)->commit_mutex);
if (type == ACL_TYPE_ACCESS && acl) {
rc = posix_acl_update_mode(inode, , );
diff --git a/fs/jfs/file.c b/fs/jfs/file.c
index 36665fd37095..b4eb55e2b291 100644
--- a/fs/jfs/file.c
+++ b/fs/jfs/file.c
@@ -42,7 +42,7 @@ int jfs_fsync(struct file *file, loff_t start, loff_t end, 
int datasync)
if (!(inode->i_state & I_DIRTY_ALL) ||
(datasync && !(inode->i_state & I_DIRTY_DATASYNC))) {
/* Make sure committed changes hit the disk */
-   jfs_flush_journal(JFS_SBI(inode->i_sb)->log, 1);
+   jfs_flush_journal(JFS_SBI(inode_sb(inode))->log, 1);
inode_unlock(inode);
return rc;
}
@@ -74,7 +74,7 @@ static int jfs_open(struct inode *inode, struct file *file)
struct jfs_inode_info *ji = JFS_IP(inode);
spin_lock_irq(>ag_lock);
if (ji->active_ag == -1) {
-   struct jfs_sb_info *jfs_sb = JFS_SBI(inode->i_sb);
+   struct jfs_sb_info *jfs_sb = JFS_SBI(inode_sb(inode));
ji->active_ag = BLKTOAG(addressPXD(>ixpxd), jfs_sb);
atomic_inc(_sb->bmap->db_active[ji->active_ag]);
}
@@ -89,7 +89,7 @@ static int jfs_release(struct inode *inode, struct file *file)
 
spin_lock_irq(>ag_lock);
if (ji->active_ag != -1) {
-   struct bmap *bmap = JFS_SBI(inode->i_sb)->bmap;
+   struct bmap *bmap = JFS_SBI(inode_sb(inode))->bmap;
atomic_dec(>db_active[ji->active_ag]);
ji->active_ag = -1;
}
diff --git a/fs/jfs/inode.c b/fs/jfs/inode.c
index 054cc761b426..6cf6574c235c 100644
--- a/fs/jfs/inode.c
+++ b/fs/jfs/inode.c
@@ -110,7 +110,7 @@ int jfs_commit_inode(struct inode *inode, int wait)
return 0;
}
 
-   tid = txBegin(inode->i_sb, COMMIT_INODE);
+   tid = txBegin(inode_sb(inode), COMMIT_INODE);
mutex_lock(_IP(inode)->commit_mutex);
 
/*
@@ -137,7 +137,7 @@ int jfs_write_inode(struct inode *inode, struct 
writeback_control *wbc)
 */
if (!test_cflag(COMMIT_Dirty, inode)) {
/* Make sure committed changes hit the disk */
-   jfs_flush_journal(JFS_SBI(inode->i_sb)->log, wait);
+   jfs_flush_journal(JFS_SBI(inode_sb(inode))->log, wait);
return 0;
}
 
@@ -213,7 +213,7 @@ int jfs_get_block(struct inode *ip, sector_t lblock,
else
IREAD_LOCK(ip, RDWRLOCK_NORMAL);
 
-   if (((lblock64 << ip->i_sb->s_blocksize_bits) < ip->i_size) &&
+   if (((lblock64 << inode_sb(ip)->s_blocksize_bits) < ip->i_size) &&
(!xtLookup(ip, lblock64, xlen, , , , 0)) &&
xaddr) {
if (xflag & XAD_NOTRECORDED) {
@@ -241,7 +241,7 @@ int jfs_get_block(struct inode *ip, sector_t lblock,
set_buffer_new(bh_result);
}
 
-   map_bh(bh_result, ip->i_sb, xaddr);
+   map_bh(bh_result, inode_sb(ip), xaddr);
bh_result->b_size = xlen << ip->i_blkbits;
goto unlock;
}
@@ -252,14 +252,14 @@ int jfs_get_block(struct inode *ip, sector_t lblock,
 * Allocate a new block
 */
 #ifdef _JFS_4K
-   if ((rc = extHint(ip, lblock64 << ip->i_sb->s_blocksize_bits, )))
+   if ((rc = extHint(ip, lblock64 << inode_sb(ip)->s_blocksize_bits, 
)))
goto unlock;
rc = extAlloc(ip, xlen, lblock64, , false);
if (rc)
goto unlock;
 
set_buffer_new(bh_result);
-   map_bh(bh_result, ip->i_sb, addressXAD());
+   

[PATCH 48/76] fs/minix: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/minix/bitmap.c   | 18 ++
 fs/minix/dir.c  | 18 +-
 fs/minix/inode.c| 10 +-
 fs/minix/itree_common.c | 10 +-
 fs/minix/itree_v1.c |  6 +++---
 fs/minix/itree_v2.c |  2 +-
 fs/minix/minix.h|  2 +-
 fs/minix/namei.c|  6 +++---
 8 files changed, 37 insertions(+), 35 deletions(-)

diff --git a/fs/minix/bitmap.c b/fs/minix/bitmap.c
index f4e5e5181a14..c432f181e006 100644
--- a/fs/minix/bitmap.c
+++ b/fs/minix/bitmap.c
@@ -41,7 +41,7 @@ static __u32 count_free(struct buffer_head *map[], unsigned 
blocksize, __u32 num
 
 void minix_free_block(struct inode *inode, unsigned long block)
 {
-   struct super_block *sb = inode->i_sb;
+   struct super_block *sb = inode_sb(inode);
struct minix_sb_info *sbi = minix_sb(sb);
struct buffer_head *bh;
int k = sb->s_blocksize_bits + 3;
@@ -70,8 +70,8 @@ void minix_free_block(struct inode *inode, unsigned long 
block)
 
 int minix_new_block(struct inode * inode)
 {
-   struct minix_sb_info *sbi = minix_sb(inode->i_sb);
-   int bits_per_zone = 8 * inode->i_sb->s_blocksize;
+   struct minix_sb_info *sbi = minix_sb(inode_sb(inode));
+   int bits_per_zone = 8 * inode_sb(inode)->s_blocksize;
int i;
 
for (i = 0; i < sbi->s_zmap_blocks; i++) {
@@ -161,14 +161,16 @@ static void minix_clear_inode(struct inode *inode)
 
if (INODE_VERSION(inode) == MINIX_V1) {
struct minix_inode *raw_inode;
-   raw_inode = minix_V1_raw_inode(inode->i_sb, inode->i_ino, );
+   raw_inode = minix_V1_raw_inode(inode_sb(inode), inode->i_ino,
+  );
if (raw_inode) {
raw_inode->i_nlinks = 0;
raw_inode->i_mode = 0;
}
} else {
struct minix2_inode *raw_inode;
-   raw_inode = minix_V2_raw_inode(inode->i_sb, inode->i_ino, );
+   raw_inode = minix_V2_raw_inode(inode_sb(inode), inode->i_ino,
+  );
if (raw_inode) {
raw_inode->i_nlinks = 0;
raw_inode->i_mode = 0;
@@ -182,8 +184,8 @@ static void minix_clear_inode(struct inode *inode)
 
 void minix_free_inode(struct inode * inode)
 {
-   struct super_block *sb = inode->i_sb;
-   struct minix_sb_info *sbi = minix_sb(inode->i_sb);
+   struct super_block *sb = inode_sb(inode);
+   struct minix_sb_info *sbi = minix_sb(inode_sb(inode));
struct buffer_head *bh;
int k = sb->s_blocksize_bits + 3;
unsigned long ino, bit;
@@ -212,7 +214,7 @@ void minix_free_inode(struct inode * inode)
 
 struct inode *minix_new_inode(const struct inode *dir, umode_t mode, int 
*error)
 {
-   struct super_block *sb = dir->i_sb;
+   struct super_block *sb = inode_sb(dir);
struct minix_sb_info *sbi = minix_sb(sb);
struct inode *inode = new_inode(sb);
struct buffer_head * bh;
diff --git a/fs/minix/dir.c b/fs/minix/dir.c
index dcfe5b25378b..ea70fc396293 100644
--- a/fs/minix/dir.c
+++ b/fs/minix/dir.c
@@ -81,7 +81,7 @@ static inline void *minix_next_entry(void *de, struct 
minix_sb_info *sbi)
 static int minix_readdir(struct file *file, struct dir_context *ctx)
 {
struct inode *inode = file_inode(file);
-   struct super_block *sb = inode->i_sb;
+   struct super_block *sb = inode_sb(inode);
struct minix_sb_info *sbi = minix_sb(sb);
unsigned chunk_size = sbi->s_dirsize;
unsigned long npages = dir_pages(inode);
@@ -153,7 +153,7 @@ minix_dirent *minix_find_entry(struct dentry *dentry, 
struct page **res_page)
const char * name = dentry->d_name.name;
int namelen = dentry->d_name.len;
struct inode * dir = d_inode(dentry->d_parent);
-   struct super_block * sb = dir->i_sb;
+   struct super_block * sb = inode_sb(dir);
struct minix_sb_info * sbi = minix_sb(sb);
unsigned long n;
unsigned long npages = dir_pages(dir);
@@ -202,7 +202,7 @@ int minix_add_link(struct dentry *dentry, struct inode 
*inode)
struct inode *dir = d_inode(dentry->d_parent);
const char * name = dentry->d_name.name;
int namelen = dentry->d_name.len;
-   struct super_block * sb = dir->i_sb;
+   struct super_block * sb = inode_sb(dir);
struct minix_sb_info * sbi = minix_sb(sb);
struct page *page = NULL;
unsigned long npages = dir_pages(dir);
@@ -291,7 +291,7 @@ int minix_delete_entry(struct minix_dir_entry *de, struct 
page *page)
struct inode *inode = page->mapping->host;
char *kaddr = page_address(page);
loff_t pos = page_offset(page) + (char*)de - kaddr;
-   struct minix_sb_info *sbi = minix_sb(inode->i_sb);
+   struct minix_sb_info *sbi = minix_sb(inode_sb(inode));
  

[PATCH 47/76] fs/lockd: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/lockd/svclock.c | 8 
 fs/lockd/svcsubs.c | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c
index 3701bccab478..d13892c7bd89 100644
--- a/fs/lockd/svclock.c
+++ b/fs/lockd/svclock.c
@@ -405,7 +405,7 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file,
__be32  ret;
 
dprintk("lockd: nlmsvc_lock(%s/%ld, ty=%d, pi=%d, %Ld-%Ld, bl=%d)\n",
-   file_inode(file->f_file)->i_sb->s_id,
+   inode_sb(file_inode(file->f_file))->s_id,
file_inode(file->f_file)->i_ino,
lock->fl.fl_type, lock->fl.fl_pid,
(long long)lock->fl.fl_start,
@@ -511,7 +511,7 @@ nlmsvc_testlock(struct svc_rqst *rqstp, struct nlm_file 
*file,
__be32  ret;
 
dprintk("lockd: nlmsvc_testlock(%s/%ld, ty=%d, %Ld-%Ld)\n",
-   file_inode(file->f_file)->i_sb->s_id,
+   inode_sb(file_inode(file->f_file))->s_id,
file_inode(file->f_file)->i_ino,
lock->fl.fl_type,
(long long)lock->fl.fl_start,
@@ -566,7 +566,7 @@ nlmsvc_unlock(struct net *net, struct nlm_file *file, 
struct nlm_lock *lock)
int error;
 
dprintk("lockd: nlmsvc_unlock(%s/%ld, pi=%d, %Ld-%Ld)\n",
-   file_inode(file->f_file)->i_sb->s_id,
+   inode_sb(file_inode(file->f_file))->s_id,
file_inode(file->f_file)->i_ino,
lock->fl.fl_pid,
(long long)lock->fl.fl_start,
@@ -595,7 +595,7 @@ nlmsvc_cancel_blocked(struct net *net, struct nlm_file 
*file, struct nlm_lock *l
int status = 0;
 
dprintk("lockd: nlmsvc_cancel(%s/%ld, pi=%d, %Ld-%Ld)\n",
-   file_inode(file->f_file)->i_sb->s_id,
+   inode_sb(file_inode(file->f_file))->s_id,
file_inode(file->f_file)->i_ino,
lock->fl.fl_pid,
(long long)lock->fl.fl_start,
diff --git a/fs/lockd/svcsubs.c b/fs/lockd/svcsubs.c
index 4ec3d6e03e76..d29444c19cdc 100644
--- a/fs/lockd/svcsubs.c
+++ b/fs/lockd/svcsubs.c
@@ -47,7 +47,7 @@ static inline void nlm_debug_print_file(char *msg, struct 
nlm_file *file)
struct inode *inode = file_inode(file->f_file);
 
dprintk("lockd: %s %s/%ld\n",
-   msg, inode->i_sb->s_id, inode->i_ino);
+   msg, inode_sb(inode)->s_id, inode->i_ino);
 }
 #else
 static inline void nlm_debug_print_fh(char *msg, struct nfs_fh *f)
@@ -414,7 +414,7 @@ nlmsvc_match_sb(void *datap, struct nlm_file *file)
 {
struct super_block *sb = datap;
 
-   return sb == file_inode(file->f_file)->i_sb;
+   return sb == inode_sb(file_inode(file->f_file));
 }
 
 /**
-- 
2.15.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 49/76] fs/nfsd: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/nfsd/blocklayout.c | 4 ++--
 fs/nfsd/export.c  | 8 
 fs/nfsd/nfs4recover.c | 2 +-
 fs/nfsd/nfsctl.c  | 4 ++--
 fs/nfsd/nfssvc.c  | 5 +++--
 fs/nfsd/vfs.c | 8 
 6 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/fs/nfsd/blocklayout.c b/fs/nfsd/blocklayout.c
index 70b8bf781fce..66fe95fc7966 100644
--- a/fs/nfsd/blocklayout.c
+++ b/fs/nfsd/blocklayout.c
@@ -24,7 +24,7 @@ nfsd4_block_proc_layoutget(struct inode *inode, const struct 
svc_fh *fhp,
struct nfsd4_layoutget *args)
 {
struct nfsd4_layout_seg *seg = >lg_seg;
-   struct super_block *sb = inode->i_sb;
+   struct super_block *sb = inode_sb(inode);
u32 block_size = i_blocksize(inode);
struct pnfs_block_extent *bex;
struct iomap iomap;
@@ -134,7 +134,7 @@ nfsd4_block_commit_blocks(struct inode *inode, struct 
nfsd4_layoutcommit *lcp,
iattr.ia_size = new_size;
}
 
-   error = inode->i_sb->s_export_op->commit_blocks(inode, iomaps,
+   error = inode_sb(inode)->s_export_op->commit_blocks(inode, iomaps,
nr_iomaps, );
kfree(iomaps);
return nfserrno(error);
diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
index 8ceb25a10ea0..bd554e880415 100644
--- a/fs/nfsd/export.c
+++ b/fs/nfsd/export.c
@@ -366,15 +366,15 @@ static int check_export(struct inode *inode, int *flags, 
unsigned char *uuid)
 * 2:  We must be able to find an inode from a filehandle.
 *   This means that s_export_op must be set.
 */
-   if (!(inode->i_sb->s_type->fs_flags & FS_REQUIRES_DEV) &&
+   if (!(inode_sb(inode)->s_type->fs_flags & FS_REQUIRES_DEV) &&
!(*flags & NFSEXP_FSID) &&
uuid == NULL) {
dprintk("exp_export: export of non-dev fs without fsid\n");
return -EINVAL;
}
 
-   if (!inode->i_sb->s_export_op ||
-   !inode->i_sb->s_export_op->fh_to_dentry) {
+   if (!inode_sb(inode)->s_export_op ||
+   !inode_sb(inode)->s_export_op->fh_to_dentry) {
dprintk("exp_export: export of invalid fs type.\n");
return -EINVAL;
}
@@ -895,7 +895,7 @@ exp_rootfh(struct net *net, struct auth_domain *clp, char 
*name,
 
dprintk("nfsd: exp_rootfh(%s [%p] %s:%s/%ld)\n",
 name, path.dentry, clp->name,
-inode->i_sb->s_id, inode->i_ino);
+inode_sb(inode)->s_id, inode->i_ino);
exp = exp_parent(cd, clp, );
if (IS_ERR(exp)) {
err = PTR_ERR(exp);
diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c
index 66eaeb1e8c2c..11d6aeb74bc1 100644
--- a/fs/nfsd/nfs4recover.c
+++ b/fs/nfsd/nfs4recover.c
@@ -716,7 +716,7 @@ cld_pipe_downcall(struct file *filp, const char __user 
*src, size_t mlen)
struct cld_upcall *tmp, *cup;
struct cld_msg __user *cmsg = (struct cld_msg __user *)src;
uint32_t xid;
-   struct nfsd_net *nn = net_generic(file_inode(filp)->i_sb->s_fs_info,
+   struct nfsd_net *nn = net_generic(inode_sb(file_inode(filp))->s_fs_info,
nfsd_net_id);
struct cld_net *cn = nn->cld_net;
 
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
index d107b4426f7e..4b7473141f2d 100644
--- a/fs/nfsd/nfsctl.c
+++ b/fs/nfsd/nfsctl.c
@@ -162,7 +162,7 @@ static const struct file_operations exports_proc_operations 
= {
 
 static int exports_nfsd_open(struct inode *inode, struct file *file)
 {
-   return exports_net_open(inode->i_sb->s_fs_info, file);
+   return exports_net_open(inode_sb(inode)->s_fs_info, file);
 }
 
 static const struct file_operations exports_nfsd_operations = {
@@ -231,7 +231,7 @@ static const struct file_operations 
reply_cache_stats_operations = {
 
 static inline struct net *netns(struct file *file)
 {
-   return file_inode(file)->i_sb->s_fs_info;
+   return inode_sb(file_inode(file))->s_fs_info;
 }
 
 /**
diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
index 89cb484f1cfb..742755f6356a 100644
--- a/fs/nfsd/nfssvc.c
+++ b/fs/nfsd/nfssvc.c
@@ -866,7 +866,8 @@ nfsd_dispatch(struct svc_rqst *rqstp, __be32 *statp)
 int nfsd_pool_stats_open(struct inode *inode, struct file *file)
 {
int ret;
-   struct nfsd_net *nn = net_generic(inode->i_sb->s_fs_info, nfsd_net_id);
+   struct nfsd_net *nn = net_generic(inode_sb(inode)->s_fs_info,
+ nfsd_net_id);
 
mutex_lock(_mutex);
if (nn->nfsd_serv == NULL) {
@@ -883,7 +884,7 @@ int nfsd_pool_stats_open(struct inode *inode, struct file 
*file)
 int nfsd_pool_stats_release(struct inode *inode, struct file *file)
 {
int ret = seq_release(inode, file);
-   struct net *net = inode->i_sb->s_fs_info;
+   struct net *net = inode_sb(inode)->s_fs_info;
 
mutex_lock(_mutex);
/* this function really, really 

[PATCH 46/76] fs/kernfs: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/kernfs/dir.c   | 4 ++--
 fs/kernfs/inode.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
index 89d1dc19340b..1239244e826a 100644
--- a/fs/kernfs/dir.c
+++ b/fs/kernfs/dir.c
@@ -1059,7 +1059,7 @@ static struct dentry *kernfs_iop_lookup(struct inode *dir,
mutex_lock(_mutex);
 
if (kernfs_ns_enabled(parent))
-   ns = kernfs_info(dir->i_sb)->ns;
+   ns = kernfs_info(inode_sb(dir))->ns;
 
kn = kernfs_find_ns(parent, dentry->d_name.name, ns);
 
@@ -1070,7 +1070,7 @@ static struct dentry *kernfs_iop_lookup(struct inode *dir,
}
 
/* attach dentry and inode */
-   inode = kernfs_get_inode(dir->i_sb, kn);
+   inode = kernfs_get_inode(inode_sb(dir), kn);
if (!inode) {
ret = ERR_PTR(-ENOMEM);
goto out_unlock;
diff --git a/fs/kernfs/inode.c b/fs/kernfs/inode.c
index a34303981deb..7b005800d815 100644
--- a/fs/kernfs/inode.c
+++ b/fs/kernfs/inode.c
@@ -173,7 +173,7 @@ static inline void set_default_inode_attr(struct inode 
*inode, umode_t mode)
 
 static inline void set_inode_attr(struct inode *inode, struct iattr *iattr)
 {
-   struct super_block *sb = inode->i_sb;
+   struct super_block *sb = inode_sb(inode);
inode->i_uid = iattr->ia_uid;
inode->i_gid = iattr->ia_gid;
inode->i_atime = timespec_trunc(iattr->ia_atime, sb->s_time_gran);
-- 
2.15.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 51/76] fs/nilfs2: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/nilfs2/alloc.c   | 10 -
 fs/nilfs2/bmap.c|  4 ++--
 fs/nilfs2/btnode.c  |  6 +++---
 fs/nilfs2/btree.c   | 12 +--
 fs/nilfs2/cpfile.c  |  6 +++---
 fs/nilfs2/dat.c |  2 +-
 fs/nilfs2/dir.c | 24 ++---
 fs/nilfs2/direct.c  |  4 ++--
 fs/nilfs2/file.c| 19 
 fs/nilfs2/gcinode.c |  6 +++---
 fs/nilfs2/ifile.c   |  2 +-
 fs/nilfs2/inode.c   | 62 ++---
 fs/nilfs2/ioctl.c   | 60 +--
 fs/nilfs2/mdt.c | 10 -
 fs/nilfs2/mdt.h |  2 +-
 fs/nilfs2/namei.c   | 54 +++---
 fs/nilfs2/page.c|  2 +-
 fs/nilfs2/sufile.c  | 20 -
 fs/nilfs2/sufile.h  |  2 +-
 19 files changed, 154 insertions(+), 153 deletions(-)

diff --git a/fs/nilfs2/alloc.c b/fs/nilfs2/alloc.c
index 03b8ba933eb2..3b3af2e7b2fb 100644
--- a/fs/nilfs2/alloc.c
+++ b/fs/nilfs2/alloc.c
@@ -622,7 +622,7 @@ void nilfs_palloc_commit_free_entry(struct inode *inode,
lock = nilfs_mdt_bgl_lock(inode, group);
 
if (!nilfs_clear_bit_atomic(lock, group_offset, bitmap))
-   nilfs_msg(inode->i_sb, KERN_WARNING,
+   nilfs_msg(inode_sb(inode), KERN_WARNING,
  "%s (ino=%lu): entry number %llu already freed",
  __func__, inode->i_ino,
  (unsigned long long)req->pr_entry_nr);
@@ -663,7 +663,7 @@ void nilfs_palloc_abort_alloc_entry(struct inode *inode,
lock = nilfs_mdt_bgl_lock(inode, group);
 
if (!nilfs_clear_bit_atomic(lock, group_offset, bitmap))
-   nilfs_msg(inode->i_sb, KERN_WARNING,
+   nilfs_msg(inode_sb(inode), KERN_WARNING,
  "%s (ino=%lu): entry number %llu already freed",
  __func__, inode->i_ino,
  (unsigned long long)req->pr_entry_nr);
@@ -772,7 +772,7 @@ int nilfs_palloc_freev(struct inode *inode, __u64 
*entry_nrs, size_t nitems)
do {
if (!nilfs_clear_bit_atomic(lock, group_offset,
bitmap)) {
-   nilfs_msg(inode->i_sb, KERN_WARNING,
+   nilfs_msg(inode_sb(inode), KERN_WARNING,
  "%s (ino=%lu): entry number %llu 
already freed",
  __func__, inode->i_ino,
  (unsigned long long)entry_nrs[j]);
@@ -817,7 +817,7 @@ int nilfs_palloc_freev(struct inode *inode, __u64 
*entry_nrs, size_t nitems)
ret = nilfs_palloc_delete_entry_block(inode,
  last_nrs[k]);
if (ret && ret != -ENOENT)
-   nilfs_msg(inode->i_sb, KERN_WARNING,
+   nilfs_msg(inode_sb(inode), KERN_WARNING,
  "error %d deleting block that object 
(entry=%llu, ino=%lu) belongs to",
  ret, (unsigned long long)last_nrs[k],
  inode->i_ino);
@@ -835,7 +835,7 @@ int nilfs_palloc_freev(struct inode *inode, __u64 
*entry_nrs, size_t nitems)
if (nfree == nilfs_palloc_entries_per_group(inode)) {
ret = nilfs_palloc_delete_bitmap_block(inode, group);
if (ret && ret != -ENOENT)
-   nilfs_msg(inode->i_sb, KERN_WARNING,
+   nilfs_msg(inode_sb(inode), KERN_WARNING,
  "error %d deleting bitmap block of 
group=%lu, ino=%lu",
  ret, group, inode->i_ino);
}
diff --git a/fs/nilfs2/bmap.c b/fs/nilfs2/bmap.c
index 01fb1831ca25..9d466fb6e65f 100644
--- a/fs/nilfs2/bmap.c
+++ b/fs/nilfs2/bmap.c
@@ -30,7 +30,7 @@
 
 struct inode *nilfs_bmap_get_dat(const struct nilfs_bmap *bmap)
 {
-   struct the_nilfs *nilfs = bmap->b_inode->i_sb->s_fs_info;
+   struct the_nilfs *nilfs = inode_sb(bmap->b_inode)->s_fs_info;
 
return nilfs->ns_dat;
 }
@@ -41,7 +41,7 @@ static int nilfs_bmap_convert_error(struct nilfs_bmap *bmap,
struct inode *inode = bmap->b_inode;
 
if (err == -EINVAL) {
-   __nilfs_error(inode->i_sb, fname,
+   __nilfs_error(inode_sb(inode), fname,
  "broken bmap (inode number=%lu)", inode->i_ino);
err = -EIO;
}
diff --git a/fs/nilfs2/btnode.c b/fs/nilfs2/btnode.c
index c21e0b4454a6..87bc94f23271 100644
--- a/fs/nilfs2/btnode.c
+++ b/fs/nilfs2/btnode.c
@@ -51,7 +51,7 @@ nilfs_btnode_create_block(struct address_space *btnc, __u64 
blocknr)
BUG();
}

[PATCH 50/76] fs/nfs: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/nfs/blocklayout/rpc_pipefs.c|  2 +-
 fs/nfs/callback_proc.c |  4 ++--
 fs/nfs/dir.c   | 22 +-
 fs/nfs/export.c|  2 +-
 fs/nfs/file.c  |  4 ++--
 fs/nfs/filelayout/filelayout.c |  4 ++--
 fs/nfs/flexfilelayout/flexfilelayout.c |  6 ++---
 fs/nfs/fscache.c   |  2 +-
 fs/nfs/inode.c | 20 
 fs/nfs/internal.h  |  4 ++--
 fs/nfs/nfs42proc.c |  2 +-
 fs/nfs/nfs4proc.c  |  4 ++--
 fs/nfs/nfs4trace.h | 36 ++---
 fs/nfs/nfstrace.h  | 42 +-
 fs/nfs/pagelist.c  |  2 +-
 fs/nfs/pnfs.c  |  2 +-
 fs/nfs/read.c  |  4 ++--
 fs/nfs/unlink.c|  6 ++---
 18 files changed, 84 insertions(+), 84 deletions(-)

diff --git a/fs/nfs/blocklayout/rpc_pipefs.c b/fs/nfs/blocklayout/rpc_pipefs.c
index 9fb067a6f7e0..68a6176a4287 100644
--- a/fs/nfs/blocklayout/rpc_pipefs.c
+++ b/fs/nfs/blocklayout/rpc_pipefs.c
@@ -112,7 +112,7 @@ bl_resolve_deviceid(struct nfs_server *server, struct 
pnfs_block_volume *b,
 static ssize_t bl_pipe_downcall(struct file *filp, const char __user *src,
 size_t mlen)
 {
-   struct nfs_net *nn = net_generic(file_inode(filp)->i_sb->s_fs_info,
+   struct nfs_net *nn = net_generic(inode_sb(file_inode(filp))->s_fs_info,
 nfs_net_id);
 
if (mlen != sizeof (struct bl_dev_msg))
diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c
index a50d7813e3ea..73c5a7baf8a4 100644
--- a/fs/nfs/callback_proc.c
+++ b/fs/nfs/callback_proc.c
@@ -133,7 +133,7 @@ static struct inode 
*nfs_layout_find_inode_by_stateid(struct nfs_client *clp,
inode = igrab(lo->plh_inode);
if (!inode)
continue;
-   if (!nfs_sb_active(inode->i_sb)) {
+   if (!nfs_sb_active(inode_sb(inode))) {
rcu_read_unlock();
spin_unlock(>cl_lock);
iput(inode);
@@ -173,7 +173,7 @@ static struct inode *nfs_layout_find_inode_by_fh(struct 
nfs_client *clp,
inode = igrab(lo->plh_inode);
if (!inode)
continue;
-   if (!nfs_sb_active(inode->i_sb)) {
+   if (!nfs_sb_active(inode_sb(inode))) {
rcu_read_unlock();
spin_unlock(>cl_lock);
iput(inode);
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 2f3f86726f5b..3d150fa56e4f 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -1449,7 +1449,7 @@ int nfs_atomic_open(struct inode *dir, struct dentry 
*dentry,
BUG_ON(d_inode(dentry));
 
dfprintk(VFS, "NFS: atomic_open(%s/%lu), %pd\n",
-   dir->i_sb->s_id, dir->i_ino, dentry);
+   inode_sb(dir)->s_id, dir->i_ino, dentry);
 
err = nfs_check_flags(open_flags);
if (err)
@@ -1671,7 +1671,7 @@ int nfs_create(struct inode *dir, struct dentry *dentry,
int error;
 
dfprintk(VFS, "NFS: create(%s/%lu), %pd\n",
-   dir->i_sb->s_id, dir->i_ino, dentry);
+   inode_sb(dir)->s_id, dir->i_ino, dentry);
 
attr.ia_mode = mode;
attr.ia_valid = ATTR_MODE;
@@ -1698,7 +1698,7 @@ nfs_mknod(struct inode *dir, struct dentry *dentry, 
umode_t mode, dev_t rdev)
int status;
 
dfprintk(VFS, "NFS: mknod(%s/%lu), %pd\n",
-   dir->i_sb->s_id, dir->i_ino, dentry);
+   inode_sb(dir)->s_id, dir->i_ino, dentry);
 
attr.ia_mode = mode;
attr.ia_valid = ATTR_MODE;
@@ -1724,7 +1724,7 @@ int nfs_mkdir(struct inode *dir, struct dentry *dentry, 
umode_t mode)
int error;
 
dfprintk(VFS, "NFS: mkdir(%s/%lu), %pd\n",
-   dir->i_sb->s_id, dir->i_ino, dentry);
+   inode_sb(dir)->s_id, dir->i_ino, dentry);
 
attr.ia_valid = ATTR_MODE;
attr.ia_mode = mode | S_IFDIR;
@@ -1752,7 +1752,7 @@ int nfs_rmdir(struct inode *dir, struct dentry *dentry)
int error;
 
dfprintk(VFS, "NFS: rmdir(%s/%lu), %pd\n",
-   dir->i_sb->s_id, dir->i_ino, dentry);
+   inode_sb(dir)->s_id, dir->i_ino, dentry);
 
trace_nfs_rmdir_enter(dir, dentry);
if (d_really_is_positive(dentry)) {
@@ -1821,8 +1821,8 @@ int nfs_unlink(struct inode *dir, struct dentry *dentry)
int error;
int need_rehash = 0;
 
-   dfprintk(VFS, "NFS: 

[PATCH 53/76] fs/ntfs: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/ntfs/aops.c|  16 ++--
 fs/ntfs/bitmap.c  |  11 ++-
 fs/ntfs/dir.c |  10 ++-
 fs/ntfs/file.c|  30 ---
 fs/ntfs/inode.c   | 231 +-
 fs/ntfs/inode.h   |   2 +-
 fs/ntfs/logfile.c |  46 ++-
 fs/ntfs/namei.c   |   7 +-
 8 files changed, 214 insertions(+), 139 deletions(-)

diff --git a/fs/ntfs/aops.c b/fs/ntfs/aops.c
index 3a2e509c77c5..f8817dfdc2b8 100644
--- a/fs/ntfs/aops.c
+++ b/fs/ntfs/aops.c
@@ -1400,14 +1400,16 @@ static int ntfs_writepage(struct page *page, struct 
writeback_control *wbc)
// TODO: Implement and replace this with
// return ntfs_write_compressed_block(page);
unlock_page(page);
-   ntfs_error(vi->i_sb, "Writing to compressed files is "
+   ntfs_error(inode_sb(vi),
+   "Writing to compressed files is "
"not supported yet.  Sorry.");
return -EOPNOTSUPP;
}
// TODO: Implement and remove this check.
if (NInoNonResident(ni) && NInoSparse(ni)) {
unlock_page(page);
-   ntfs_error(vi->i_sb, "Writing to sparse files is not "
+   ntfs_error(inode_sb(vi),
+   "Writing to sparse files is not "
"supported yet.  Sorry.");
return -EOPNOTSUPP;
}
@@ -1437,7 +1439,7 @@ static int ntfs_writepage(struct page *page, struct 
writeback_control *wbc)
BUG_ON(page_has_buffers(page));
BUG_ON(!PageUptodate(page));
if (unlikely(page->index > 0)) {
-   ntfs_error(vi->i_sb, "BUG()! page->index (0x%lx) > 0.  "
+   ntfs_error(inode_sb(vi), "BUG()! page->index (0x%lx) > 0.  "
"Aborting write.", page->index);
BUG_ON(PageWriteback(page));
set_page_writeback(page);
@@ -1514,7 +1516,8 @@ static int ntfs_writepage(struct page *page, struct 
writeback_control *wbc)
return 0;
 err_out:
if (err == -ENOMEM) {
-   ntfs_warning(vi->i_sb, "Error allocating memory. Redirtying "
+   ntfs_warning(inode_sb(vi),
+   "Error allocating memory. Redirtying "
"page so we try again later.");
/*
 * Put the page back on mapping->dirty_pages, but leave its
@@ -1523,7 +1526,8 @@ static int ntfs_writepage(struct page *page, struct 
writeback_control *wbc)
redirty_page_for_writepage(wbc, page);
err = 0;
} else {
-   ntfs_error(vi->i_sb, "Resident attribute write failed with "
+   ntfs_error(inode_sb(vi),
+   "Resident attribute write failed with "
"error %i.", err);
SetPageError(page);
NVolSetErrors(ni->vol);
@@ -1735,7 +1739,7 @@ void mark_ntfs_record_dirty(struct page *page, const 
unsigned int ofs) {
 
BUG_ON(!PageUptodate(page));
end = ofs + ni->itype.index.block_size;
-   bh_size = VFS_I(ni)->i_sb->s_blocksize;
+   bh_size = inode_sb(VFS_I(ni))->s_blocksize;
spin_lock(>private_lock);
if (unlikely(!page_has_buffers(page))) {
spin_unlock(>private_lock);
diff --git a/fs/ntfs/bitmap.c b/fs/ntfs/bitmap.c
index ec130c588d2b..7584c413bdb5 100644
--- a/fs/ntfs/bitmap.c
+++ b/fs/ntfs/bitmap.c
@@ -75,7 +75,8 @@ int __ntfs_bitmap_set_bits_in_run(struct inode *vi, const s64 
start_bit,
page = ntfs_map_page(mapping, index);
if (IS_ERR(page)) {
if (!is_rollback)
-   ntfs_error(vi->i_sb, "Failed to map first page (error "
+   ntfs_error(inode_sb(vi),
+   "Failed to map first page (error "
"%li), aborting.", PTR_ERR(page));
return PTR_ERR(page);
}
@@ -177,15 +178,17 @@ int __ntfs_bitmap_set_bits_in_run(struct inode *vi, const 
s64 start_bit,
pos = 0;
if (!pos) {
/* Rollback was successful. */
-   ntfs_error(vi->i_sb, "Failed to map subsequent page (error "
+   ntfs_error(inode_sb(vi),
+   "Failed to map subsequent page (error "
"%li), aborting.", PTR_ERR(page));
} else {
/* Rollback failed. */
-   ntfs_error(vi->i_sb, "Failed to map subsequent page (error "
+   ntfs_error(inode_sb(vi),
+   "Failed to map subsequent page (error "
"%li) and rollback failed (error 

[PATCH 52/76] fs/notify: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/notify/fdinfo.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/notify/fdinfo.c b/fs/notify/fdinfo.c
index d478629c728b..857df5ce27ac 100644
--- a/fs/notify/fdinfo.c
+++ b/fs/notify/fdinfo.c
@@ -91,7 +91,8 @@ static void inotify_fdinfo(struct seq_file *m, struct 
fsnotify_mark *mark)
 */
u32 mask = mark->mask & IN_ALL_EVENTS;
seq_printf(m, "inotify wd:%x ino:%lx sdev:%x mask:%x 
ignored_mask:%x ",
-  inode_mark->wd, inode->i_ino, inode->i_sb->s_dev,
+  inode_mark->wd, inode->i_ino,
+  inode_sb(inode)->s_dev,
   mask, mark->ignored_mask);
show_mark_fhandle(m, inode);
seq_putc(m, '\n');
@@ -121,7 +122,7 @@ static void fanotify_fdinfo(struct seq_file *m, struct 
fsnotify_mark *mark)
if (!inode)
return;
seq_printf(m, "fanotify ino:%lx sdev:%x mflags:%x mask:%x 
ignored_mask:%x ",
-  inode->i_ino, inode->i_sb->s_dev,
+  inode->i_ino, inode_sb(inode)->s_dev,
   mflags, mark->mask, mark->ignored_mask);
show_mark_fhandle(m, inode);
seq_putc(m, '\n');
-- 
2.15.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 58/76] fs/overlayfs: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/overlayfs/export.c | 2 +-
 fs/overlayfs/inode.c  | 6 +++---
 fs/overlayfs/super.c  | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/overlayfs/export.c b/fs/overlayfs/export.c
index 87bd4148f4fb..41b23510f5b9 100644
--- a/fs/overlayfs/export.c
+++ b/fs/overlayfs/export.c
@@ -316,7 +316,7 @@ static struct dentry *ovl_obtain_alias(struct super_block 
*sb,
 
dentry = d_find_any_alias(inode);
if (!dentry) {
-   dentry = d_alloc_anon(inode->i_sb);
+   dentry = d_alloc_anon(inode_sb(inode));
if (!dentry)
goto nomem;
oe = ovl_alloc_entry(lower ? 1 : 0);
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index 3b1bd469accd..ebf2a857d547 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -199,7 +199,7 @@ int ovl_permission(struct inode *inode, int mask)
if (err)
return err;
 
-   old_cred = ovl_override_creds(inode->i_sb);
+   old_cred = ovl_override_creds(inode_sb(inode));
if (!upperinode &&
!special_file(realinode->i_mode) && mask & MAY_WRITE) {
mask &= ~(MAY_WRITE | MAY_APPEND);
@@ -342,7 +342,7 @@ struct posix_acl *ovl_get_acl(struct inode *inode, int type)
if (!IS_ENABLED(CONFIG_FS_POSIX_ACL) || !IS_POSIXACL(realinode))
return NULL;
 
-   old_cred = ovl_override_creds(inode->i_sb);
+   old_cred = ovl_override_creds(inode_sb(inode));
acl = get_acl(realinode, type);
revert_creds(old_cred);
 
@@ -445,7 +445,7 @@ static inline void 
ovl_lockdep_annotate_inode_mutex_key(struct inode *inode)
static struct lock_class_key ovl_i_mutex_dir_key[OVL_MAX_NESTING];
static struct lock_class_key ovl_i_lock_key[OVL_MAX_NESTING];
 
-   int depth = inode->i_sb->s_stack_depth - 1;
+   int depth = inode_sb(inode)->s_stack_depth - 1;
 
if (WARN_ON_ONCE(depth < 0 || depth >= OVL_MAX_NESTING))
depth = 0;
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index 7c24619ae7fc..bc04230f3ffb 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -127,7 +127,7 @@ static struct dentry *ovl_d_real(struct dentry *dentry,
return real;
 bug:
WARN(1, "ovl_d_real(%pd4, %s:%lu): real dentry not found\n", dentry,
-inode ? inode->i_sb->s_id : "NULL", inode ? inode->i_ino : 0);
+inode ? inode_sb(inode)->s_id : "NULL", inode ? inode->i_ino : 0);
return dentry;
 }
 
-- 
2.15.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 55/76] fs/omfs: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/omfs/dir.c   | 24 
 fs/omfs/file.c  | 37 +++--
 fs/omfs/inode.c | 19 ++-
 3 files changed, 41 insertions(+), 39 deletions(-)

diff --git a/fs/omfs/dir.c b/fs/omfs/dir.c
index b7146526afff..5a589c5a852f 100644
--- a/fs/omfs/dir.c
+++ b/fs/omfs/dir.c
@@ -28,7 +28,7 @@ static struct buffer_head *omfs_get_bucket(struct inode *dir,
int bucket = omfs_hash(name, namelen, nbuckets);
 
*ofs = OMFS_DIR_START + bucket * 8;
-   return omfs_bread(dir->i_sb, dir->i_ino);
+   return omfs_bread(inode_sb(dir), dir->i_ino);
 }
 
 static struct buffer_head *omfs_scan_list(struct inode *dir, u64 block,
@@ -41,14 +41,14 @@ static struct buffer_head *omfs_scan_list(struct inode 
*dir, u64 block,
*prev_block = ~0;
 
while (block != ~0) {
-   bh = omfs_bread(dir->i_sb, block);
+   bh = omfs_bread(inode_sb(dir), block);
if (!bh) {
err = -EIO;
goto err;
}
 
oi = (struct omfs_inode *) bh->b_data;
-   if (omfs_is_bad(OMFS_SB(dir->i_sb), >i_head, block)) {
+   if (omfs_is_bad(OMFS_SB(inode_sb(dir)), >i_head, block)) {
brelse(bh);
goto err;
}
@@ -131,7 +131,7 @@ static int omfs_add_link(struct dentry *dentry, struct 
inode *inode)
brelse(bh);
 
/* now set the sibling and parent pointers on the new inode */
-   bh = omfs_bread(dir->i_sb, inode->i_ino);
+   bh = omfs_bread(inode_sb(dir), inode->i_ino);
if (!bh)
goto out;
 
@@ -187,7 +187,7 @@ static int omfs_delete_entry(struct dentry *dentry)
if (prev != ~0) {
/* found in middle of list, get list ptr */
brelse(bh);
-   bh = omfs_bread(dir->i_sb, prev);
+   bh = omfs_bread(inode_sb(dir), prev);
if (!bh)
goto out;
 
@@ -199,7 +199,7 @@ static int omfs_delete_entry(struct dentry *dentry)
mark_buffer_dirty(bh);
 
if (prev != ~0) {
-   dirty = omfs_iget(dir->i_sb, prev);
+   dirty = omfs_iget(inode_sb(dir), prev);
if (!IS_ERR(dirty)) {
mark_inode_dirty(dirty);
iput(dirty);
@@ -220,7 +220,7 @@ static int omfs_dir_is_empty(struct inode *inode)
u64 *ptr;
int i;
 
-   bh = omfs_bread(inode->i_sb, inode->i_ino);
+   bh = omfs_bread(inode_sb(inode), inode->i_ino);
 
if (!bh)
return 0;
@@ -263,7 +263,7 @@ static int omfs_add_node(struct inode *dir, struct dentry 
*dentry, umode_t mode)
if (IS_ERR(inode))
return PTR_ERR(inode);
 
-   err = omfs_make_empty(inode, dir->i_sb);
+   err = omfs_make_empty(inode, inode_sb(dir));
if (err)
goto out_free_inode;
 
@@ -304,7 +304,7 @@ static struct dentry *omfs_lookup(struct inode *dir, struct 
dentry *dentry,
struct omfs_inode *oi = (struct omfs_inode *)bh->b_data;
ino_t ino = be64_to_cpu(oi->i_head.h_self);
brelse(bh);
-   inode = omfs_iget(dir->i_sb, ino);
+   inode = omfs_iget(inode_sb(dir), ino);
if (IS_ERR(inode))
return ERR_CAST(inode);
}
@@ -332,7 +332,7 @@ static bool omfs_fill_chain(struct inode *dir, struct 
dir_context *ctx,
 {
/* follow chain in this bucket */
while (fsblock != ~0) {
-   struct buffer_head *bh = omfs_bread(dir->i_sb, fsblock);
+   struct buffer_head *bh = omfs_bread(inode_sb(dir), fsblock);
struct omfs_inode *oi;
u64 self;
unsigned char d_type;
@@ -341,7 +341,7 @@ static bool omfs_fill_chain(struct inode *dir, struct 
dir_context *ctx,
return true;
 
oi = (struct omfs_inode *) bh->b_data;
-   if (omfs_is_bad(OMFS_SB(dir->i_sb), >i_head, fsblock)) {
+   if (omfs_is_bad(OMFS_SB(inode_sb(dir)), >i_head, fsblock)) {
brelse(bh);
return true;
}
@@ -428,7 +428,7 @@ static int omfs_readdir(struct file *file, struct 
dir_context *ctx)
hchain = (ctx->pos >> 20) - 1;
hindex = ctx->pos & 0xf;
 
-   bh = omfs_bread(dir->i_sb, dir->i_ino);
+   bh = omfs_bread(inode_sb(dir), dir->i_ino);
if (!bh)
return -EINVAL;
 
diff --git a/fs/omfs/file.c b/fs/omfs/file.c
index bf83e6644333..a714a3ba6d6a 100644
--- a/fs/omfs/file.c
+++ b/fs/omfs/file.c
@@ -30,7 +30,7 @@ void omfs_make_empty_table(struct buffer_head *bh, int offset)
 
 int omfs_shrink_inode(struct inode *inode)
 {
-   struct omfs_sb_info *sbi = OMFS_SB(inode->i_sb);
+   struct 

[PATCH 56/76] fs/openpromfs: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/openpromfs/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/openpromfs/inode.c b/fs/openpromfs/inode.c
index 2200662a9bf1..d1c59e6252c5 100644
--- a/fs/openpromfs/inode.c
+++ b/fs/openpromfs/inode.c
@@ -229,7 +229,7 @@ static struct dentry *openpromfs_lookup(struct inode *dir, 
struct dentry *dentry
return ERR_PTR(-ENOENT);
 
 found:
-   inode = openprom_iget(dir->i_sb, ino);
+   inode = openprom_iget(inode_sb(dir), ino);
mutex_unlock(_mutex);
if (IS_ERR(inode))
return ERR_CAST(inode);
-- 
2.15.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 57/76] fs/orangefs: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/orangefs/file.c|  2 +-
 fs/orangefs/namei.c   | 12 
 fs/orangefs/orangefs-kernel.h |  8 
 3 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/fs/orangefs/file.c b/fs/orangefs/file.c
index 0d228cd087e6..123a0c5b4a22 100644
--- a/fs/orangefs/file.c
+++ b/fs/orangefs/file.c
@@ -722,7 +722,7 @@ static int orangefs_lock(struct file *filp, int cmd, struct 
file_lock *fl)
 {
int rc = -EINVAL;
 
-   if (ORANGEFS_SB(file_inode(filp)->i_sb)->flags & 
ORANGEFS_OPT_LOCAL_LOCK) {
+   if (ORANGEFS_SB(inode_sb(file_inode(filp)))->flags & 
ORANGEFS_OPT_LOCAL_LOCK) {
if (cmd == F_GETLK) {
rc = 0;
posix_test_lock(filp, fl);
diff --git a/fs/orangefs/namei.c b/fs/orangefs/namei.c
index 6e3134e6d98a..79b76f8f0ba8 100644
--- a/fs/orangefs/namei.c
+++ b/fs/orangefs/namei.c
@@ -60,7 +60,8 @@ static int orangefs_create(struct inode *dir,
ref = new_op->downcall.resp.create.refn;
op_release(new_op);
 
-   inode = orangefs_new_inode(dir->i_sb, dir, S_IFREG | mode, 0, );
+   inode = orangefs_new_inode(inode_sb(dir), dir, S_IFREG | mode, 0,
+  );
if (IS_ERR(inode)) {
gossip_err("%s: Failed to allocate inode for file :%pd:\n",
   __func__,
@@ -192,7 +193,8 @@ static struct dentry *orangefs_lookup(struct inode *dir, 
struct dentry *dentry,
 
orangefs_set_timeout(dentry);
 
-   inode = orangefs_iget(dir->i_sb, _op->downcall.resp.lookup.refn);
+   inode = orangefs_iget(inode_sb(dir),
+ _op->downcall.resp.lookup.refn);
if (IS_ERR(inode)) {
gossip_debug(GOSSIP_NAME_DEBUG,
"error %ld from iget\n", PTR_ERR(inode));
@@ -320,7 +322,8 @@ static int orangefs_symlink(struct inode *dir,
ref = new_op->downcall.resp.sym.refn;
op_release(new_op);
 
-   inode = orangefs_new_inode(dir->i_sb, dir, S_IFLNK | mode, 0, );
+   inode = orangefs_new_inode(inode_sb(dir), dir, S_IFLNK | mode, 0,
+  );
if (IS_ERR(inode)) {
gossip_err
("*** Failed to allocate orangefs symlink inode\n");
@@ -391,7 +394,8 @@ static int orangefs_mkdir(struct inode *dir, struct dentry 
*dentry, umode_t mode
ref = new_op->downcall.resp.mkdir.refn;
op_release(new_op);
 
-   inode = orangefs_new_inode(dir->i_sb, dir, S_IFDIR | mode, 0, );
+   inode = orangefs_new_inode(inode_sb(dir), dir, S_IFDIR | mode, 0,
+  );
if (IS_ERR(inode)) {
gossip_err("*** Failed to allocate orangefs dir inode\n");
ret = PTR_ERR(inode);
diff --git a/fs/orangefs/orangefs-kernel.h b/fs/orangefs/orangefs-kernel.h
index eebbaece85ef..c006a3f6dedd 100644
--- a/fs/orangefs/orangefs-kernel.h
+++ b/fs/orangefs/orangefs-kernel.h
@@ -325,11 +325,11 @@ static inline int is_root_handle(struct inode *inode)
gossip_debug(GOSSIP_DCACHE_DEBUG,
 "%s: root handle: %pU, this handle: %pU:\n",
 __func__,
-_SB(inode->i_sb)->root_khandle,
+_SB(inode_sb(inode))->root_khandle,
 get_khandle_from_ino(inode));
 
-   if (ORANGEFS_khandle_cmp(&(ORANGEFS_SB(inode->i_sb)->root_khandle),
-get_khandle_from_ino(inode)))
+   if (ORANGEFS_khandle_cmp(&(ORANGEFS_SB(inode_sb(inode))->root_khandle),
+get_khandle_from_ino(inode)))
return 0;
else
return 1;
@@ -513,7 +513,7 @@ int service_operation(struct orangefs_kernel_op_s *op,
  int flags);
 
 #define get_interruptible_flag(inode) \
-   ((ORANGEFS_SB(inode->i_sb)->flags & ORANGEFS_OPT_INTR) ? \
+   ((ORANGEFS_SB(inode_sb(inode))->flags & ORANGEFS_OPT_INTR) ? \
ORANGEFS_OP_INTERRUPTIBLE : 0)
 
 #define fill_default_sys_attrs(sys_attr, type, mode)   \
-- 
2.15.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 59/76] fs/proc: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/proc/array.c   |  2 +-
 fs/proc/base.c| 22 --
 fs/proc/fd.c  |  4 ++--
 fs/proc/generic.c |  2 +-
 fs/proc/namespaces.c  |  2 +-
 fs/proc/nommu.c   |  2 +-
 fs/proc/proc_sysctl.c |  4 ++--
 fs/proc/self.c|  2 +-
 fs/proc/task_mmu.c|  2 +-
 fs/proc/task_nommu.c  |  2 +-
 fs/proc/thread_self.c |  2 +-
 11 files changed, 24 insertions(+), 22 deletions(-)

diff --git a/fs/proc/array.c b/fs/proc/array.c
index 598803576e4c..e7a668a89caf 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -687,7 +687,7 @@ static int children_seq_show(struct seq_file *seq, void *v)
struct inode *inode = seq->private;
pid_t pid;
 
-   pid = pid_nr_ns(v, inode->i_sb->s_fs_info);
+   pid = pid_nr_ns(v, inode_sb(inode)->s_fs_info);
seq_printf(seq, "%d ", pid);
 
return 0;
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 9298324325ed..a39fdd56f5d9 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -698,7 +698,7 @@ static bool has_pid_permissions(struct pid_namespace *pid,
 
 static int proc_pid_permission(struct inode *inode, int mask)
 {
-   struct pid_namespace *pid = inode->i_sb->s_fs_info;
+   struct pid_namespace *pid = inode_sb(inode)->s_fs_info;
struct task_struct *task;
bool has_perms;
 
@@ -738,7 +738,7 @@ static int proc_single_show(struct seq_file *m, void *v)
struct task_struct *task;
int ret;
 
-   ns = inode->i_sb->s_fs_info;
+   ns = inode_sb(inode)->s_fs_info;
pid = proc_pid(inode);
task = get_pid_task(pid, PIDTYPE_PID);
if (!task)
@@ -1410,7 +1410,7 @@ static const struct file_operations 
proc_fail_nth_operations = {
 static int sched_show(struct seq_file *m, void *v)
 {
struct inode *inode = m->private;
-   struct pid_namespace *ns = inode->i_sb->s_fs_info;
+   struct pid_namespace *ns = inode_sb(inode)->s_fs_info;
struct task_struct *p;
 
p = get_proc_task(inode);
@@ -2065,7 +2065,7 @@ proc_map_files_instantiate(struct inode *dir, struct 
dentry *dentry,
struct proc_inode *ei;
struct inode *inode;
 
-   inode = proc_pid_make_inode(dir->i_sb, task, S_IFLNK |
+   inode = proc_pid_make_inode(inode_sb(dir), task, S_IFLNK |
((mode & FMODE_READ ) ? S_IRUSR : 0) |
((mode & FMODE_WRITE) ? S_IWUSR : 0));
if (!inode)
@@ -2327,7 +2327,7 @@ static int proc_timers_open(struct inode *inode, struct 
file *file)
return -ENOMEM;
 
tp->pid = proc_pid(inode);
-   tp->ns = inode->i_sb->s_fs_info;
+   tp->ns = inode_sb(inode)->s_fs_info;
return 0;
 }
 
@@ -2432,7 +2432,7 @@ static int proc_pident_instantiate(struct inode *dir,
struct inode *inode;
struct proc_inode *ei;
 
-   inode = proc_pid_make_inode(dir->i_sb, task, p->mode);
+   inode = proc_pid_make_inode(inode_sb(dir), task, p->mode);
if (!inode)
goto out;
 
@@ -3137,7 +3137,8 @@ static int proc_pid_instantiate(struct inode *dir,
 {
struct inode *inode;
 
-   inode = proc_pid_make_inode(dir->i_sb, task, S_IFDIR | S_IRUGO | 
S_IXUGO);
+   inode = proc_pid_make_inode(inode_sb(dir), task,
+   S_IFDIR | S_IRUGO | S_IXUGO);
if (!inode)
goto out;
 
@@ -3232,7 +3233,7 @@ static struct tgid_iter next_tgid(struct pid_namespace 
*ns, struct tgid_iter ite
 int proc_pid_readdir(struct file *file, struct dir_context *ctx)
 {
struct tgid_iter iter;
-   struct pid_namespace *ns = file_inode(file)->i_sb->s_fs_info;
+   struct pid_namespace *ns = inode_sb(file_inode(file))->s_fs_info;
loff_t pos = ctx->pos;
 
if (pos >= PID_MAX_LIMIT + TGID_OFFSET)
@@ -3435,7 +3436,8 @@ static int proc_task_instantiate(struct inode *dir,
struct dentry *dentry, struct task_struct *task, const void *ptr)
 {
struct inode *inode;
-   inode = proc_pid_make_inode(dir->i_sb, task, S_IFDIR | S_IRUGO | 
S_IXUGO);
+   inode = proc_pid_make_inode(inode_sb(dir), task,
+   S_IFDIR | S_IRUGO | S_IXUGO);
 
if (!inode)
goto out;
@@ -3584,7 +3586,7 @@ static int proc_task_readdir(struct file *file, struct 
dir_context *ctx)
/* f_version caches the tgid value that the last readdir call couldn't
 * return. lseek aka telldir automagically resets f_version to 0.
 */
-   ns = inode->i_sb->s_fs_info;
+   ns = inode_sb(inode)->s_fs_info;
tid = (int)file->f_version;
file->f_version = 0;
for (task = first_tid(proc_pid(inode), tid, ctx->pos - 2, ns);
diff --git a/fs/proc/fd.c b/fs/proc/fd.c
index 6b80cd1e419a..818fe341c3e7 100644
--- a/fs/proc/fd.c
+++ b/fs/proc/fd.c
@@ -174,7 +174,7 @@ proc_fd_instantiate(struct inode *dir, struct dentry 
*dentry,

Re: send ioctl failed with -2

2018-05-08 Thread Noah Massey
On Tue, May 8, 2018 at 1:44 PM, Nicolas Porcel
 wrote:
> Hello,
>
> When I do a btrfs send, I get the following error code:
>
> # btrfs send mysnapshot > /dev/null
> ERROR: send ioctl failed with -2: No such file or directory
>

Silly question, but is 'mysnapshot' actually accessible at './mysnapshot' ?
Because the output from btrfs send should immediately output
'At subvol mysnapshot'

> I get it after 70-100% of the bytes are sent.
>

If 'btrfs send' is actually generating output, 'btrfs receive -vv' may
help "parse" the send stream enough to figure out where it is
terminating.

~ Noah

ps - I was going to suggest 'btrfs send -v'. According the the
manpage, that would "enable verbose output, print generated commands
in a readable form". But it does not seem to be working for me, and
after a quick glance at the code I'm not seeing how the ioctl call is
setting up any kind of verbose feedback. So that may be out-of-date
documentation.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 60/76] fs/qnx4: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/qnx4/dir.c   | 2 +-
 fs/qnx4/inode.c | 4 ++--
 fs/qnx4/namei.c | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/qnx4/dir.c b/fs/qnx4/dir.c
index a6ee23aadd28..c0e764ce79dd 100644
--- a/fs/qnx4/dir.c
+++ b/fs/qnx4/dir.c
@@ -31,7 +31,7 @@ static int qnx4_readdir(struct file *file, struct dir_context 
*ctx)
 
while (ctx->pos < inode->i_size) {
blknum = qnx4_block_map(inode, ctx->pos >> 
QNX4_BLOCK_SIZE_BITS);
-   bh = sb_bread(inode->i_sb, blknum);
+   bh = sb_bread(inode_sb(inode), blknum);
if (bh == NULL) {
printk(KERN_ERR "qnx4_readdir: bread failed (%ld)\n", 
blknum);
return 0;
diff --git a/fs/qnx4/inode.c b/fs/qnx4/inode.c
index 3d46fe302fcb..2b5e5b18e084 100644
--- a/fs/qnx4/inode.c
+++ b/fs/qnx4/inode.c
@@ -60,7 +60,7 @@ static int qnx4_get_block( struct inode *inode, sector_t 
iblock, struct buffer_h
phys = qnx4_block_map( inode, iblock );
if ( phys ) {
// logical block is before EOF
-   map_bh(bh, inode->i_sb, phys);
+   map_bh(bh, inode_sb(inode), phys);
}
return 0;
 }
@@ -94,7 +94,7 @@ unsigned long qnx4_block_map( struct inode *inode, long 
iblock )
while ( --nxtnt > 0 ) {
if ( ix == 0 ) {
// read next xtnt block.
-   bh = sb_bread(inode->i_sb, i_xblk - 1);
+   bh = sb_bread(inode_sb(inode), i_xblk - 1);
if ( !bh ) {
QNX4DEBUG((KERN_ERR "qnx4: I/O error 
reading xtnt block [%ld])\n", i_xblk - 1));
return -EIO;
diff --git a/fs/qnx4/namei.c b/fs/qnx4/namei.c
index eca27878079d..3a84a8f6c6a7 100644
--- a/fs/qnx4/namei.c
+++ b/fs/qnx4/namei.c
@@ -67,7 +67,7 @@ static struct buffer_head *qnx4_find_entry(int len, struct 
inode *dir,
if (!bh) {
block = qnx4_block_map(dir, blkofs);
if (block)
-   bh = sb_bread(dir->i_sb, block);
+   bh = sb_bread(inode_sb(dir), block);
if (!bh) {
blkofs++;
continue;
@@ -113,7 +113,7 @@ struct dentry * qnx4_lookup(struct inode *dir, struct 
dentry *dentry, unsigned i
}
brelse(bh);
 
-   foundinode = qnx4_iget(dir->i_sb, ino);
+   foundinode = qnx4_iget(inode_sb(dir), ino);
if (IS_ERR(foundinode)) {
QNX4DEBUG((KERN_ERR "qnx4: lookup->iget -> error %ld\n",
   PTR_ERR(foundinode)));
-- 
2.15.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 61/76] fs/qnx6: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/qnx6/dir.c   | 8 
 fs/qnx6/inode.c | 4 ++--
 fs/qnx6/namei.c | 2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/fs/qnx6/dir.c b/fs/qnx6/dir.c
index c1cfb8a19e9d..655d0eb9d82a 100644
--- a/fs/qnx6/dir.c
+++ b/fs/qnx6/dir.c
@@ -65,7 +65,7 @@ static int qnx6_dir_longfilename(struct inode *inode,
unsigned de_inode)
 {
struct qnx6_long_filename *lf;
-   struct super_block *s = inode->i_sb;
+   struct super_block *s = inode_sb(inode);
struct qnx6_sb_info *sbi = QNX6_SB(s);
struct page *page;
int lf_size;
@@ -112,7 +112,7 @@ static int qnx6_dir_longfilename(struct inode *inode,
 static int qnx6_readdir(struct file *file, struct dir_context *ctx)
 {
struct inode *inode = file_inode(file);
-   struct super_block *s = inode->i_sb;
+   struct super_block *s = inode_sb(inode);
struct qnx6_sb_info *sbi = QNX6_SB(s);
loff_t pos = ctx->pos & ~(QNX6_DIR_ENTRY_SIZE - 1);
unsigned long npages = dir_pages(inode);
@@ -175,7 +175,7 @@ static int qnx6_readdir(struct file *file, struct 
dir_context *ctx)
 static unsigned qnx6_long_match(int len, const char *name,
struct qnx6_long_dir_entry *de, struct inode *dir)
 {
-   struct super_block *s = dir->i_sb;
+   struct super_block *s = inode_sb(dir);
struct qnx6_sb_info *sbi = QNX6_SB(s);
struct page *page;
int thislen;
@@ -213,7 +213,7 @@ static unsigned qnx6_match(struct super_block *s, int len, 
const char *name,
 unsigned qnx6_find_entry(int len, struct inode *dir, const char *name,
 struct page **res_page)
 {
-   struct super_block *s = dir->i_sb;
+   struct super_block *s = inode_sb(dir);
struct qnx6_inode_info *ei = QNX6_I(dir);
struct page *page = NULL;
unsigned long start, n;
diff --git a/fs/qnx6/inode.c b/fs/qnx6/inode.c
index 4aeb26bcb4d0..4be77b89f11d 100644
--- a/fs/qnx6/inode.c
+++ b/fs/qnx6/inode.c
@@ -79,7 +79,7 @@ static int qnx6_get_block(struct inode *inode, sector_t 
iblock,
phys = qnx6_block_map(inode, iblock);
if (phys) {
/* logical block is before EOF */
-   map_bh(bh, inode->i_sb, phys);
+   map_bh(bh, inode_sb(inode), phys);
}
return 0;
 }
@@ -110,7 +110,7 @@ static int qnx6_readpages(struct file *file, struct 
address_space *mapping,
  */
 static unsigned qnx6_block_map(struct inode *inode, unsigned no)
 {
-   struct super_block *s = inode->i_sb;
+   struct super_block *s = inode_sb(inode);
struct qnx6_sb_info *sbi = QNX6_SB(s);
struct qnx6_inode_info *ei = QNX6_I(inode);
unsigned block = 0;
diff --git a/fs/qnx6/namei.c b/fs/qnx6/namei.c
index 72c2770830be..0b1a626c20d8 100644
--- a/fs/qnx6/namei.c
+++ b/fs/qnx6/namei.c
@@ -27,7 +27,7 @@ struct dentry *qnx6_lookup(struct inode *dir, struct dentry 
*dentry,
 
ino = qnx6_find_entry(len, dir, name, );
if (ino) {
-   foundinode = qnx6_iget(dir->i_sb, ino);
+   foundinode = qnx6_iget(inode_sb(dir), ino);
qnx6_put_page(page);
if (IS_ERR(foundinode)) {
pr_debug("lookup->iget ->  error %ld\n",
-- 
2.15.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 62/76] fs/quota: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/quota/dquot.c | 30 +++---
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 020c597ef9b6..ba6d549323cb 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -920,7 +920,7 @@ EXPORT_SYMBOL(dqget);
 
 static inline struct dquot **i_dquot(struct inode *inode)
 {
-   return inode->i_sb->s_op->get_dquots(inode);
+   return inode_sb(inode)->s_op->get_dquots(inode);
 }
 
 static int dqinit_needed(struct inode *inode, int type)
@@ -1406,7 +1406,7 @@ static int info_bdq_free(struct dquot *dquot, qsize_t 
space)
 
 static int dquot_active(const struct inode *inode)
 {
-   struct super_block *sb = inode->i_sb;
+   struct super_block *sb = inode_sb(inode);
 
if (IS_NOQUOTA(inode))
return 0;
@@ -1423,7 +1423,7 @@ static int __dquot_initialize(struct inode *inode, int 
type)
 {
int cnt, init_needed = 0;
struct dquot **dquots, *got[MAXQUOTAS] = {};
-   struct super_block *sb = inode->i_sb;
+   struct super_block *sb = inode_sb(inode);
qsize_t rsv;
int ret = 0;
 
@@ -1462,7 +1462,7 @@ static int __dquot_initialize(struct inode *inode, int 
type)
qid = make_kqid_gid(inode->i_gid);
break;
case PRJQUOTA:
-   rc = inode->i_sb->dq_op->get_projid(inode, );
+   rc = inode_sb(inode)->dq_op->get_projid(inode, );
if (rc)
continue;
qid = make_kqid_projid(projid);
@@ -1540,7 +1540,7 @@ bool dquot_initialize_needed(struct inode *inode)
 
dquots = i_dquot(inode);
for (i = 0; i < MAXQUOTAS; i++)
-   if (!dquots[i] && sb_has_quota_active(inode->i_sb, i))
+   if (!dquots[i] && sb_has_quota_active(inode_sb(inode), i))
return true;
return false;
 }
@@ -1603,13 +1603,13 @@ static qsize_t *inode_reserved_space(struct inode * 
inode)
 {
/* Filesystem must explicitly define it's own method in order to use
 * quota reservation interface */
-   BUG_ON(!inode->i_sb->dq_op->get_reserved_space);
-   return inode->i_sb->dq_op->get_reserved_space(inode);
+   BUG_ON(!inode_sb(inode)->dq_op->get_reserved_space);
+   return inode_sb(inode)->dq_op->get_reserved_space(inode);
 }
 
 static qsize_t __inode_get_rsv_space(struct inode *inode)
 {
-   if (!inode->i_sb->dq_op->get_reserved_space)
+   if (!inode_sb(inode)->dq_op->get_reserved_space)
return 0;
return *inode_reserved_space(inode);
 }
@@ -1618,7 +1618,7 @@ static qsize_t inode_get_rsv_space(struct inode *inode)
 {
qsize_t ret;
 
-   if (!inode->i_sb->dq_op->get_reserved_space)
+   if (!inode_sb(inode)->dq_op->get_reserved_space)
return 0;
spin_lock(>i_lock);
ret = __inode_get_rsv_space(inode);
@@ -1955,8 +1955,8 @@ int __dquot_transfer(struct inode *inode, struct dquot 
**transfer_to)
if (IS_NOQUOTA(inode))
return 0;
 
-   if (inode->i_sb->dq_op->get_inode_usage) {
-   ret = inode->i_sb->dq_op->get_inode_usage(inode, _usage);
+   if (inode_sb(inode)->dq_op->get_inode_usage) {
+   ret = inode_sb(inode)->dq_op->get_inode_usage(inode, 
_usage);
if (ret)
return ret;
}
@@ -1988,7 +1988,7 @@ int __dquot_transfer(struct inode *inode, struct dquot 
**transfer_to)
if (!transfer_to[cnt])
continue;
/* Avoid races with quotaoff() */
-   if (!sb_has_quota_active(inode->i_sb, cnt))
+   if (!sb_has_quota_active(inode_sb(inode), cnt))
continue;
is_valid[cnt] = 1;
transfer_from[cnt] = i_dquot(inode)[cnt];
@@ -2070,7 +2070,7 @@ int dquot_transfer(struct inode *inode, struct iattr 
*iattr)
 {
struct dquot *transfer_to[MAXQUOTAS] = {};
struct dquot *dquot;
-   struct super_block *sb = inode->i_sb;
+   struct super_block *sb = inode_sb(inode);
int ret;
 
if (!dquot_active(inode))
@@ -2302,7 +2302,7 @@ static int vfs_load_quota_inode(struct inode *inode, int 
type, int format_id,
unsigned int flags)
 {
struct quota_format_type *fmt = find_quota_format(format_id);
-   struct super_block *sb = inode->i_sb;
+   struct super_block *sb = inode_sb(inode);
struct quota_info *dqopt = sb_dqopt(sb);
int error;
 
@@ -2464,7 +2464,7 @@ EXPORT_SYMBOL(dquot_quota_on);
 int dquot_enable(struct inode *inode, int type, int format_id,
 unsigned int flags)
 {
-   struct super_block *sb = inode->i_sb;
+   struct super_block *sb = inode_sb(inode);
 
/* Just unsuspend quotas? */
BUG_ON(flags & DQUOT_SUSPENDED);
-- 

[PATCH 64/76] fs/read: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/read_write.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/fs/read_write.c b/fs/read_write.c
index f8547b82dfb3..cf9900707558 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -146,7 +146,7 @@ loff_t generic_file_llseek(struct file *file, loff_t 
offset, int whence)
struct inode *inode = file->f_mapping->host;
 
return generic_file_llseek_size(file, offset, whence,
-   inode->i_sb->s_maxbytes,
+   inode_sb(inode)->s_maxbytes,
i_size_read(inode));
 }
 EXPORT_SYMBOL(generic_file_llseek);
@@ -1389,7 +1389,8 @@ static ssize_t do_sendfile(int out_fd, int in_fd, loff_t 
*ppos,
goto fput_out;
 
if (!max)
-   max = min(in_inode->i_sb->s_maxbytes, 
out_inode->i_sb->s_maxbytes);
+   max = min(inode_sb(in_inode)->s_maxbytes,
+ inode_sb(out_inode)->s_maxbytes);
 
if (unlikely(pos + count > max)) {
retval = -EOVERFLOW;
@@ -1549,7 +1550,7 @@ ssize_t vfs_copy_file_range(struct file *file_in, loff_t 
pos_in,
return -EBADF;
 
/* this could be relaxed once a method supports cross-fs copies */
-   if (inode_in->i_sb != inode_out->i_sb)
+   if (inode_sb(inode_in) != inode_sb(inode_out))
return -EXDEV;
 
if (len == 0)
@@ -1694,7 +1695,7 @@ int vfs_clone_file_prep_inodes(struct inode *inode_in, 
loff_t pos_in,
   struct inode *inode_out, loff_t pos_out,
   u64 *len, bool is_dedupe)
 {
-   loff_t bs = inode_out->i_sb->s_blocksize;
+   loff_t bs = inode_sb(inode_out)->s_blocksize;
loff_t blen;
loff_t isize;
bool same_inode = (inode_in == inode_out);
@@ -1808,7 +1809,7 @@ int vfs_clone_file_range(struct file *file_in, loff_t 
pos_in,
 * the same mount. Practically, they only need to be on the same file
 * system.
 */
-   if (inode_in->i_sb != inode_out->i_sb)
+   if (inode_sb(inode_in) != inode_sb(inode_out))
return -EXDEV;
 
if (!(file_in->f_mode & FMODE_READ) ||
-- 
2.15.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 67/76] fs/squashfs: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/squashfs/dir.c | 26 ++
 fs/squashfs/export.c  |  2 +-
 fs/squashfs/file.c| 34 ++
 fs/squashfs/file_cache.c  |  5 +++--
 fs/squashfs/file_direct.c |  9 +
 fs/squashfs/inode.c   |  2 +-
 fs/squashfs/namei.c   | 28 
 fs/squashfs/symlink.c |  2 +-
 fs/squashfs/xattr.c   |  4 ++--
 9 files changed, 61 insertions(+), 51 deletions(-)

diff --git a/fs/squashfs/dir.c b/fs/squashfs/dir.c
index a5845f94a2a1..c184017e4e70 100644
--- a/fs/squashfs/dir.c
+++ b/fs/squashfs/dir.c
@@ -110,7 +110,7 @@ static int get_dir_index_using_offset(struct super_block 
*sb,
 static int squashfs_readdir(struct file *file, struct dir_context *ctx)
 {
struct inode *inode = file_inode(file);
-   struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info;
+   struct squashfs_sb_info *msblk = inode_sb(inode)->s_fs_info;
u64 block = squashfs_i(inode)->start + msblk->directory_table;
int offset = squashfs_i(inode)->offset, length, err;
unsigned int inode_number, dir_count, size, type;
@@ -154,18 +154,18 @@ static int squashfs_readdir(struct file *file, struct 
dir_context *ctx)
ctx->pos += size;
}
 
-   length = get_dir_index_using_offset(inode->i_sb, , ,
-   squashfs_i(inode)->dir_idx_start,
-   squashfs_i(inode)->dir_idx_offset,
-   squashfs_i(inode)->dir_idx_cnt,
-   ctx->pos);
+   length = get_dir_index_using_offset(inode_sb(inode), , ,
+   squashfs_i(inode)->dir_idx_start,
+   squashfs_i(inode)->dir_idx_offset,
+   squashfs_i(inode)->dir_idx_cnt,
+   ctx->pos);
 
while (length < i_size_read(inode)) {
/*
 * Read directory header
 */
-   err = squashfs_read_metadata(inode->i_sb, , ,
-   , sizeof(dirh));
+   err = squashfs_read_metadata(inode_sb(inode), , ,
+, sizeof(dirh));
if (err < 0)
goto failed_read;
 
@@ -180,8 +180,9 @@ static int squashfs_readdir(struct file *file, struct 
dir_context *ctx)
/*
 * Read directory entry.
 */
-   err = squashfs_read_metadata(inode->i_sb, dire, ,
-   , sizeof(*dire));
+   err = squashfs_read_metadata(inode_sb(inode), dire,
+,
+, sizeof(*dire));
if (err < 0)
goto failed_read;
 
@@ -191,8 +192,9 @@ static int squashfs_readdir(struct file *file, struct 
dir_context *ctx)
if (size > SQUASHFS_NAME_LEN)
goto failed_read;
 
-   err = squashfs_read_metadata(inode->i_sb, dire->name,
-   , , size);
+   err = squashfs_read_metadata(inode_sb(inode),
+dire->name,
+, , size);
if (err < 0)
goto failed_read;
 
diff --git a/fs/squashfs/export.c b/fs/squashfs/export.c
index 8073b6532cf0..ce7615f66d5c 100644
--- a/fs/squashfs/export.c
+++ b/fs/squashfs/export.c
@@ -113,7 +113,7 @@ static struct dentry *squashfs_get_parent(struct dentry 
*child)
struct inode *inode = d_inode(child);
unsigned int parent_ino = squashfs_i(inode)->parent;
 
-   return squashfs_export_iget(inode->i_sb, parent_ino);
+   return squashfs_export_iget(inode_sb(inode), parent_ino);
 }
 
 
diff --git a/fs/squashfs/file.c b/fs/squashfs/file.c
index 13d80947bf9e..afad108e0d36 100644
--- a/fs/squashfs/file.c
+++ b/fs/squashfs/file.c
@@ -61,7 +61,7 @@ static struct meta_index *locate_meta_index(struct inode 
*inode, int offset,
int index)
 {
struct meta_index *meta = NULL;
-   struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info;
+   struct squashfs_sb_info *msblk = inode_sb(inode)->s_fs_info;
int i;
 
mutex_lock(>meta_index_mutex);
@@ -99,7 +99,7 @@ static struct meta_index *locate_meta_index(struct inode 
*inode, int offset,
 static struct meta_index *empty_meta_index(struct inode *inode, int offset,
int skip)
 {
-   struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info;
+   struct squashfs_sb_info *msblk = 

[PATCH 63/76] fs/ramfs: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/ramfs/inode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c
index 11201b2d06b9..57b78ae51ed1 100644
--- a/fs/ramfs/inode.c
+++ b/fs/ramfs/inode.c
@@ -101,7 +101,7 @@ struct inode *ramfs_get_inode(struct super_block *sb,
 static int
 ramfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
 {
-   struct inode * inode = ramfs_get_inode(dir->i_sb, dir, mode, dev);
+   struct inode * inode = ramfs_get_inode(inode_sb(dir), dir, mode, dev);
int error = -ENOSPC;
 
if (inode) {
@@ -131,7 +131,7 @@ static int ramfs_symlink(struct inode * dir, struct dentry 
*dentry, const char *
struct inode *inode;
int error = -ENOSPC;
 
-   inode = ramfs_get_inode(dir->i_sb, dir, S_IFLNK|S_IRWXUGO, 0);
+   inode = ramfs_get_inode(inode_sb(dir), dir, S_IFLNK|S_IRWXUGO, 0);
if (inode) {
int l = strlen(symname)+1;
error = page_symlink(inode, symname, l);
-- 
2.15.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 68/76] fs/sysv: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/sysv/dir.c| 12 ++--
 fs/sysv/ialloc.c |  8 
 fs/sysv/inode.c  |  6 +++---
 fs/sysv/itree.c  | 29 +++--
 fs/sysv/namei.c  |  4 ++--
 5 files changed, 30 insertions(+), 29 deletions(-)

diff --git a/fs/sysv/dir.c b/fs/sysv/dir.c
index 88e38cd8f5c9..84a11fda6a28 100644
--- a/fs/sysv/dir.c
+++ b/fs/sysv/dir.c
@@ -65,7 +65,7 @@ static int sysv_readdir(struct file *file, struct dir_context 
*ctx)
 {
unsigned long pos = ctx->pos;
struct inode *inode = file_inode(file);
-   struct super_block *sb = inode->i_sb;
+   struct super_block *sb = inode_sb(inode);
unsigned long npages = dir_pages(inode);
unsigned offset;
unsigned long n;
@@ -214,7 +214,7 @@ int sysv_add_link(struct dentry *dentry, struct inode 
*inode)
goto out_unlock;
memcpy (de->name, name, namelen);
memset (de->name + namelen, 0, SYSV_DIRSIZE - namelen - 2);
-   de->inode = cpu_to_fs16(SYSV_SB(inode->i_sb), inode->i_ino);
+   de->inode = cpu_to_fs16(SYSV_SB(inode_sb(inode)), inode->i_ino);
err = dir_commit_chunk(page, pos, SYSV_DIRSIZE);
dir->i_mtime = dir->i_ctime = current_time(dir);
mark_inode_dirty(dir);
@@ -265,10 +265,10 @@ int sysv_make_empty(struct inode *inode, struct inode 
*dir)
memset(base, 0, PAGE_SIZE);
 
de = (struct sysv_dir_entry *) base;
-   de->inode = cpu_to_fs16(SYSV_SB(inode->i_sb), inode->i_ino);
+   de->inode = cpu_to_fs16(SYSV_SB(inode_sb(inode)), inode->i_ino);
strcpy(de->name,".");
de++;
-   de->inode = cpu_to_fs16(SYSV_SB(inode->i_sb), dir->i_ino);
+   de->inode = cpu_to_fs16(SYSV_SB(inode_sb(inode)), dir->i_ino);
strcpy(de->name,"..");
 
kunmap(page);
@@ -283,7 +283,7 @@ int sysv_make_empty(struct inode *inode, struct inode *dir)
  */
 int sysv_empty_dir(struct inode * inode)
 {
-   struct super_block *sb = inode->i_sb;
+   struct super_block *sb = inode_sb(inode);
struct page *page = NULL;
unsigned long i, npages = dir_pages(inode);
 
@@ -335,7 +335,7 @@ void sysv_set_link(struct sysv_dir_entry *de, struct page 
*page,
lock_page(page);
err = sysv_prepare_chunk(page, pos, SYSV_DIRSIZE);
BUG_ON(err);
-   de->inode = cpu_to_fs16(SYSV_SB(inode->i_sb), inode->i_ino);
+   de->inode = cpu_to_fs16(SYSV_SB(inode_sb(inode)), inode->i_ino);
err = dir_commit_chunk(page, pos, SYSV_DIRSIZE);
dir_put_page(page);
dir->i_mtime = dir->i_ctime = current_time(dir);
diff --git a/fs/sysv/ialloc.c b/fs/sysv/ialloc.c
index 6c9801986af6..2515367bf047 100644
--- a/fs/sysv/ialloc.c
+++ b/fs/sysv/ialloc.c
@@ -100,14 +100,14 @@ static int refill_free_cache(struct super_block *sb)
 
 void sysv_free_inode(struct inode * inode)
 {
-   struct super_block *sb = inode->i_sb;
+   struct super_block *sb = inode_sb(inode);
struct sysv_sb_info *sbi = SYSV_SB(sb);
unsigned int ino;
struct buffer_head * bh;
struct sysv_inode * raw_inode;
unsigned count;
 
-   sb = inode->i_sb;
+   sb = inode_sb(inode);
ino = inode->i_ino;
if (ino <= SYSV_ROOT_INO || ino > sbi->s_ninodes) {
printk("sysv_free_inode: inode 0,1,2 or nonexistent inode\n");
@@ -116,7 +116,7 @@ void sysv_free_inode(struct inode * inode)
raw_inode = sysv_raw_inode(sb, ino, );
if (!raw_inode) {
printk("sysv_free_inode: unable to read inode block on device "
-  "%s\n", inode->i_sb->s_id);
+  "%s\n", inode_sb(inode)->s_id);
return;
}
mutex_lock(>s_lock);
@@ -135,7 +135,7 @@ void sysv_free_inode(struct inode * inode)
 
 struct inode * sysv_new_inode(const struct inode * dir, umode_t mode)
 {
-   struct super_block *sb = dir->i_sb;
+   struct super_block *sb = inode_sb(dir);
struct sysv_sb_info *sbi = SYSV_SB(sb);
struct inode *inode;
sysv_ino_t ino;
diff --git a/fs/sysv/inode.c b/fs/sysv/inode.c
index bec9f79adb25..9d04a4a2c248 100644
--- a/fs/sysv/inode.c
+++ b/fs/sysv/inode.c
@@ -192,7 +192,7 @@ struct inode *sysv_iget(struct super_block *sb, unsigned 
int ino)
raw_inode = sysv_raw_inode(sb, ino, );
if (!raw_inode) {
printk("Major problem: unable to read inode from dev %s\n",
-  inode->i_sb->s_id);
+  inode_sb(inode)->s_id);
goto bad_inode;
}
/* SystemV FS: kludge permissions if ino==SYSV_ROOT_INO ?? */
@@ -230,7 +230,7 @@ struct inode *sysv_iget(struct super_block *sb, unsigned 
int ino)
 
 static int __sysv_write_inode(struct inode *inode, int wait)
 {
-   struct super_block * sb = inode->i_sb;
+   struct super_block * sb = inode_sb(inode);
struct sysv_sb_info * sbi = SYSV_SB(sb);
struct buffer_head * bh;
   

[PATCH 66/76] fs/romfs: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/romfs/mmap-nommu.c |  4 ++--
 fs/romfs/super.c  | 24 +---
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/fs/romfs/mmap-nommu.c b/fs/romfs/mmap-nommu.c
index 1118a0dc6b45..0dbf9be30283 100644
--- a/fs/romfs/mmap-nommu.c
+++ b/fs/romfs/mmap-nommu.c
@@ -26,7 +26,7 @@ static unsigned long romfs_get_unmapped_area(struct file 
*file,
 unsigned long flags)
 {
struct inode *inode = file->f_mapping->host;
-   struct mtd_info *mtd = inode->i_sb->s_mtd;
+   struct mtd_info *mtd = inode_sb(inode)->s_mtd;
unsigned long isize, offset, maxpages, lpages;
int ret;
 
@@ -72,7 +72,7 @@ static int romfs_mmap(struct file *file, struct 
vm_area_struct *vma)
 
 static unsigned romfs_mmap_capabilities(struct file *file)
 {
-   struct mtd_info *mtd = file_inode(file)->i_sb->s_mtd;
+   struct mtd_info *mtd = inode_sb(file_inode(file))->s_mtd;
 
if (!mtd)
return NOMMU_MAP_COPY;
diff --git a/fs/romfs/super.c b/fs/romfs/super.c
index 8f06fd1f3d69..eb0b7d3775bb 100644
--- a/fs/romfs/super.c
+++ b/fs/romfs/super.c
@@ -122,7 +122,7 @@ static int romfs_readpage(struct file *file, struct page 
*page)
 
pos = ROMFS_I(inode)->i_dataoffset + offset;
 
-   ret = romfs_dev_read(inode->i_sb, pos, buf, fillsize);
+   ret = romfs_dev_read(inode_sb(inode), pos, buf, fillsize);
if (ret < 0) {
SetPageError(page);
fillsize = 0;
@@ -157,12 +157,12 @@ static int romfs_readdir(struct file *file, struct 
dir_context *ctx)
char fsname[ROMFS_MAXFN];   /* XXX dynamic? */
int ret;
 
-   maxoff = romfs_maxsize(i->i_sb);
+   maxoff = romfs_maxsize(inode_sb(i));
 
offset = ctx->pos;
if (!offset) {
offset = i->i_ino & ROMFH_MASK;
-   ret = romfs_dev_read(i->i_sb, offset, , ROMFH_SIZE);
+   ret = romfs_dev_read(inode_sb(i), offset, , ROMFH_SIZE);
if (ret < 0)
goto out;
offset = be32_to_cpu(ri.spec) & ROMFH_MASK;
@@ -178,16 +178,17 @@ static int romfs_readdir(struct file *file, struct 
dir_context *ctx)
ctx->pos = offset;
 
/* Fetch inode info */
-   ret = romfs_dev_read(i->i_sb, offset, , ROMFH_SIZE);
+   ret = romfs_dev_read(inode_sb(i), offset, , ROMFH_SIZE);
if (ret < 0)
goto out;
 
-   j = romfs_dev_strnlen(i->i_sb, offset + ROMFH_SIZE,
+   j = romfs_dev_strnlen(inode_sb(i), offset + ROMFH_SIZE,
  sizeof(fsname) - 1);
if (j < 0)
goto out;
 
-   ret = romfs_dev_read(i->i_sb, offset + ROMFH_SIZE, fsname, j);
+   ret = romfs_dev_read(inode_sb(i), offset + ROMFH_SIZE, fsname,
+j);
if (ret < 0)
goto out;
fsname[j] = '\0';
@@ -219,13 +220,13 @@ static struct dentry *romfs_lookup(struct inode *dir, 
struct dentry *dentry,
int len, ret;
 
offset = dir->i_ino & ROMFH_MASK;
-   ret = romfs_dev_read(dir->i_sb, offset, , ROMFH_SIZE);
+   ret = romfs_dev_read(inode_sb(dir), offset, , ROMFH_SIZE);
if (ret < 0)
goto error;
 
/* search all the file entries in the list starting from the one
 * pointed to by the directory's special data */
-   maxoff = romfs_maxsize(dir->i_sb);
+   maxoff = romfs_maxsize(inode_sb(dir));
offset = be32_to_cpu(ri.spec) & ROMFH_MASK;
 
name = dentry->d_name.name;
@@ -235,12 +236,13 @@ static struct dentry *romfs_lookup(struct inode *dir, 
struct dentry *dentry,
if (!offset || offset >= maxoff)
goto out0;
 
-   ret = romfs_dev_read(dir->i_sb, offset, , sizeof(ri));
+   ret = romfs_dev_read(inode_sb(dir), offset, , sizeof(ri));
if (ret < 0)
goto error;
 
/* try to match the first 16 bytes of name */
-   ret = romfs_dev_strcmp(dir->i_sb, offset + ROMFH_SIZE, name,
+   ret = romfs_dev_strcmp(inode_sb(dir), offset + ROMFH_SIZE,
+  name,
   len);
if (ret < 0)
goto error;
@@ -255,7 +257,7 @@ static struct dentry *romfs_lookup(struct inode *dir, 
struct dentry *dentry,
if ((be32_to_cpu(ri.next) & ROMFH_TYPE) == ROMFH_HRD)
offset = be32_to_cpu(ri.spec) & ROMFH_MASK;
 
-   inode = romfs_iget(dir->i_sb, offset);
+   inode = romfs_iget(inode_sb(dir), offset);
if (IS_ERR(inode)) {
ret = PTR_ERR(inode);
goto 

[PATCH 69/76] fs/ubifs: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/ubifs/crypto.c |  4 ++--
 fs/ubifs/dir.c| 30 +++---
 fs/ubifs/file.c   | 42 +-
 fs/ubifs/ioctl.c  |  4 ++--
 fs/ubifs/super.c  |  4 ++--
 fs/ubifs/xattr.c  | 10 +-
 6 files changed, 47 insertions(+), 47 deletions(-)

diff --git a/fs/ubifs/crypto.c b/fs/ubifs/crypto.c
index 616a688f5d8f..3c8122065ed5 100644
--- a/fs/ubifs/crypto.c
+++ b/fs/ubifs/crypto.c
@@ -35,7 +35,7 @@ static unsigned int ubifs_crypt_max_namelen(struct inode 
*inode)
 int ubifs_encrypt(const struct inode *inode, struct ubifs_data_node *dn,
  unsigned int in_len, unsigned int *out_len, int block)
 {
-   struct ubifs_info *c = inode->i_sb->s_fs_info;
+   struct ubifs_info *c = inode_sb(inode)->s_fs_info;
void *p = >data;
struct page *ret;
unsigned int pad_len = round_up(in_len, UBIFS_CIPHER_BLOCK_SIZE);
@@ -61,7 +61,7 @@ int ubifs_encrypt(const struct inode *inode, struct 
ubifs_data_node *dn,
 int ubifs_decrypt(const struct inode *inode, struct ubifs_data_node *dn,
  unsigned int *out_len, int block)
 {
-   struct ubifs_info *c = inode->i_sb->s_fs_info;
+   struct ubifs_info *c = inode_sb(inode)->s_fs_info;
int err;
unsigned int clen = le16_to_cpu(dn->compr_size);
unsigned int dlen = *out_len;
diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index 9d7fb88e172e..6d168f5cc8ff 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -215,7 +215,7 @@ static struct dentry *ubifs_lookup(struct inode *dir, 
struct dentry *dentry,
union ubifs_key key;
struct inode *inode = NULL;
struct ubifs_dent_node *dent;
-   struct ubifs_info *c = dir->i_sb->s_fs_info;
+   struct ubifs_info *c = inode_sb(dir)->s_fs_info;
struct fscrypt_name nm;
 
dbg_gen("'%pd' in dir ino %lu", dentry, dir->i_ino);
@@ -262,7 +262,7 @@ static struct dentry *ubifs_lookup(struct inode *dir, 
struct dentry *dentry,
goto out_dent;
}
 
-   inode = ubifs_iget(dir->i_sb, le64_to_cpu(dent->inum));
+   inode = ubifs_iget(inode_sb(dir), le64_to_cpu(dent->inum));
if (IS_ERR(inode)) {
/*
 * This should not happen. Probably the file-system needs
@@ -307,7 +307,7 @@ static int ubifs_create(struct inode *dir, struct dentry 
*dentry, umode_t mode,
bool excl)
 {
struct inode *inode;
-   struct ubifs_info *c = dir->i_sb->s_fs_info;
+   struct ubifs_info *c = inode_sb(dir)->s_fs_info;
struct ubifs_budget_req req = { .new_ino = 1, .new_dent = 1,
.dirtied_ino = 1 };
struct ubifs_inode *dir_ui = ubifs_inode(dir);
@@ -376,7 +376,7 @@ static int do_tmpfile(struct inode *dir, struct dentry 
*dentry,
  umode_t mode, struct inode **whiteout)
 {
struct inode *inode;
-   struct ubifs_info *c = dir->i_sb->s_fs_info;
+   struct ubifs_info *c = inode_sb(dir)->s_fs_info;
struct ubifs_budget_req req = { .new_ino = 1, .new_dent = 1};
struct ubifs_budget_req ino_req = { .dirtied_ino = 1 };
struct ubifs_inode *ui, *dir_ui = ubifs_inode(dir);
@@ -525,7 +525,7 @@ static int ubifs_readdir(struct file *file, struct 
dir_context *ctx)
union ubifs_key key;
struct ubifs_dent_node *dent;
struct inode *dir = file_inode(file);
-   struct ubifs_info *c = dir->i_sb->s_fs_info;
+   struct ubifs_info *c = inode_sb(dir)->s_fs_info;
bool encrypted = ubifs_crypt_is_encrypted(dir);
 
dbg_gen("dir ino %lu, f_pos %#llx", dir->i_ino, ctx->pos);
@@ -712,7 +712,7 @@ static void unlock_2_inodes(struct inode *inode1, struct 
inode *inode2)
 static int ubifs_link(struct dentry *old_dentry, struct inode *dir,
  struct dentry *dentry)
 {
-   struct ubifs_info *c = dir->i_sb->s_fs_info;
+   struct ubifs_info *c = inode_sb(dir)->s_fs_info;
struct inode *inode = d_inode(old_dentry);
struct ubifs_inode *ui = ubifs_inode(inode);
struct ubifs_inode *dir_ui = ubifs_inode(dir);
@@ -786,7 +786,7 @@ static int ubifs_link(struct dentry *old_dentry, struct 
inode *dir,
 
 static int ubifs_unlink(struct inode *dir, struct dentry *dentry)
 {
-   struct ubifs_info *c = dir->i_sb->s_fs_info;
+   struct ubifs_info *c = inode_sb(dir)->s_fs_info;
struct inode *inode = d_inode(dentry);
struct ubifs_inode *dir_ui = ubifs_inode(dir);
int err, sz_change, budgeted = 1;
@@ -873,7 +873,7 @@ static int ubifs_unlink(struct inode *dir, struct dentry 
*dentry)
  */
 int ubifs_check_dir_empty(struct inode *dir)
 {
-   struct ubifs_info *c = dir->i_sb->s_fs_info;
+   struct ubifs_info *c = inode_sb(dir)->s_fs_info;
struct fscrypt_name nm = { 0 };
struct ubifs_dent_node *dent;
union ubifs_key key;
@@ -894,7 +894,7 @@ int 

[PATCH 70/76] fs/udf: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/udf/dir.c   |   2 +-
 fs/udf/directory.c |  30 
 fs/udf/file.c  |   6 +-
 fs/udf/ialloc.c|  24 +++---
 fs/udf/inode.c | 209 +++--
 fs/udf/misc.c  |   4 +-
 fs/udf/namei.c |  76 ++-
 fs/udf/partition.c |   2 +-
 fs/udf/super.c |   2 +-
 fs/udf/symlink.c   |   7 +-
 fs/udf/truncate.c  |  26 +++
 11 files changed, 199 insertions(+), 189 deletions(-)

diff --git a/fs/udf/dir.c b/fs/udf/dir.c
index c19dba45aa20..ef5b632da782 100644
--- a/fs/udf/dir.c
+++ b/fs/udf/dir.c
@@ -57,7 +57,7 @@ static int udf_readdir(struct file *file, struct dir_context 
*ctx)
sector_t offset;
int i, num, ret = 0;
struct extent_position epos = { NULL, 0, {0, 0} };
-   struct super_block *sb = dir->i_sb;
+   struct super_block *sb = inode_sb(dir);
 
if (ctx->pos == 0) {
if (!dir_emit_dot(file, ctx))
diff --git a/fs/udf/directory.c b/fs/udf/directory.c
index 0a98a2369738..d5d490eaba6c 100644
--- a/fs/udf/directory.c
+++ b/fs/udf/directory.c
@@ -38,7 +38,7 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, 
loff_t *nf_pos,
   (iinfo->i_efe ?
sizeof(struct extendedFileEntry) :
sizeof(struct fileEntry)),
-  dir->i_sb->s_blocksize,
+  inode_sb(dir)->s_blocksize,
   &(fibh->eoffset));
if (!fi)
return NULL;
@@ -51,15 +51,15 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, 
loff_t *nf_pos,
return fi;
}
 
-   if (fibh->eoffset == dir->i_sb->s_blocksize) {
+   if (fibh->eoffset == inode_sb(dir)->s_blocksize) {
uint32_t lextoffset = epos->offset;
-   unsigned char blocksize_bits = dir->i_sb->s_blocksize_bits;
+   unsigned char blocksize_bits = inode_sb(dir)->s_blocksize_bits;
 
if (udf_next_aext(dir, epos, eloc, elen, 1) !=
(EXT_RECORDED_ALLOCATED >> 30))
return NULL;
 
-   block = udf_get_lb_pblock(dir->i_sb, eloc, *offset);
+   block = udf_get_lb_pblock(inode_sb(dir), eloc, *offset);
 
(*offset)++;
 
@@ -69,7 +69,7 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, 
loff_t *nf_pos,
epos->offset = lextoffset;
 
brelse(fibh->sbh);
-   fibh->sbh = fibh->ebh = udf_tread(dir->i_sb, block);
+   fibh->sbh = fibh->ebh = udf_tread(inode_sb(dir), block);
if (!fibh->sbh)
return NULL;
fibh->soffset = fibh->eoffset = 0;
@@ -79,9 +79,9 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, 
loff_t *nf_pos,
if (i + *offset > (*elen >> blocksize_bits))
i = (*elen >> blocksize_bits)-*offset;
for (num = 0; i > 0; i--) {
-   block = udf_get_lb_pblock(dir->i_sb, eloc,
+   block = udf_get_lb_pblock(inode_sb(dir), eloc,
  *offset + i);
-   tmp = udf_tgetblk(dir->i_sb, block);
+   tmp = udf_tgetblk(inode_sb(dir), block);
if (tmp && !buffer_uptodate(tmp) &&
!buffer_locked(tmp))
bha[num++] = tmp;
@@ -99,7 +99,7 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, 
loff_t *nf_pos,
fibh->sbh = fibh->ebh;
}
 
-   fi = udf_get_fileident(fibh->sbh->b_data, dir->i_sb->s_blocksize,
+   fi = udf_get_fileident(fibh->sbh->b_data, inode_sb(dir)->s_blocksize,
   &(fibh->eoffset));
 
if (!fi)
@@ -107,29 +107,29 @@ struct fileIdentDesc *udf_fileident_read(struct inode 
*dir, loff_t *nf_pos,
 
*nf_pos += fibh->eoffset - fibh->soffset;
 
-   if (fibh->eoffset <= dir->i_sb->s_blocksize) {
+   if (fibh->eoffset <= inode_sb(dir)->s_blocksize) {
memcpy((uint8_t *)cfi, (uint8_t *)fi,
   sizeof(struct fileIdentDesc));
-   } else if (fibh->eoffset > dir->i_sb->s_blocksize) {
+   } else if (fibh->eoffset > inode_sb(dir)->s_blocksize) {
uint32_t lextoffset = epos->offset;
 
if (udf_next_aext(dir, epos, eloc, elen, 1) !=
(EXT_RECORDED_ALLOCATED >> 30))
return NULL;
 
-   block = udf_get_lb_pblock(dir->i_sb, eloc, *offset);
+   block = udf_get_lb_pblock(inode_sb(dir), eloc, *offset);
 

[PATCH 71/76] fs/ufs: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/ufs/balloc.c | 23 ---
 fs/ufs/dir.c| 34 +-
 fs/ufs/ialloc.c |  4 ++--
 fs/ufs/inode.c  | 37 +++--
 fs/ufs/namei.c  |  6 +++---
 5 files changed, 53 insertions(+), 51 deletions(-)

diff --git a/fs/ufs/balloc.c b/fs/ufs/balloc.c
index e727ee07dbe4..b6053d9c0e64 100644
--- a/fs/ufs/balloc.c
+++ b/fs/ufs/balloc.c
@@ -45,7 +45,7 @@ void ufs_free_fragments(struct inode *inode, u64 fragment, 
unsigned count)
unsigned cgno, bit, end_bit, bbase, blkmap, i;
u64 blkno;

-   sb = inode->i_sb;
+   sb = inode_sb(inode);
uspi = UFS_SB(sb)->s_uspi;

UFSD("ENTER, fragment %llu, count %u\n",
@@ -141,7 +141,7 @@ void ufs_free_blocks(struct inode *inode, u64 fragment, 
unsigned count)
unsigned overflow, cgno, bit, end_bit, i;
u64 blkno;

-   sb = inode->i_sb;
+   sb = inode_sb(inode);
uspi = UFS_SB(sb)->s_uspi;
 
UFSD("ENTER, fragment %llu, count %u\n",
@@ -268,7 +268,7 @@ static void ufs_change_blocknr(struct inode *inode, 
sector_t beg,
if (!page)/* it was truncated */
continue;
if (IS_ERR(page)) {/* or EIO */
-   ufs_error(inode->i_sb, __func__,
+   ufs_error(inode_sb(inode), __func__,
  "read of page %llu failed\n",
  (unsigned long long)index);
continue;
@@ -294,12 +294,13 @@ static void ufs_change_blocknr(struct inode *inode, 
sector_t beg,
pos = (i - beg) + j;
 
if (!buffer_mapped(bh))
-   map_bh(bh, inode->i_sb, oldb + pos);
+   map_bh(bh, inode_sb(inode),
+  oldb + pos);
if (!buffer_uptodate(bh)) {
ll_rw_block(REQ_OP_READ, 0, 1, );
wait_on_buffer(bh);
if (!buffer_uptodate(bh)) {
-   ufs_error(inode->i_sb, __func__,
+   ufs_error(inode_sb(inode), __func__,
  "read of block failed\n");
break;
}
@@ -329,9 +330,9 @@ static void ufs_clear_frags(struct inode *inode, sector_t 
beg, unsigned int n,
sector_t end = beg + n;
 
for (; beg < end; ++beg) {
-   bh = sb_getblk(inode->i_sb, beg);
+   bh = sb_getblk(inode_sb(inode), beg);
lock_buffer(bh);
-   memset(bh->b_data, 0, inode->i_sb->s_blocksize);
+   memset(bh->b_data, 0, inode_sb(inode)->s_blocksize);
set_buffer_uptodate(bh);
mark_buffer_dirty(bh);
unlock_buffer(bh);
@@ -355,7 +356,7 @@ u64 ufs_new_fragments(struct inode *inode, void *p, u64 
fragment,
 inode->i_ino, (unsigned long long)fragment,
 (unsigned long long)goal, count);

-   sb = inode->i_sb;
+   sb = inode_sb(inode);
uspi = UFS_SB(sb)->s_uspi;
usb1 = ubh_get_usb_first(uspi);
*err = -ENOSPC;
@@ -517,7 +518,7 @@ static u64 ufs_add_fragments(struct inode *inode, u64 
fragment,
UFSD("ENTER, fragment %llu, oldcount %u, newcount %u\n",
 (unsigned long long)fragment, oldcount, newcount);

-   sb = inode->i_sb;
+   sb = inode_sb(inode);
uspi = UFS_SB(sb)->s_uspi;
count = newcount - oldcount;

@@ -597,7 +598,7 @@ static u64 ufs_alloc_fragments(struct inode *inode, 
unsigned cgno,
UFSD("ENTER, ino %lu, cgno %u, goal %llu, count %u\n",
 inode->i_ino, cgno, (unsigned long long)goal, count);
 
-   sb = inode->i_sb;
+   sb = inode_sb(inode);
uspi = UFS_SB(sb)->s_uspi;
oldcg = cgno;

@@ -708,7 +709,7 @@ static u64 ufs_alloccg_block(struct inode *inode,
 
UFSD("ENTER, goal %llu\n", (unsigned long long)goal);
 
-   sb = inode->i_sb;
+   sb = inode_sb(inode);
uspi = UFS_SB(sb)->s_uspi;
ucg = ubh_get_ucg(UCPI_UBH(ucpi));
 
diff --git a/fs/ufs/dir.c b/fs/ufs/dir.c
index b721d0bda5e5..ebe0ddc8b708 100644
--- a/fs/ufs/dir.c
+++ b/fs/ufs/dir.c
@@ -75,7 +75,7 @@ ino_t ufs_inode_by_name(struct inode *dir, const struct qstr 
*qstr)

de = ufs_find_entry(dir, qstr, );
if (de) {
-   res = fs32_to_cpu(dir->i_sb, de->d_ino);
+   res = fs32_to_cpu(inode_sb(dir), de->d_ino);
ufs_put_page(page);
}
return res;
@@ -89,15 +89,15 @@ void ufs_set_link(struct inode *dir, struct ufs_dir_entry 

[PATCH 73/76] vfs: Move s_dev to to struct fs_view

2018-05-08 Thread Mark Fasheh
There are many places where a dev_t:ino_t pair are passed to userspace
to uniquely describe an inode.  Some file systems, like btrfs, have
multiple inode namespace internally and use a separate dev_t to make the
distinction between them.

The kernel typically uses sb->s_dev for the inode device. Most filesystems
are fine with that but btrfs needs to use the device beloning to the root
which that inode resides on. By moving s_dev into the fs_view we allow btrfs
and any similar filesystems to set this field on a per inode basis.

This patch adds a dev_t field to struct fs_view, v_dev and removes s_dev
from struct super_block. I also include a helper, inode_view() to make
referencing inode->i_view fields less clunky.

Signed-off-by: Mark Fasheh 
---
 include/linux/fs.h | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index 5d4bb19b2a43..c93486505084 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1351,6 +1351,7 @@ struct sb_writers {
  */
 struct fs_view {
struct super_block  *v_sb;
+   dev_t   v_dev;  /* search index; _not_ kdev_t */
 };
 
 static inline struct super_block *inode_sb(const struct inode *inode)
@@ -1358,9 +1359,13 @@ static inline struct super_block *inode_sb(const struct 
inode *inode)
return inode->i_view->v_sb;
 }
 
+static inline struct fs_view *inode_view(const struct inode *inode)
+{
+   return inode->i_view;
+}
+
 struct super_block {
struct list_heads_list; /* Keep this first */
-   dev_t   s_dev;  /* search index; _not_ kdev_t */
unsigned char   s_blocksize_bits;
unsigned long   s_blocksize;
loff_t  s_maxbytes; /* Max file size */
-- 
2.15.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 72/76] fs/xfs: Use inode_sb() helper instead of inode->i_sb

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh 
---
 fs/xfs/xfs_acl.c|  2 +-
 fs/xfs/xfs_aops.c   |  4 ++--
 fs/xfs/xfs_export.c |  4 ++--
 fs/xfs/xfs_file.c   | 10 -
 fs/xfs/xfs_ioctl.c  |  8 +++
 fs/xfs/xfs_iops.c   |  6 ++---
 fs/xfs/xfs_pnfs.c   |  2 +-
 fs/xfs/xfs_trace.h  | 64 ++---
 8 files changed, 50 insertions(+), 50 deletions(-)

diff --git a/fs/xfs/xfs_acl.c b/fs/xfs/xfs_acl.c
index 3354140de07e..42b00b01ea1a 100644
--- a/fs/xfs/xfs_acl.c
+++ b/fs/xfs/xfs_acl.c
@@ -255,7 +255,7 @@ xfs_set_acl(struct inode *inode, struct posix_acl *acl, int 
type)
goto set_acl;
 
error = -E2BIG;
-   if (acl->a_count > XFS_ACL_MAX_ENTRIES(XFS_M(inode->i_sb)))
+   if (acl->a_count > XFS_ACL_MAX_ENTRIES(XFS_M(inode_sb(inode
return error;
 
if (type == ACL_TYPE_ACCESS) {
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index 9c6a830da0ee..951ca9c4ed9e 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -219,7 +219,7 @@ xfs_setfilesize_trans_alloc(
 * We may pass freeze protection with a transaction.  So tell lockdep
 * we released it.
 */
-   __sb_writers_release(ioend->io_inode->i_sb, SB_FREEZE_FS);
+   __sb_writers_release(inode_sb(ioend->io_inode), SB_FREEZE_FS);
/*
 * We hand off the transaction to the completion thread now, so
 * clear the flag here.
@@ -288,7 +288,7 @@ xfs_setfilesize_ioend(
 * Similarly for freeze protection.
 */
current_set_flags_nested(>t_pflags, PF_MEMALLOC_NOFS);
-   __sb_writers_acquired(VFS_I(ip)->i_sb, SB_FREEZE_FS);
+   __sb_writers_acquired(inode_sb(VFS_I(ip)), SB_FREEZE_FS);
 
/* we abort the update if there was an IO error */
if (error) {
diff --git a/fs/xfs/xfs_export.c b/fs/xfs/xfs_export.c
index fe1bfee35898..a78f6eb9987b 100644
--- a/fs/xfs/xfs_export.c
+++ b/fs/xfs/xfs_export.c
@@ -78,8 +78,8 @@ xfs_fs_encode_fh(
 * large enough filesystem may contain them, thus the slightly
 * confusing looking conditional below.
 */
-   if (!(XFS_M(inode->i_sb)->m_flags & XFS_MOUNT_SMALL_INUMS) ||
-   (XFS_M(inode->i_sb)->m_flags & XFS_MOUNT_32BITINODES))
+   if (!(XFS_M(inode_sb(inode))->m_flags & XFS_MOUNT_SMALL_INUMS) ||
+   (XFS_M(inode_sb(inode))->m_flags & XFS_MOUNT_32BITINODES))
fileid_type |= XFS_FILEID_TYPE_64FLAG;
 
/*
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index 9ea08326f876..7b805a8a031e 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -821,7 +821,7 @@ xfs_file_fallocate(
}
 
/* check the new inode size does not wrap through zero */
-   if (new_size > inode->i_sb->s_maxbytes) {
+   if (new_size > inode_sb(inode)->s_maxbytes) {
error = -EFBIG;
goto out_unlock;
}
@@ -926,7 +926,7 @@ xfs_file_open(
 {
if (!(file->f_flags & O_LARGEFILE) && i_size_read(inode) > MAX_NON_LFS)
return -EFBIG;
-   if (XFS_FORCED_SHUTDOWN(XFS_M(inode->i_sb)))
+   if (XFS_FORCED_SHUTDOWN(XFS_M(inode_sb(inode
return -EIO;
file->f_mode |= FMODE_NOWAIT;
return 0;
@@ -1014,7 +1014,7 @@ xfs_file_llseek(
 
if (offset < 0)
return offset;
-   return vfs_setpos(file, offset, inode->i_sb->s_maxbytes);
+   return vfs_setpos(file, offset, inode_sb(inode)->s_maxbytes);
 }
 
 /*
@@ -1040,7 +1040,7 @@ __xfs_filemap_fault(
trace_xfs_filemap_fault(ip, pe_size, write_fault);
 
if (write_fault) {
-   sb_start_pagefault(inode->i_sb);
+   sb_start_pagefault(inode_sb(inode));
file_update_time(vmf->vma->vm_file);
}
 
@@ -1060,7 +1060,7 @@ __xfs_filemap_fault(
xfs_iunlock(XFS_I(inode), XFS_MMAPLOCK_SHARED);
 
if (write_fault)
-   sb_end_pagefault(inode->i_sb);
+   sb_end_pagefault(inode_sb(inode));
return ret;
 }
 
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index 89fb1eb80aae..8e492a123815 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -98,7 +98,7 @@ xfs_find_handle(
 * and only for regular files, directories or symbolic links.
 */
error = -EINVAL;
-   if (inode->i_sb->s_magic != XFS_SB_MAGIC)
+   if (inode_sb(inode)->s_magic != XFS_SB_MAGIC)
goto out_put;
 
error = -EBADF;
@@ -688,9 +688,9 @@ xfs_ioc_space(
}
 
if (bf->l_start < 0 ||
-   bf->l_start > inode->i_sb->s_maxbytes ||
+   bf->l_start > inode_sb(inode)->s_maxbytes ||
bf->l_start + bf->l_len < 0 ||
-   bf->l_start + bf->l_len >= inode->i_sb->s_maxbytes) {
+   bf->l_start + bf->l_len >= inode_sb(inode)->s_maxbytes) {
error = -EINVAL;
goto out_unlock;
}

[PATCH 74/76] fs: Use fs_view device from struct inode.

2018-05-08 Thread Mark Fasheh
Replace calls of inode_sb(inode)->s_dev with inode_view(inode)->v_dev.

Signed-off-by: Mark Fasheh 
---
 arch/arc/kernel/troubleshoot.c |   2 +-
 drivers/staging/lustre/lustre/llite/dir.c  |   2 +-
 drivers/staging/lustre/lustre/llite/file.c |   2 +-
 fs/eventpoll.c |   2 +-
 fs/f2fs/trace.c|   8 +-
 fs/fuse/dir.c  |   2 +-
 fs/locks.c |  12 +--
 fs/nfs/nfs4trace.h |  36 -
 fs/nfs/nfstrace.h  |  42 +-
 fs/nfsd/vfs.c  |   6 +-
 fs/notify/fdinfo.c |   4 +-
 fs/proc/nommu.c|   2 +-
 fs/proc/task_mmu.c |   2 +-
 fs/proc/task_nommu.c   |   2 +-
 fs/stat.c  |   2 +-
 fs/xfs/xfs_iops.c  |   2 +-
 fs/xfs/xfs_trace.h |  64 
 include/trace/events/ext4.h| 118 ++---
 include/trace/events/f2fs.h|  52 ++---
 include/trace/events/filelock.h|   8 +-
 include/trace/events/filemap.h |   6 +-
 include/trace/events/fs_dax.h  |  14 ++--
 include/trace/events/jbd2.h|   2 +-
 include/trace/events/writeback.h   |   2 +-
 kernel/audit.c |   2 +-
 kernel/audit_fsnotify.c|   2 +-
 kernel/audit_watch.c   |   4 +-
 kernel/auditsc.c   |   4 +-
 kernel/bpf/offload.c   |   4 +-
 kernel/events/core.c   |   4 +-
 mm/memory-failure.c|   2 +-
 security/tomoyo/condition.c|   2 +-
 32 files changed, 209 insertions(+), 209 deletions(-)

diff --git a/arch/arc/kernel/troubleshoot.c b/arch/arc/kernel/troubleshoot.c
index 18eb4984d555..b3aa20be118e 100644
--- a/arch/arc/kernel/troubleshoot.c
+++ b/arch/arc/kernel/troubleshoot.c
@@ -104,7 +104,7 @@ static void show_faulting_vma(unsigned long address, char 
*buf)
if (file) {
nm = file_path(file, buf, PAGE_SIZE - 1);
inode = file_inode(vma->vm_file);
-   dev = inode_sb(inode)->s_dev;
+   dev = inode_view(inode)->v_dev;
ino = inode->i_ino;
}
pr_info("@off 0x%lx in [%s]\n"
diff --git a/drivers/staging/lustre/lustre/llite/dir.c 
b/drivers/staging/lustre/lustre/llite/dir.c
index 809e493b61da..cb50d04327d4 100644
--- a/drivers/staging/lustre/lustre/llite/dir.c
+++ b/drivers/staging/lustre/lustre/llite/dir.c
@@ -1364,7 +1364,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int 
cmd, unsigned long arg)
struct lov_user_mds_data __user *lmdp;
lstat_t st = { 0 };
 
-   st.st_dev = inode_sb(inode)->s_dev;
+   st.st_dev = inode_view(inode)->v_dev;
st.st_mode= body->mbo_mode;
st.st_nlink   = body->mbo_nlink;
st.st_uid = body->mbo_uid;
diff --git a/drivers/staging/lustre/lustre/llite/file.c 
b/drivers/staging/lustre/lustre/llite/file.c
index 64df47bd1118..749a74e49e61 100644
--- a/drivers/staging/lustre/lustre/llite/file.c
+++ b/drivers/staging/lustre/lustre/llite/file.c
@@ -2967,7 +2967,7 @@ int ll_getattr(const struct path *path, struct kstat 
*stat,
 
OBD_FAIL_TIMEOUT(OBD_FAIL_GETATTR_DELAY, 30);
 
-   stat->dev = inode_sb(inode)->s_dev;
+   stat->dev = inode_view(inode)->v_dev;
if (ll_need_32bit_api(sbi))
stat->ino = cl_fid_build_ino(>lli_fid, 1);
else
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index a7e3dbc83bbc..39487ae0eabd 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -955,7 +955,7 @@ static void ep_show_fdinfo(struct seq_file *m, struct file 
*f)
   epi->ffd.fd, epi->event.events,
   (long long)epi->event.data,
   (long long)epi->ffd.file->f_pos,
-  inode->i_ino, inode_sb(inode)->s_dev);
+  inode->i_ino, inode_view(inode)->v_dev);
if (seq_has_overflowed(m))
break;
}
diff --git a/fs/f2fs/trace.c b/fs/f2fs/trace.c
index 235a3bca1f5f..601cf0cb723e 100644
--- a/fs/f2fs/trace.c
+++ b/fs/f2fs/trace.c
@@ -74,8 +74,8 @@ void f2fs_trace_pid(struct page *page)
f2fs_radix_tree_insert(, pid, current);
 
trace_printk("%3x:%3x %4x %-16s\n",
-   MAJOR(inode_sb(inode)->s_dev),
-   MINOR(inode_sb(inode)->s_dev),
+   MAJOR(inode_view(inode)->v_dev),
+   

[PATCH 76/76] btrfs: Use fs_view in roots, point inodes to it

2018-05-08 Thread Mark Fasheh
Ensure that our per-subvolume anonymous dev_t gets published to userspace,
instead of the global device in struct super_block. We do this by embedding a
struct fs_view in btrfs_root. The anonymous device number is placed in
view->v_dev. Each inode is then pointed to the view embedded in their owning 
root.

Signed-off-by: Mark Fasheh 
---
 fs/btrfs/ctree.h |  7 ++-
 fs/btrfs/disk-io.c   | 14 --
 fs/btrfs/disk-io.h   |  2 +-
 fs/btrfs/inode.c |  5 +++--
 fs/btrfs/root-tree.c |  2 +-
 5 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index a3cca35642e2..cffd3aa51e93 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -1216,11 +1216,6 @@ struct btrfs_root {
 * protected by inode_lock
 */
struct radix_tree_root delayed_nodes_tree;
-   /*
-* right now this just gets used so that a root has its own devid
-* for stat.  It may be used for more later
-*/
-   dev_t anon_dev;
 
spinlock_t root_item_lock;
refcount_t refs;
@@ -1262,6 +1257,8 @@ struct btrfs_root {
 
/* For qgroup metadata space reserve */
atomic64_t qgroup_meta_rsv;
+
+   struct fs_view view; /* fill in and link to inodes for vfs usage */
 };
 
 struct btrfs_file_private {
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 334234da997c..c50af14b5856 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1191,7 +1191,8 @@ static void __setup_root(struct btrfs_root *root, struct 
btrfs_fs_info *fs_info,
else
root->defrag_trans_start = 0;
root->root_key.objectid = objectid;
-   root->anon_dev = 0;
+   memset(>view, 0, sizeof(struct fs_view));
+   root->view.v_sb = fs_info->sb;
 
spin_lock_init(>root_item_lock);
 }
@@ -1463,7 +1464,7 @@ struct btrfs_root *btrfs_read_fs_root(struct btrfs_root 
*tree_root,
return root;
 }
 
-int btrfs_init_fs_root(struct btrfs_root *root)
+int btrfs_init_fs_root(struct btrfs_root *root, struct super_block *sb)
 {
int ret;
struct btrfs_subvolume_writers *writers;
@@ -1487,7 +1488,8 @@ int btrfs_init_fs_root(struct btrfs_root *root)
spin_lock_init(>ino_cache_lock);
init_waitqueue_head(>ino_cache_wait);
 
-   ret = get_anon_bdev(>anon_dev);
+   root->view.v_sb = sb;
+   ret = get_anon_bdev(>view.v_dev);
if (ret)
goto fail;
 
@@ -1587,7 +1589,7 @@ struct btrfs_root *btrfs_get_fs_root(struct btrfs_fs_info 
*fs_info,
goto fail;
}
 
-   ret = btrfs_init_fs_root(root);
+   ret = btrfs_init_fs_root(root, fs_info->sb);
if (ret)
goto fail;
 
@@ -3603,8 +3605,8 @@ static void free_fs_root(struct btrfs_root *root)
WARN_ON(!RB_EMPTY_ROOT(>inode_tree));
btrfs_free_block_rsv(root->fs_info, root->orphan_block_rsv);
root->orphan_block_rsv = NULL;
-   if (root->anon_dev)
-   free_anon_bdev(root->anon_dev);
+   if (root->view.v_dev)
+   free_anon_bdev(root->view.v_dev);
if (root->subv_writers)
btrfs_free_subvolume_writers(root->subv_writers);
free_extent_buffer(root->node);
diff --git a/fs/btrfs/disk-io.h b/fs/btrfs/disk-io.h
index 301151a50ac1..af60e7d76449 100644
--- a/fs/btrfs/disk-io.h
+++ b/fs/btrfs/disk-io.h
@@ -72,7 +72,7 @@ int btrfs_read_dev_one_super(struct block_device *bdev, int 
copy_num,
 int btrfs_commit_super(struct btrfs_fs_info *fs_info);
 struct btrfs_root *btrfs_read_fs_root(struct btrfs_root *tree_root,
  struct btrfs_key *location);
-int btrfs_init_fs_root(struct btrfs_root *root);
+int btrfs_init_fs_root(struct btrfs_root *root, struct super_block *sb);
 struct btrfs_root *btrfs_lookup_fs_root(struct btrfs_fs_info *fs_info,
u64 root_id);
 int btrfs_insert_fs_root(struct btrfs_fs_info *fs_info,
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 1d4a28a4763a..17e93fb6d871 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -5705,6 +5705,7 @@ static int btrfs_init_locked_inode(struct inode *inode, 
void *p)
memcpy(_I(inode)->location, args->location,
   sizeof(*args->location));
BTRFS_I(inode)->root = args->root;
+   inode->i_view = >root->view;
return 0;
 }
 
@@ -6346,6 +6347,7 @@ static struct inode *btrfs_new_inode(struct 
btrfs_trans_handle *trans,
BTRFS_I(inode)->root = root;
BTRFS_I(inode)->generation = trans->transid;
inode->i_generation = BTRFS_I(inode)->generation;
+   inode->i_view = >view;
 
/*
 * We could have gotten an inode number from somebody who was fsynced
@@ -9528,8 +9530,7 @@ static int btrfs_getattr(const struct path *path, struct 
kstat *stat,
  STATX_ATTR_NODUMP);
 
generic_fillattr(inode, stat);
-   stat->dev = 

[PATCH 75/76] fs: Use fs view device from struct super_block

2018-05-08 Thread Mark Fasheh
We have some places which access s_dev directly from struct super_block.

Convert those to get v_dev from the default super block view.

Signed-off-by: Mark Fasheh 
---
 drivers/mtd/mtdsuper.c  |  2 +-
 drivers/staging/lustre/lustre/llite/llite_lib.c |  6 +-
 fs/autofs4/autofs_i.h   |  2 +-
 fs/autofs4/dev-ioctl.c  | 10 +--
 fs/ceph/super.c |  2 +-
 fs/cramfs/inode.c   |  4 +-
 fs/exofs/super.c|  2 +-
 fs/fuse/inode.c |  2 +-
 fs/gfs2/ops_fstype.c|  2 +-
 fs/gfs2/quota.c |  5 +-
 fs/gfs2/sys.c   |  3 +-
 fs/gfs2/trace_gfs2.h| 30 -
 fs/nfs/nfs4trace.h  |  2 +-
 fs/nfs/super.c  |  6 +-
 fs/nfsd/nfs3xdr.c   |  2 +-
 fs/nfsd/nfsfh.c |  6 +-
 fs/nilfs2/super.c   |  2 +-
 fs/ocfs2/journal.c  | 13 ++--
 fs/ocfs2/ocfs2_trace.h  |  4 +-
 fs/ocfs2/super.c|  4 +-
 fs/overlayfs/inode.c|  4 +-
 fs/overlayfs/readdir.c  |  4 +-
 fs/proc_namespace.c |  2 +-
 fs/quota/dquot.c|  2 +-
 fs/reiserfs/journal.c   |  6 +-
 fs/romfs/super.c|  6 +-
 fs/super.c  |  8 +--
 fs/xfs/scrub/trace.h| 26 
 fs/xfs/xfs_trace.h  | 84 -
 fs/xfs/xfs_trans_dquot.c|  2 +-
 include/trace/events/ext4.h | 36 +--
 include/trace/events/f2fs.h | 18 +++---
 include/trace/events/writeback.h|  2 +-
 init/do_mounts.c|  2 +-
 kernel/audit_watch.c|  2 +-
 net/unix/diag.c |  2 +-
 security/tomoyo/realpath.c  |  4 +-
 37 files changed, 162 insertions(+), 157 deletions(-)

diff --git a/drivers/mtd/mtdsuper.c b/drivers/mtd/mtdsuper.c
index d58a61c09304..f5346de9b29d 100644
--- a/drivers/mtd/mtdsuper.c
+++ b/drivers/mtd/mtdsuper.c
@@ -51,7 +51,7 @@ static int get_sb_mtd_set(struct super_block *sb, void *_mtd)
struct mtd_info *mtd = _mtd;
 
sb->s_mtd = mtd;
-   sb->s_dev = MKDEV(MTD_BLOCK_MAJOR, mtd->index);
+   sb->s_view.v_dev = MKDEV(MTD_BLOCK_MAJOR, mtd->index);
sb->s_bdi = bdi_get(mtd_bdi);
 
return 0;
diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c 
b/drivers/staging/lustre/lustre/llite/llite_lib.c
index 6f6df27635d4..ffa6e7d92080 100644
--- a/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -524,7 +524,7 @@ static int client_common_fill_super(struct super_block *sb, 
char *md, char *dt)
goto out_lock_cn_cb;
}
 
-   sbi->ll_sdev_orig = sb->s_dev;
+   sbi->ll_sdev_orig = sb->s_view.v_dev;
 
/* We set sb->s_dev equal on all lustre clients in order to support
 * NFS export clustering.  NFSD requires that the FSID be the same
@@ -535,7 +535,7 @@ static int client_common_fill_super(struct super_block *sb, 
char *md, char *dt)
 */
uuid = obd_get_uuid(sbi->ll_md_exp);
if (uuid) {
-   sb->s_dev = get_uuid2int(uuid->uuid, strlen(uuid->uuid));
+   sb->s_view.v_dev = get_uuid2int(uuid->uuid, strlen(uuid->uuid));
get_uuid2fsid(uuid->uuid, strlen(uuid->uuid), >ll_fsid);
}
 
@@ -670,7 +670,7 @@ void ll_kill_super(struct super_block *sb)
 * in put_super not affected real removing devices
 */
if (sbi) {
-   sb->s_dev = sbi->ll_sdev_orig;
+   sb->s_view.v_dev = sbi->ll_sdev_orig;
sbi->ll_umounting = 1;
 
/* wait running statahead threads to quit */
diff --git a/fs/autofs4/autofs_i.h b/fs/autofs4/autofs_i.h
index 4737615f0eaa..31fcf15108eb 100644
--- a/fs/autofs4/autofs_i.h
+++ b/fs/autofs4/autofs_i.h
@@ -225,7 +225,7 @@ void autofs4_catatonic_mode(struct autofs_sb_info *);
 
 static inline u32 autofs4_get_dev(struct autofs_sb_info *sbi)
 {
-   return new_encode_dev(sbi->sb->s_dev);
+   return new_encode_dev(sbi->sb->s_view.v_dev);
 }
 
 static inline u64 autofs4_get_ino(struct autofs_sb_info *sbi)
diff --git a/fs/autofs4/dev-ioctl.c b/fs/autofs4/dev-ioctl.c
index 6b28b01e5022..6d1f1bc5db06 100644
--- a/fs/autofs4/dev-ioctl.c
+++ b/fs/autofs4/dev-ioctl.c
@@ -231,7 +231,7 @@ static int find_autofs_mount(const char 

Re: [PATCH 1/2] btrfs-progs: check: Make btrfs check return error for qgroup mismatch

2018-05-08 Thread David Sterba
On Mon, Apr 30, 2018 at 02:16:59PM +0800, Qu Wenruo wrote:
> Current btrfs-check will check qgroup consistency, but even when it
> finds something wrong, the return value is still 0.
> 
> Fix it by allowing report_qgroups() to return int to indicate qgroup
> mismatch, and also add extra logical to return no error if qgroup repair
> is successful.
> 
> Without this patch, fstests can't detect qgroup corruption by its fsck
> alone.
> 
> Signed-off-by: Qu Wenruo 

Applied, thanks. Please send the 0/N (cover letter) mail even for
2-patch series.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


send ioctl failed with -2

2018-05-08 Thread Nicolas Porcel
Hello,

When I do a btrfs send, I get the following error code:

# btrfs send mysnapshot > /dev/null
ERROR: send ioctl failed with -2: No such file or directory

I get it after 70-100% of the bytes are sent.

$ uname -a
Linux nicolas-desktop 4.17.0-rc2_3+ #1 SMP PREEMPT Tue May 8 01:14:47 CEST 
2018 x86_64 GNU/Linux 

$ btrfs --version
btrfs-progs v4.16.1

# btrfs fi show
Label: 'ssd'  uuid: 135e8b6e-c5e5-4d2c-8c1a-62093b41ed1c
  Total devices 1 FS bytes used 178.72GiB
  devid1 size 238.47GiB used 238.47GiB path /dev/sdb1

# btrfs fi df /home
Data, single: total=226.44GiB, used=173.10GiB
System, single: total=32.00MiB, used=48.00KiB
Metadata, single: total=12.00GiB, used=5.62GiB
GlobalReserve, single: total=512.00MiB, used=0.00B

# sudo btrfs scrub status /home 
  
scrub status for 135e8b6e-c5e5-4d2c-8c1a-62093b41ed1c
scrub started at Mon May  7 02:07:52 2018 and finished after 00:07:23
total bytes scrubbed: 162.16GiB with 0 errors

For the kernel version, I had the same problem with v4.16.1 so this is
not a regression of the rc.

I use btrbk to automate my snapshots and backups. I only have the
problem with one of my subvolumes while I do the automatic snapshots
with many subvolumes on this drive. Also, all the snapshots of this
subvolume seem affected.

Did anyone encounter a similar issue or can help me investigate it?

I started looking at the kernel code for the send ioctl but was too lazy
to go through the call hierarchy after 3 function calls. I also found a
page on the btrfs wiki how to debug btrfs using user mode linux but I do
not know if it still works considering it is using 2.6.

Thank you.

-- 
Nicolas Porcel
[0.00] Linux version 4.17.0-rc2_3+ (nicolas@nicolas-desktop) (gcc 
version 7.3.0 (GCC)) #1 SMP PREEMPT Tue May 8 01:14:47 CEST 2018
[0.00] Command line: BOOT_IMAGE=/void/boot/vmlinuz-4.17.0-rc2_3+ 
root=UUID=135e8b6e-c5e5-4d2c-8c1a-62093b41ed1c ro rootflags=subvol=void 
loglevel=4 slub_debug=P page_poison=1 crashkernel=168M
[0.00] x86/fpu: Supporting XSAVE feature 0x001: 'x87 floating point 
registers'
[0.00] x86/fpu: Supporting XSAVE feature 0x002: 'SSE registers'
[0.00] x86/fpu: Supporting XSAVE feature 0x004: 'AVX registers'
[0.00] x86/fpu: xstate_offset[2]:  576, xstate_sizes[2]:  256
[0.00] x86/fpu: Enabled xstate features 0x7, context size is 832 bytes, 
using 'compacted' format.
[0.00] e820: BIOS-provided physical RAM map:
[0.00] BIOS-e820: [mem 0x-0x0009d3ff] usable
[0.00] BIOS-e820: [mem 0x0009d400-0x0009] reserved
[0.00] BIOS-e820: [mem 0x000e-0x000f] reserved
[0.00] BIOS-e820: [mem 0x0010-0x09d7] usable
[0.00] BIOS-e820: [mem 0x09d8-0x09ff] reserved
[0.00] BIOS-e820: [mem 0x0a00-0xdd27] usable
[0.00] BIOS-e820: [mem 0xdd28-0xdd3c0fff] reserved
[0.00] BIOS-e820: [mem 0xdd3c1000-0xdd4bbfff] usable
[0.00] BIOS-e820: [mem 0xdd4bc000-0xdd88efff] ACPI NVS
[0.00] BIOS-e820: [mem 0xdd88f000-0xde3e8fff] reserved
[0.00] BIOS-e820: [mem 0xde3e9000-0xdeff] usable
[0.00] BIOS-e820: [mem 0xdf00-0xdfff] reserved
[0.00] BIOS-e820: [mem 0xf800-0xfbff] reserved
[0.00] BIOS-e820: [mem 0xfdf0-0xfdff] reserved
[0.00] BIOS-e820: [mem 0xfea0-0xfea0] reserved
[0.00] BIOS-e820: [mem 0xfeb8-0xfec01fff] reserved
[0.00] BIOS-e820: [mem 0xfec1-0xfec10fff] reserved
[0.00] BIOS-e820: [mem 0xfec3-0xfec30fff] reserved
[0.00] BIOS-e820: [mem 0xfed0-0xfed00fff] reserved
[0.00] BIOS-e820: [mem 0xfed4-0xfed44fff] reserved
[0.00] BIOS-e820: [mem 0xfed8-0xfed8] reserved
[0.00] BIOS-e820: [mem 0xfedc2000-0xfedc] reserved
[0.00] BIOS-e820: [mem 0xfedd4000-0xfedd5fff] reserved
[0.00] BIOS-e820: [mem 0xfee0-0xfeef] reserved
[0.00] BIOS-e820: [mem 0xff00-0x] reserved
[0.00] BIOS-e820: [mem 0x0001-0x00041f37] usable
[0.00] NX (Execute Disable) protection: active
[0.00] SMBIOS 3.0 present.
[0.00] DMI: Micro-Star International Co., Ltd. MS-7A34/B350 TOMAHAWK 
(MS-7A34), BIOS 1.90 09/19/2017
[0.00] e820: update [mem 0x-0x0fff] usable ==> reserved
[0.00] e820: remove 

Re: [PATCH] btrfs-progs: Use exclude_super_stripes instead of account_super_bytes

2018-05-08 Thread David Sterba
On Wed, May 02, 2018 at 02:52:54PM +0300, Nikolay Borisov wrote:
> Originally commit 2681e00f00fe ("btrfs-progs: check for matchingi
> free space in cache") added the account_super_bytes function to prevent
> false negative when running btrfs check. Turns out this function is
> really copied exclude_super_stripes, excluding the calls to
> exclude_super_stripes. Later commit e4797df6a9fa ("btrfs-progs: check
> the free space tree in btrfsck") introduced proper version of
> exclude_super_stripes. Instead of duplicating the function, just remove
> account_super_bytes and use exclude_super_stripes instead of the former.
> This also has the benefit of bringing the userspace code a bit closer
> to the kernel counterpart.
> 
> Signed-off-by: Nikolay Borisov 

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 1/2] btrfs-progs: qgroup: swap the argument in the caller of update_qgroup_relation

2018-05-08 Thread David Sterba
On Tue, May 08, 2018 at 01:48:02PM +0800, Lu Fengqi wrote:
> The QGROUP_RELATION item is very special, it always exists in pairs
> (objectid and offset exchange). Its objectid and offset are the ids of a
> pair of parent and child qgroups, respectively. The larger one is
> parent and the smaller one is child. After the following commit, the order
> of the parameters is wrong and causes qgroup show to output the wrong
> qgroup parent-child relationship.
> 
> Fixes: aaf2dac5ef37 ("btrfs-progs: qgroup: split update_qgroup to reduce 
> arguments")
> Issue: #129
> Signed-off-by: Lu Fengqi 
> ---
> V2: Rename variables instead of the comment to make it clear.

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


  1   2   >