[PATCH 1/2] vfs: allow dedupe of user owned read-only files

2018-09-10 Thread Mark Fasheh
The permission check in vfs_dedupe_file_range_one() is too coarse - We only
allow dedupe of the destination file if the user is root, or they have the
file open for write.

This effectively limits a non-root user from deduping their own read-only
files. In addition, the write file descriptor that the user is forced to
hold open can prevent execution of files. As file data during a dedupe
does not change, the behavior is unexpected and this has caused a number of
issue reports. For an example, see:

https://github.com/markfasheh/duperemove/issues/129

So change the check so we allow dedupe on the target if:

- the root or admin is asking for it
- the process has write access
- the owner of the file is asking for the dedupe
- the process could get write access

That way users can open read-only and still get dedupe.

Signed-off-by: Mark Fasheh 
---
 fs/read_write.c | 16 +++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/fs/read_write.c b/fs/read_write.c
index 39b4a21dd933..be0e8723a049 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1964,6 +1964,20 @@ int vfs_dedupe_file_range_compare(struct inode *src, 
loff_t srcoff,
 }
 EXPORT_SYMBOL(vfs_dedupe_file_range_compare);
 
+/* Check whether we are allowed to dedupe the destination file */
+static bool allow_file_dedupe(struct file *file)
+{
+   if (capable(CAP_SYS_ADMIN))
+   return true;
+   if (file->f_mode & FMODE_WRITE)
+   return true;
+   if (uid_eq(current_fsuid(), file_inode(file)->i_uid))
+   return true;
+   if (!inode_permission(file_inode(file), MAY_WRITE))
+   return true;
+   return false;
+}
+
 int vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos,
  struct file *dst_file, loff_t dst_pos, u64 len)
 {
@@ -1978,7 +1992,7 @@ int vfs_dedupe_file_range_one(struct file *src_file, 
loff_t src_pos,
goto out_drop_write;
 
ret = -EINVAL;
-   if (!(capable(CAP_SYS_ADMIN) || (dst_file->f_mode & FMODE_WRITE)))
+   if (!allow_file_dedupe(dst_file))
goto out_drop_write;
 
ret = -EXDEV;
-- 
2.15.1



[PATCH v6 0/2] vfs: fix dedupe permission check

2018-09-10 Thread Mark Fasheh
Hi Andrew/Al,

Could I please have these patches put in a tree for more public testing?
They've hit fsdevel a few times now, I have links to the discussions in the
change log below.


The following patches fix a couple of issues with the permission check
we do in vfs_dedupe_file_range().

The first patch expands our check to allow dedupe of a file if the
user owns it or otherwise would be allowed to write to it.

Current behavior is that we'll allow dedupe only if:

- the user is an admin (root)
- the user has the file open for write

This makes it impossible for a user to dedupe their own file set
unless they do it as root, or ensure that all files have write
permission. There's a couple of duperemove bugs open for this:

https://github.com/markfasheh/duperemove/issues/129
https://github.com/markfasheh/duperemove/issues/86

The other problem we have is also related to forcing the user to open
target files for write - A process trying to exec a file currently
being deduped gets ETXTBUSY. The answer (as above) is to allow them to
open the targets ro - root can already do this. There was a patch from
Adam Borowski to fix this back in 2016:

https://lkml.org/lkml/2016/7/17/130

which I have incorporated into my changes.


The 2nd patch fixes our return code for permission denied to be
EPERM. For some reason we're returning EINVAL - I think that's
probably my fault. At any rate, we need to be returning something
descriptive of the actual problem, otherwise callers see EINVAL and
can't really make a valid determination of what's gone wrong.

This has also popped up in duperemove, mostly in the form of cryptic
error messages. Because this is a code returned to userspace, I did
check the other users of extent-same that I could find. Both 'bees'
and 'rust-btrfs' do the same as duperemove and simply report the error
(as they should).


One way I tested these patches was to make non-root owned files with
read-only permissions and see if I could dedupe them as the owning user. For
example, the following script fails on an unpatched kernel and succeeds with
the patches applied.

  TESTDIR=/btrfs
  USER=mfasheh

  rm -f $TESTDIR/file*

  dd if=/dev/zero of=$TESTDIR/file1 count=1024 bs=1024
  dd if=/dev/zero of=$TESTDIR/file2 count=1024 bs=1024

  chown $USER $TESTDIR/file*
  chmod 444 $TESTDIR/file*

  # open file* for read and dedupe
  sudo -u $USER duperemove -Ad $TESTDIR/file*


Lastly, I have an update to the fi_deduperange manpage to reflect these
changes. That patch is attached below.


git pull https://github.com/markfasheh/linux dedupe-perms

Thanks,
  --Mark

Changes from V5 to V6:
- Rebase and retest on 4.19-rc3
- Add a note on testing

Changes from V4 to V5:
- Rebase and retest on 4.18-rc8
- Place updated manpage patch below, CC linux-api
- V4 discussion: https://patchwork.kernel.org/patch/10530365/

Changes from V3 to V4:
- Add a patch (below) to ioctl_fideduperange.2 explaining our
  changes. I will send this patch once the kernel update is
  accepted. Thanks to Darrick Wong for this suggestion.
- V3 discussion: https://www.spinics.net/lists/linux-btrfs/msg79135.html

Changes from V2 to V3:
- Return bool from allow_file_dedupe
- V2 discussion: https://www.spinics.net/lists/linux-btrfs/msg78421.html

Changes from V1 to V2:
- Add inode_permission check as suggested by Adam Borowski
- V1 discussion: https://marc.info/?l=linux-xfs=152606684017965=2


From: Mark Fasheh 

[PATCH] ioctl_fideduperange.2: clarify permission requirements

dedupe permission checks were recently relaxed - update our man page to
reflect those changes.

Signed-off-by: Mark Fasheh 
---
 man2/ioctl_fideduperange.2 | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/man2/ioctl_fideduperange.2 b/man2/ioctl_fideduperange.2
index 84d20a276..4040ee064 100644
--- a/man2/ioctl_fideduperange.2
+++ b/man2/ioctl_fideduperange.2
@@ -105,9 +105,12 @@ The field
 must be zero.
 During the call,
 .IR src_fd
-must be open for reading and
+must be open for reading.
 .IR dest_fd
-must be open for writing.
+can be open for writing, or reading.
+If
+.IR dest_fd
+is open for reading, the user must have write access to the file.
 The combined size of the struct
 .IR file_dedupe_range
 and the struct
@@ -185,8 +188,8 @@ This can appear if the filesystem does not support 
deduplicating either file
 descriptor, or if either file descriptor refers to special inodes.
 .TP
 .B EPERM
-.IR dest_fd
-is immutable.
+This will be returned if the user lacks permission to dedupe the file 
referenced by
+.IR dest_fd .
 .TP
 .B ETXTBSY
 One of the files is a swap file.
-- 
2.15.1



[PATCH 2/2] vfs: dedupe should return EPERM if permission is not granted

2018-09-10 Thread Mark Fasheh
Right now we return EINVAL if a process does not have permission to dedupe a
file. This was an oversight on my part. EPERM gives a true description of
the nature of our error, and EINVAL is already used for the case that the
filesystem does not support dedupe.

Signed-off-by: Mark Fasheh 
Reviewed-by: Darrick J. Wong 
Acked-by: David Sterba 
---
 fs/read_write.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/read_write.c b/fs/read_write.c
index be0e8723a049..c734bc2880a5 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1991,7 +1991,7 @@ int vfs_dedupe_file_range_one(struct file *src_file, 
loff_t src_pos,
if (ret < 0)
goto out_drop_write;
 
-   ret = -EINVAL;
+   ret = -EPERM;
if (!allow_file_dedupe(dst_file))
goto out_drop_write;
 
-- 
2.15.1



[PATCH v5 2/2] vfs: dedupe should return EPERM if permission is not granted

2018-09-04 Thread Mark Fasheh
Right now we return EINVAL if a process does not have permission to dedupe a
file. This was an oversight on my part. EPERM gives a true description of
the nature of our error, and EINVAL is already used for the case that the
filesystem does not support dedupe.

Signed-off-by: Mark Fasheh 
Reviewed-by: Darrick J. Wong 
Acked-by: David Sterba 
---
 fs/read_write.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/read_write.c b/fs/read_write.c
index 71e9077f8bc1..7188982e2733 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -2050,7 +2050,7 @@ int vfs_dedupe_file_range(struct file *file, struct 
file_dedupe_range *same)
if (info->reserved) {
info->status = -EINVAL;
} else if (!allow_file_dedupe(dst_file)) {
-   info->status = -EINVAL;
+   info->status = -EPERM;
} else if (file->f_path.mnt != dst_file->f_path.mnt) {
info->status = -EXDEV;
} else if (S_ISDIR(dst->i_mode)) {
-- 
2.15.1



[PATCH v5 1/2] vfs: allow dedupe of user owned read-only files

2018-09-04 Thread Mark Fasheh
The permission check in vfs_dedupe_file_range() is too coarse - We
only allow dedupe of the destination file if the user is root, or
they have the file open for write.

This effectively limits a non-root user from deduping their own read-only
files. In addition, the write file descriptor that the user is forced to
hold open can prevent execution of files. As file data during a dedupe
does not change, the behavior is unexpected and this has caused a number of
issue reports. For an example, see:

https://github.com/markfasheh/duperemove/issues/129

So change the check so we allow dedupe on the target if:

- the root or admin is asking for it
- the process has write access
- the owner of the file is asking for the dedupe
- the process could get write access

That way users can open read-only and still get dedupe.

Signed-off-by: Mark Fasheh 
Acked-by: Darrick J. Wong 
---
 fs/read_write.c | 17 +++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/fs/read_write.c b/fs/read_write.c
index e83bd9744b5d..71e9077f8bc1 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1964,6 +1964,20 @@ int vfs_dedupe_file_range_compare(struct inode *src, 
loff_t srcoff,
 }
 EXPORT_SYMBOL(vfs_dedupe_file_range_compare);
 
+/* Check whether we are allowed to dedupe the destination file */
+static bool allow_file_dedupe(struct file *file)
+{
+   if (capable(CAP_SYS_ADMIN))
+   return true;
+   if (file->f_mode & FMODE_WRITE)
+   return true;
+   if (uid_eq(current_fsuid(), file_inode(file)->i_uid))
+   return true;
+   if (!inode_permission(file_inode(file), MAY_WRITE))
+   return true;
+   return false;
+}
+
 int vfs_dedupe_file_range(struct file *file, struct file_dedupe_range *same)
 {
struct file_dedupe_range_info *info;
@@ -1972,7 +1986,6 @@ int vfs_dedupe_file_range(struct file *file, struct 
file_dedupe_range *same)
u64 len;
int i;
int ret;
-   bool is_admin = capable(CAP_SYS_ADMIN);
u16 count = same->dest_count;
struct file *dst_file;
loff_t dst_off;
@@ -2036,7 +2049,7 @@ int vfs_dedupe_file_range(struct file *file, struct 
file_dedupe_range *same)
 
if (info->reserved) {
info->status = -EINVAL;
-   } else if (!(is_admin || (dst_file->f_mode & FMODE_WRITE))) {
+   } else if (!allow_file_dedupe(dst_file)) {
info->status = -EINVAL;
} else if (file->f_path.mnt != dst_file->f_path.mnt) {
info->status = -EXDEV;
-- 
2.15.1



[RESEND][PATCH v5 0/2] vfs: fix dedupe permission check

2018-09-04 Thread Mark Fasheh
Hi Andrew/Al,

Could I please have these patches put in a tree for more public testing?
They've hit fsdevel a few times now, I have links to the discussions in the
change log below.


The following patches fix a couple of issues with the permission check
we do in vfs_dedupe_file_range().

The first patch expands our check to allow dedupe of a file if the
user owns it or otherwise would be allowed to write to it.

Current behavior is that we'll allow dedupe only if:

- the user is an admin (root)
- the user has the file open for write

This makes it impossible for a user to dedupe their own file set
unless they do it as root, or ensure that all files have write
permission. There's a couple of duperemove bugs open for this:

https://github.com/markfasheh/duperemove/issues/129
https://github.com/markfasheh/duperemove/issues/86

The other problem we have is also related to forcing the user to open
target files for write - A process trying to exec a file currently
being deduped gets ETXTBUSY. The answer (as above) is to allow them to
open the targets ro - root can already do this. There was a patch from
Adam Borowski to fix this back in 2016:

https://lkml.org/lkml/2016/7/17/130

which I have incorporated into my changes.


The 2nd patch fixes our return code for permission denied to be
EPERM. For some reason we're returning EINVAL - I think that's
probably my fault. At any rate, we need to be returning something
descriptive of the actual problem, otherwise callers see EINVAL and
can't really make a valid determination of what's gone wrong.

This has also popped up in duperemove, mostly in the form of cryptic
error messages. Because this is a code returned to userspace, I did
check the other users of extent-same that I could find. Both 'bees'
and 'rust-btrfs' do the same as duperemove and simply report the error
(as they should).


Lastly, I have an update to the fi_deduperange manpage to reflect these
changes. That patch is attached below.


Please apply.

git pull https://github.com/markfasheh/linux dedupe-perms

Thanks,
  --Mark

Changes from V4 to V5:
- Rebase and retest on 4.18-rc8
- Place updated manpage patch below, CC linux-api
- V4 discussion: https://patchwork.kernel.org/patch/10530365/

Changes from V3 to V4:
- Add a patch (below) to ioctl_fideduperange.2 explaining our
  changes. I will send this patch once the kernel update is
  accepted. Thanks to Darrick Wong for this suggestion.
- V3 discussion: https://www.spinics.net/lists/linux-btrfs/msg79135.html

Changes from V2 to V3:
- Return bool from allow_file_dedupe
- V2 discussion: https://www.spinics.net/lists/linux-btrfs/msg78421.html

Changes from V1 to V2:
- Add inode_permission check as suggested by Adam Borowski
- V1 discussion: https://marc.info/?l=linux-xfs=152606684017965=2


From: Mark Fasheh 

[PATCH] ioctl_fideduperange.2: clarify permission requirements

dedupe permission checks were recently relaxed - update our man page to
reflect those changes.

Signed-off-by: Mark Fasheh 
---
 man2/ioctl_fideduperange.2 | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/man2/ioctl_fideduperange.2 b/man2/ioctl_fideduperange.2
index 84d20a276..4040ee064 100644
--- a/man2/ioctl_fideduperange.2
+++ b/man2/ioctl_fideduperange.2
@@ -105,9 +105,12 @@ The field
 must be zero.
 During the call,
 .IR src_fd
-must be open for reading and
+must be open for reading.
 .IR dest_fd
-must be open for writing.
+can be open for writing, or reading.
+If
+.IR dest_fd
+is open for reading, the user must have write access to the file.
 The combined size of the struct
 .IR file_dedupe_range
 and the struct
@@ -185,8 +188,8 @@ This can appear if the filesystem does not support 
deduplicating either file
 descriptor, or if either file descriptor refers to special inodes.
 .TP
 .B EPERM
-.IR dest_fd
-is immutable.
+This will be returned if the user lacks permission to dedupe the file 
referenced by
+.IR dest_fd .
 .TP
 .B ETXTBSY
 One of the files is a swap file.
-- 
2.15.1



[PATCH v5 2/2] vfs: dedupe should return EPERM if permission is not granted

2018-08-07 Thread Mark Fasheh
Right now we return EINVAL if a process does not have permission to dedupe a
file. This was an oversight on my part. EPERM gives a true description of
the nature of our error, and EINVAL is already used for the case that the
filesystem does not support dedupe.

Signed-off-by: Mark Fasheh 
Reviewed-by: Darrick J. Wong 
Acked-by: David Sterba 
---
 fs/read_write.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/read_write.c b/fs/read_write.c
index 71e9077f8bc1..7188982e2733 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -2050,7 +2050,7 @@ int vfs_dedupe_file_range(struct file *file, struct 
file_dedupe_range *same)
if (info->reserved) {
info->status = -EINVAL;
} else if (!allow_file_dedupe(dst_file)) {
-   info->status = -EINVAL;
+   info->status = -EPERM;
} else if (file->f_path.mnt != dst_file->f_path.mnt) {
info->status = -EXDEV;
} else if (S_ISDIR(dst->i_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


[RESEND][PATCH v5 0/2] vfs: better dedupe permission check

2018-08-07 Thread Mark Fasheh
Hi Andrew,

Could I please have these patches upstreamed or at least put in a tree for
more public testing? They've hit fsdevel a few times now, I have links to
the discussions in the change log below.


The following patches fix a couple of issues with the permission check
we do in vfs_dedupe_file_range().

The first patch expands our check to allow dedupe of a file if the
user owns it or otherwise would be allowed to write to it.

Current behavior is that we'll allow dedupe only if:

- the user is an admin (root)
- the user has the file open for write

This makes it impossible for a user to dedupe their own file set
unless they do it as root, or ensure that all files have write
permission. There's a couple of duperemove bugs open for this:

https://github.com/markfasheh/duperemove/issues/129
https://github.com/markfasheh/duperemove/issues/86

The other problem we have is also related to forcing the user to open
target files for write - A process trying to exec a file currently
being deduped gets ETXTBUSY. The answer (as above) is to allow them to
open the targets ro - root can already do this. There was a patch from
Adam Borowski to fix this back in 2016:

https://lkml.org/lkml/2016/7/17/130

which I have incorporated into my changes.


The 2nd patch fixes our return code for permission denied to be
EPERM. For some reason we're returning EINVAL - I think that's
probably my fault. At any rate, we need to be returning something
descriptive of the actual problem, otherwise callers see EINVAL and
can't really make a valid determination of what's gone wrong.

This has also popped up in duperemove, mostly in the form of cryptic
error messages. Because this is a code returned to userspace, I did
check the other users of extent-same that I could find. Both 'bees'
and 'rust-btrfs' do the same as duperemove and simply report the error
(as they should).


Lastly, I have an update to the fi_deduperange manpage to reflect these
changes. That patch is attached below.


Please apply.

git pull https://github.com/markfasheh/linux dedupe-perms

Thanks,
  --Mark

Changes from V4 to V5:
- Rebase and retest on 4.18-rc8
- Place updated manpage patch below, CC linux-api
- V4 discussion: https://patchwork.kernel.org/patch/10530365/

Changes from V3 to V4:
- Add a patch (below) to ioctl_fideduperange.2 explaining our
  changes. I will send this patch once the kernel update is
  accepted. Thanks to Darrick Wong for this suggestion.
- V3 discussion: https://www.spinics.net/lists/linux-btrfs/msg79135.html

Changes from V2 to V3:
- Return bool from allow_file_dedupe
- V2 discussion: https://www.spinics.net/lists/linux-btrfs/msg78421.html

Changes from V1 to V2:
- Add inode_permission check as suggested by Adam Borowski
- V1 discussion: https://marc.info/?l=linux-xfs=152606684017965=2


From: Mark Fasheh 

[PATCH] ioctl_fideduperange.2: clarify permission requirements

dedupe permission checks were recently relaxed - update our man page to
reflect those changes.

Signed-off-by: Mark Fasheh 
---
 man2/ioctl_fideduperange.2 | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/man2/ioctl_fideduperange.2 b/man2/ioctl_fideduperange.2
index 84d20a276..4040ee064 100644
--- a/man2/ioctl_fideduperange.2
+++ b/man2/ioctl_fideduperange.2
@@ -105,9 +105,12 @@ The field
 must be zero.
 During the call,
 .IR src_fd
-must be open for reading and
+must be open for reading.
 .IR dest_fd
-must be open for writing.
+can be open for writing, or reading.
+If
+.IR dest_fd
+is open for reading, the user must have write access to the file.
 The combined size of the struct
 .IR file_dedupe_range
 and the struct
@@ -185,8 +188,8 @@ This can appear if the filesystem does not support 
deduplicating either file
 descriptor, or if either file descriptor refers to special inodes.
 .TP
 .B EPERM
-.IR dest_fd
-is immutable.
+This will be returned if the user lacks permission to dedupe the file 
referenced by
+.IR dest_fd .
 .TP
 .B ETXTBSY
 One of the files is a swap 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 v5 1/2] vfs: allow dedupe of user owned read-only files

2018-08-07 Thread Mark Fasheh
The permission check in vfs_dedupe_file_range() is too coarse - We
only allow dedupe of the destination file if the user is root, or
they have the file open for write.

This effectively limits a non-root user from deduping their own read-only
files. In addition, the write file descriptor that the user is forced to
hold open can prevent execution of files. As file data during a dedupe
does not change, the behavior is unexpected and this has caused a number of
issue reports. For an example, see:

https://github.com/markfasheh/duperemove/issues/129

So change the check so we allow dedupe on the target if:

- the root or admin is asking for it
- the process has write access
- the owner of the file is asking for the dedupe
- the process could get write access

That way users can open read-only and still get dedupe.

Signed-off-by: Mark Fasheh 
Acked-by: Darrick J. Wong 
---
 fs/read_write.c | 17 +++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/fs/read_write.c b/fs/read_write.c
index e83bd9744b5d..71e9077f8bc1 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1964,6 +1964,20 @@ int vfs_dedupe_file_range_compare(struct inode *src, 
loff_t srcoff,
 }
 EXPORT_SYMBOL(vfs_dedupe_file_range_compare);
 
+/* Check whether we are allowed to dedupe the destination file */
+static bool allow_file_dedupe(struct file *file)
+{
+   if (capable(CAP_SYS_ADMIN))
+   return true;
+   if (file->f_mode & FMODE_WRITE)
+   return true;
+   if (uid_eq(current_fsuid(), file_inode(file)->i_uid))
+   return true;
+   if (!inode_permission(file_inode(file), MAY_WRITE))
+   return true;
+   return false;
+}
+
 int vfs_dedupe_file_range(struct file *file, struct file_dedupe_range *same)
 {
struct file_dedupe_range_info *info;
@@ -1972,7 +1986,6 @@ int vfs_dedupe_file_range(struct file *file, struct 
file_dedupe_range *same)
u64 len;
int i;
int ret;
-   bool is_admin = capable(CAP_SYS_ADMIN);
u16 count = same->dest_count;
struct file *dst_file;
loff_t dst_off;
@@ -2036,7 +2049,7 @@ int vfs_dedupe_file_range(struct file *file, struct 
file_dedupe_range *same)
 
if (info->reserved) {
info->status = -EINVAL;
-   } else if (!(is_admin || (dst_file->f_mode & FMODE_WRITE))) {
+   } else if (!allow_file_dedupe(dst_file)) {
info->status = -EINVAL;
} else if (file->f_path.mnt != dst_file->f_path.mnt) {
info->status = -EXDEV;
-- 
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


Re: [PATCH 2/4] nfs: check for NULL vfsmount in nfs_getattr

2018-08-02 Thread Mark Fasheh
Hi Al,

On Thu, Aug 02, 2018 at 01:43:48AM +0100, Al Viro wrote:
> On Tue, Jul 31, 2018 at 10:51:57PM +0000, Mark Fasheh wrote:
> > Hi Al,
> > 
> > On Tue, Jul 31, 2018 at 11:16:05PM +0100, Al Viro wrote:
> > > On Tue, Jul 31, 2018 at 02:10:43PM -0700, Mark Fasheh wrote:
> > > > ->getattr from inside the kernel won't always have a vfsmount, check for
> > > > this.
> > > 
> > > Really?  Where would that happen?
> > 
> > It happens in my first patch. FWIW, I'm not tied to that particular bit of
> > code, or even this (latest) approach. I would actually very much appreciate
> > your input into how we might fix the problem we have where we are sometimes
> > not exporting a correct ino/dev pair to user space.
> 
> Which callers would those be?  I don't see anything in your series that
> wouldn't have vfsmount at hand...

You are correct - there's no callers in my patch series that don't have a
vfsmount available. I can remove patch #2 and pass the vfsmount through.

At some point I was trying to plug this callback into audit_copy_inode()
which AFAICT doesn't have a vfsmount to pass in when we're coming from
vfs_rename (vfs_rename() -> fsnotify_move()). I will eventually have to go
back and handle this for audit though so it seems worth mentioning here.


> > I have a good break-down of the problem and possible solutions here:
> > 
> > https://www.spinics.net/lists/linux-fsdevel/msg128003.html
> 
> btrfs pulling odd crap with device numbers is a problem, but this is far from
> the most obvious unpleasantness caused by that - e.g. userland code expecting
> that unequal st_dev for directory and subdirectory means that we have
> a mountpoint there.  Or assuming it can compare that to st_dev of mountpoints
> (or, indeed, the values in /proc/self/mountinfo) to find which fs it's on...

Indeed, I agree that all of these are pretty gross and things I'd like to
see fixed - I have to deal with subvolume boundaries in some of my own
software. I know Jeff is working on some code to give subvolumes their own
vfsmount but that wouldn't help with our device reporting unless we did
something like move s_dev from the super_block to the vfsmount (also an idea
that's been thrown around).


> /proc/*/maps is unfortunate, but it does contain the pathnames, doesn't it?
> What _real_ problems are there - the ones where we don't have a saner 
> solution?
> Note that /proc/locks is (a) FPOS interface and (b) unsuitable for your
> approach anyway.

Yeah I see now that /proc/locks isn't going to work with something calling
into ->getattr().

Primarily my concerns are /proc/*/maps and audit (which is recording ino/dev
pairs). Even though /proc/*/maps prints a path it is still a problem as
there is no way for userspace to verify that the inode it stats using that
path is the correct one.

I don't mean to overstate the case but the /proc/*/maps issue is real to us
(SUSE) in that it's produced bug reports. For example, lsof produces
confusing output when we run with a btrfs subvolume as root.

As far as problems that can't be solved by this approach - there are
tracepoints in events/lock.h and events/writeback.h which ought to be
reporting the correct ino/dev pairs. There's of course /proc/locks too. I
acknowledge that whether those are severe enough to warrant a different
approach might be up for debate.

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


Re: [PATCH 4/4] locks: map correct ino/dev pairs when exporting to userspace

2018-08-01 Thread Mark Fasheh
Hi Jeff,

On Wed, Aug 01, 2018 at 07:03:54AM -0400, Jeff Layton wrote:
> On Tue, 2018-07-31 at 14:10 -0700, Mark Fasheh wrote:
> > /proc/locks does not always print the correct inode number/device pair.
> > Update lock_get_status() to use vfs_map_unique_ino_dev() to get the real,
> > unique values for userspace.
> > 
> > Signed-off-by: Mark Fasheh 
> > ---
> >  fs/locks.c | 12 +---
> >  1 file changed, 9 insertions(+), 3 deletions(-)
> > 
> > diff --git a/fs/locks.c b/fs/locks.c
> > index db7b6917d9c5..3a012df87fd8 100644
> > --- a/fs/locks.c
> > +++ b/fs/locks.c
> > @@ -2621,6 +2621,7 @@ static void lock_get_status(struct seq_file *f, 
> > struct file_lock *fl,
> > loff_t id, char *pfx)
> >  {
> > struct inode *inode = NULL;
> > +   struct dentry *dentry;
> > unsigned int fl_pid;
> > struct pid_namespace *proc_pidns = file_inode(f->file)->i_sb->s_fs_info;
> >  
> > @@ -2633,8 +2634,10 @@ static void lock_get_status(struct seq_file *f, 
> > struct file_lock *fl,
> > if (fl_pid == 0)
> > return;
> >  
> > -   if (fl->fl_file != NULL)
> > +   if (fl->fl_file != NULL) {
> > inode = locks_inode(fl->fl_file);
> > +   dentry = file_dentry(fl->fl_file);
> > +   }
> >  
> > seq_printf(f, "%lld:%s ", id, pfx);
> > if (IS_POSIX(fl)) {
> > @@ -2681,10 +2684,13 @@ static void lock_get_status(struct seq_file *f, 
> > struct file_lock *fl,
> >: (fl->fl_type == F_WRLCK) ? "WRITE" : "READ ");
> > }
> > if (inode) {
> > +   __u64 ino;
> > +   dev_t dev;
> > +
> > +   vfs_map_unique_ino_dev(dentry, , );
> 
> This code is under a spinlock (blocked_locks_lock or ctx->flc_lock). I
> don't think it'll be ok to call ->getattr while holding a spinlock.

Hmm, indeed it does call under spinlock. I'll hve to rethink how to approach
this in fs/locks.c

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


Re: [PATCH 4/4] locks: map correct ino/dev pairs when exporting to userspace

2018-08-01 Thread Mark Fasheh
On Wed, Aug 01, 2018 at 08:37:31AM +0300, Amir Goldstein wrote:
> > if (inode) {
> > +   __u64 ino;
> > +   dev_t dev;
> > +
> > +   vfs_map_unique_ino_dev(dentry, , );
> > /* userspace relies on this representation of dev_t */
> > seq_printf(f, "%d %02x:%02x:%ld ", fl_pid,
> > -   MAJOR(inode->i_sb->s_dev),
> > -   MINOR(inode->i_sb->s_dev), inode->i_ino);
> > +   MAJOR(dev), MINOR(dev), inode->i_ino);
> 
> Don't you mean ,ino); ?

Indeed I do, thanks for catching that one Amir.
--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


Re: [PATCH 1/4] vfs: introduce function to map unique ino/dev pairs

2018-08-01 Thread Mark Fasheh
Hi Amir,

On Wed, Aug 01, 2018 at 08:41:14AM +0300, Amir Goldstein wrote:
> > +void vfs_map_unique_ino_dev(struct dentry *dentry, u64 *ino, dev_t *dev)
> 
> I find this function name a bit more than function can guaranty.
> It's just a fancy wrapper around ->getattr()
> How about vfs_get_ino_dev() ?

Yeah I agree with that. An early version actually had the name
vfs_get_ino_dev(), I don't mind going back to it.

Thanks for the review!
--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


Re: [PATCH 1/4] vfs: introduce function to map unique ino/dev pairs

2018-07-31 Thread Mark Fasheh


On Tue, Jul 31, 2018 at 02:10:42PM -0700, Mark Fasheh wrote:
> diff --git a/fs/stat.c b/fs/stat.c
> index f8e6fb2c3657..80ea42505219 100644
> --- a/fs/stat.c
> +++ b/fs/stat.c
> @@ -84,6 +84,29 @@ int vfs_getattr_nosec(const struct path *path, struct 
> kstat *stat,
>  }
>  EXPORT_SYMBOL(vfs_getattr_nosec);
>  
> +void vfs_map_unique_ino_dev(struct dentry *dentry, u64 *ino, dev_t *dev)
> +{
> + int ret;
> + struct path path;
> + struct kstat stat;
> +
> + path.mnt = NULL;
> + path.dentry = dentry;
> + /* ->dev is always returned, so we only need to specify ino here */
> + ret = vfs_getattr_nosec(, , STATX_INO, 0);
> + if (ret) {
> + struct inode *inode = d_inode(dentry);
> + /* Fallback to old behavior in case of getattr error */
> + *ino = inode->i_ino;
> + *dev = inode->i_sb->s_dev;
> + return ret;

Ooof, attached is a version of this patch which doesn't try to return a value
from a void function. Apologies for the extra e-mail.

>From Mark Fasheh 

[PATCH 1/4] vfs: introduce function to map unique ino/dev pairs

There are places in the VFS where we export an ino/dev pair to userspace.
/proc/PID/maps is a good example - we directly expose inode->i_ino and
inode->i_sb->s_dev to userspace there.  Many filesystems don't put a unique
value in inode->i_ino and instead rely on ->getattr to provide the real
inode number to userspace.  super->s_dev is similar - some filesystems
expose a difference device from what's put in super->s_dev when queried via
stat/statx.

Ultimately this makes it impossible for a user (or software) to match one of
those reported pairs to the right inode.

We can fix this by adding a helper function, vfs_map_unique_ino_dev(), which
will query the owning filesystem (via ->getattr) to get the correct ino/dev
pair.  Later patches will update those places which simply dump inode->i_ino
and super->s_dev to use the helper.

Signed-off-by: Mark Fasheh 
---
 fs/stat.c  | 22 ++
 include/linux/fs.h |  2 ++
 2 files changed, 24 insertions(+)

diff --git a/fs/stat.c b/fs/stat.c
index f8e6fb2c3657..20c72d618ed5 100644
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -84,6 +84,28 @@ int vfs_getattr_nosec(const struct path *path, struct kstat 
*stat,
 }
 EXPORT_SYMBOL(vfs_getattr_nosec);
 
+void vfs_map_unique_ino_dev(struct dentry *dentry, u64 *ino, dev_t *dev)
+{
+   int ret;
+   struct path path;
+   struct kstat stat;
+
+   path.mnt = NULL;
+   path.dentry = dentry;
+   /* ->dev is always returned, so we only need to specify ino here */
+   ret = vfs_getattr_nosec(, , STATX_INO, 0);
+   if (ret) {
+   struct inode *inode = d_inode(dentry);
+   /* Fallback to old behavior in case of getattr error */
+   *ino = inode->i_ino;
+   *dev = inode->i_sb->s_dev;
+   return;
+   }
+   *ino = stat.ino;
+   *dev = stat.dev;
+}
+EXPORT_SYMBOL(vfs_map_unique_ino_dev);
+
 /*
  * vfs_getattr - Get the enhanced basic attributes of a file
  * @path: The file of interest
diff --git a/include/linux/fs.h b/include/linux/fs.h
index d78d146a98da..b80789472438 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -3077,6 +3077,8 @@ extern void kfree_link(void *);
 extern void generic_fillattr(struct inode *, struct kstat *);
 extern int vfs_getattr_nosec(const struct path *, struct kstat *, u32, 
unsigned int);
 extern int vfs_getattr(const struct path *, struct kstat *, u32, unsigned int);
+extern void vfs_map_unique_ino_dev(struct dentry *dentry, u64 *ino, dev_t 
*dev);
+
 void __inode_add_bytes(struct inode *inode, loff_t bytes);
 void inode_add_bytes(struct inode *inode, loff_t bytes);
 void __inode_sub_bytes(struct inode *inode, loff_t bytes);
-- 
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


Re: [PATCH 2/4] nfs: check for NULL vfsmount in nfs_getattr

2018-07-31 Thread Mark Fasheh
Hi Al,

On Tue, Jul 31, 2018 at 11:16:05PM +0100, Al Viro wrote:
> On Tue, Jul 31, 2018 at 02:10:43PM -0700, Mark Fasheh wrote:
> > ->getattr from inside the kernel won't always have a vfsmount, check for
> > this.
> 
> Really?  Where would that happen?

It happens in my first patch. FWIW, I'm not tied to that particular bit of
code, or even this (latest) approach. I would actually very much appreciate
your input into how we might fix the problem we have where we are sometimes
not exporting a correct ino/dev pair to user space.

I have a good break-down of the problem and possible solutions here:

https://www.spinics.net/lists/linux-fsdevel/msg128003.html

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 1/4] vfs: introduce function to map unique ino/dev pairs

2018-07-31 Thread Mark Fasheh
There are places in the VFS where we export an ino/dev pair to userspace.
/proc/PID/maps is a good example - we directly expose inode->i_ino and
inode->i_sb->s_dev to userspace there.  Many filesystems don't put a unique
value in inode->i_ino and instead rely on ->getattr to provide the real
inode number to userspace.  super->s_dev is similar - some filesystems
expose a difference device from what's put in super->s_dev when queried via
stat/statx.

Ultimately this makes it impossible for a user (or software) to match one of
those reported pairs to the right inode.

We can fix this by adding a helper function, vfs_map_unique_ino_dev(), which
will query the owning filesystem (via ->getattr) to get the correct ino/dev
pair.  Later patches will update those places which simply dump inode->i_ino
and super->s_dev to use the helper.

Signed-off-by: Mark Fasheh 
---
 fs/stat.c  | 23 +++
 include/linux/fs.h |  2 ++
 2 files changed, 25 insertions(+)

diff --git a/fs/stat.c b/fs/stat.c
index f8e6fb2c3657..80ea42505219 100644
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -84,6 +84,29 @@ int vfs_getattr_nosec(const struct path *path, struct kstat 
*stat,
 }
 EXPORT_SYMBOL(vfs_getattr_nosec);
 
+void vfs_map_unique_ino_dev(struct dentry *dentry, u64 *ino, dev_t *dev)
+{
+   int ret;
+   struct path path;
+   struct kstat stat;
+
+   path.mnt = NULL;
+   path.dentry = dentry;
+   /* ->dev is always returned, so we only need to specify ino here */
+   ret = vfs_getattr_nosec(, , STATX_INO, 0);
+   if (ret) {
+   struct inode *inode = d_inode(dentry);
+   /* Fallback to old behavior in case of getattr error */
+   *ino = inode->i_ino;
+   *dev = inode->i_sb->s_dev;
+   return ret;
+   }
+   *ino = stat.ino;
+   *dev = stat.dev;
+   return 0;
+}
+EXPORT_SYMBOL(vfs_map_unique_ino_dev);
+
 /*
  * vfs_getattr - Get the enhanced basic attributes of a file
  * @path: The file of interest
diff --git a/include/linux/fs.h b/include/linux/fs.h
index d78d146a98da..b80789472438 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -3077,6 +3077,8 @@ extern void kfree_link(void *);
 extern void generic_fillattr(struct inode *, struct kstat *);
 extern int vfs_getattr_nosec(const struct path *, struct kstat *, u32, 
unsigned int);
 extern int vfs_getattr(const struct path *, struct kstat *, u32, unsigned int);
+extern void vfs_map_unique_ino_dev(struct dentry *dentry, u64 *ino, dev_t 
*dev);
+
 void __inode_add_bytes(struct inode *inode, loff_t bytes);
 void inode_add_bytes(struct inode *inode, loff_t bytes);
 void __inode_sub_bytes(struct inode *inode, loff_t bytes);
-- 
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 2/4] nfs: check for NULL vfsmount in nfs_getattr

2018-07-31 Thread Mark Fasheh
->getattr from inside the kernel won't always have a vfsmount, check for
this.

Signed-off-by: Mark Fasheh 
---
 fs/nfs/inode.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index b65aee481d13..7a3d90a7cc92 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -795,7 +795,9 @@ int nfs_getattr(const struct path *path, struct kstat *stat,
}
 
/*
-* We may force a getattr if the user cares about atime.
+* We may force a getattr if the user cares about atime. A
+* NULL vfsmount means we are called from inside the kernel,
+* where no atime is required.
 *
 * Note that we only have to check the vfsmount flags here:
 *  - NFS always sets S_NOATIME by so checking it would give a
@@ -803,7 +805,7 @@ int nfs_getattr(const struct path *path, struct kstat *stat,
 *  - NFS never sets SB_NOATIME or SB_NODIRATIME so there is
 *no point in checking those.
 */
-   if ((path->mnt->mnt_flags & MNT_NOATIME) ||
+   if (!path->mnt || (path->mnt->mnt_flags & MNT_NOATIME) ||
((path->mnt->mnt_flags & MNT_NODIRATIME) && S_ISDIR(inode->i_mode)))
request_mask &= ~STATX_ATIME;
 
-- 
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 4/4] locks: map correct ino/dev pairs when exporting to userspace

2018-07-31 Thread Mark Fasheh
/proc/locks does not always print the correct inode number/device pair.
Update lock_get_status() to use vfs_map_unique_ino_dev() to get the real,
unique values for userspace.

Signed-off-by: Mark Fasheh 
---
 fs/locks.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/fs/locks.c b/fs/locks.c
index db7b6917d9c5..3a012df87fd8 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -2621,6 +2621,7 @@ static void lock_get_status(struct seq_file *f, struct 
file_lock *fl,
loff_t id, char *pfx)
 {
struct inode *inode = NULL;
+   struct dentry *dentry;
unsigned int fl_pid;
struct pid_namespace *proc_pidns = file_inode(f->file)->i_sb->s_fs_info;
 
@@ -2633,8 +2634,10 @@ static void lock_get_status(struct seq_file *f, struct 
file_lock *fl,
if (fl_pid == 0)
return;
 
-   if (fl->fl_file != NULL)
+   if (fl->fl_file != NULL) {
inode = locks_inode(fl->fl_file);
+   dentry = file_dentry(fl->fl_file);
+   }
 
seq_printf(f, "%lld:%s ", id, pfx);
if (IS_POSIX(fl)) {
@@ -2681,10 +2684,13 @@ static void lock_get_status(struct seq_file *f, struct 
file_lock *fl,
   : (fl->fl_type == F_WRLCK) ? "WRITE" : "READ ");
}
if (inode) {
+   __u64 ino;
+   dev_t dev;
+
+   vfs_map_unique_ino_dev(dentry, , );
/* userspace relies on this representation of dev_t */
seq_printf(f, "%d %02x:%02x:%ld ", fl_pid,
-   MAJOR(inode->i_sb->s_dev),
-   MINOR(inode->i_sb->s_dev), inode->i_ino);
+   MAJOR(dev), MINOR(dev), inode->i_ino);
} else {
seq_printf(f, "%d :0 ", fl_pid);
}
-- 
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


[RFC PATCH 0/4] vfs: map unique ino/dev pairs for user space

2018-07-31 Thread Mark Fasheh
Hi,

These patches are follow-up to this conversation on fsdevel which provides a
good break-down of the core problem:

https://www.spinics.net/lists/linux-fsdevel/msg128003.html

That e-mail was in turn a follow-up to the following patch series:

https://lwn.net/Articles/753917/

which tried to solve the dev portion of this problem with a bit of structure
re-routing but was never accepted.


We have an inconsistency in how the kernel is exporting inode number /
device pairs for user space.  I'm not talking about stat(2) or statx(2) here
but everywhere else where an ino/dev is exported into a buffer for user
space.

We typically do this by simply dumping the potentially 32 bit inode->i_ino
and single device from super->s_dev.  Sometimes these values differ from
what is returned via stat(2) or statx(2).  Some filesystems might even show
duplicate (but internally different!) pairs when the raw i_ino/s_dev is
used.

Aside from breaking software which expects these pairs to be unique, this
can put the user in a situation where they might not be able to find an
inode referenced from some kernel log (be it /proc/, printk buffer, etc). 
What's even worse - depending on how ino is exported, they might even find
an existing but /wrong/ file.

The following patches fix these inconsistencies by introducing a VFS helper
function which calls the underlying filesystem ->getattr to get our real
inode number / device pair.  The returned values can then be used at those
places in the kernel where we are incorrectly reporting our ino/dev pair. 
We then update fs/proc/ and fs/locks.c to use this helper when writing to
/proc/PID/maps and /proc/locks respectively.


For anyone who is watching the evolution of these patches, this would be one
implementation of the 'callback' method which I discussed in my last e-mail. 
This approach is very straight forward and easy to understand but has some
drawbacks:

- Not all of the call sites can tolerate errors.  Instead, we fallback to
  inode->i_ino and super->s_dev in case of getattr error.  That behavior is
  no worse than what we have today but what we have today is pretty bad so I
  don't particularly feel good about that. It's better than nothing though.

- There are places in the kernel where we could never call into ->getattr. 
  There are tons of tracepoints for example that are printing the the wrong
  ino/dev pair.

- The helper function has to fake a path struct because getting a vfsmount
  from inside these call sites is impossible.  This isn't actually a big
  deal as nobody except NFS cares and the NFS patch is very trivial.  It's
  ugly though, so if we had consensus on this approach I would happily
  rework our ->getattr function signature, perhaps pulling the vfsmount and
  dentry arguments back out.

- The dentry argument to ->getattr is potentially problematic as we have
  some places which _only_ have an inode. Even if we had a dentry I'm not
  sure what would keep it from going negative while in the middle of our
  ->getattr call.


Comments and review would be greatly 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 3/4] proc: use vfs helper to get ino/dev pairs for maps file

2018-07-31 Thread Mark Fasheh
Proc writes ino/dev into /proc/PID/maps which it gets from i_ino and s_dev.
The problem with this is that i_ino and s_dev are not guaranteed to be
unique - we can have duplicates in the maps file for otherwise distinct
inodes.

This breaks any software expecting them to be unique, including lsof(8).  We
can fix this by using vfs_map_unique_ino_dev() to map the unique ino/dev
pair for us.

Signed-off-by: Mark Fasheh 
---
 fs/proc/nommu.c  | 11 ---
 fs/proc/task_mmu.c   |  8 +++-
 fs/proc/task_nommu.c |  8 +++-
 3 files changed, 10 insertions(+), 17 deletions(-)

diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
index 3b63be64e436..56c12d02c5ad 100644
--- a/fs/proc/nommu.c
+++ b/fs/proc/nommu.c
@@ -36,7 +36,7 @@
  */
 static int nommu_region_show(struct seq_file *m, struct vm_region *region)
 {
-   unsigned long ino = 0;
+u64 ino = 0;
struct file *file;
dev_t dev = 0;
int flags;
@@ -44,15 +44,12 @@ static int nommu_region_show(struct seq_file *m, struct 
vm_region *region)
flags = region->vm_flags;
file = region->vm_file;
 
-   if (file) {
-   struct inode *inode = file_inode(region->vm_file);
-   dev = inode->i_sb->s_dev;
-   ino = inode->i_ino;
-   }
+   if (file)
+   vfs_map_unique_ino_dev(file_dentry(file), , ); {
 
seq_setwidth(m, 25 + sizeof(void *) * 6 - 1);
seq_printf(m,
-  "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu ",
+  "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %llu ",
   region->vm_start,
   region->vm_end,
   flags & VM_READ ? 'r' : '-',
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index dfd73a4616ce..e9cd33425191 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -276,7 +276,7 @@ static int is_stack(struct vm_area_struct *vma)
 static void show_vma_header_prefix(struct seq_file *m,
   unsigned long start, unsigned long end,
   vm_flags_t flags, unsigned long long pgoff,
-  dev_t dev, unsigned long ino)
+  dev_t dev, u64 ino)
 {
seq_setwidth(m, 25 + sizeof(void *) * 6 - 1);
seq_put_hex_ll(m, NULL, start, 8);
@@ -299,16 +299,14 @@ show_map_vma(struct seq_file *m, struct vm_area_struct 
*vma, int is_pid)
struct mm_struct *mm = vma->vm_mm;
struct file *file = vma->vm_file;
vm_flags_t flags = vma->vm_flags;
-   unsigned long ino = 0;
+   u64 ino = 0;
unsigned long long pgoff = 0;
unsigned long start, end;
dev_t dev = 0;
const char *name = NULL;
 
if (file) {
-   struct inode *inode = file_inode(vma->vm_file);
-   dev = inode->i_sb->s_dev;
-   ino = inode->i_ino;
+   vfs_map_unique_ino_dev(file_dentry(file), , );
pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
}
 
diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
index 5b62f57bd9bc..1198e979ed3f 100644
--- a/fs/proc/task_nommu.c
+++ b/fs/proc/task_nommu.c
@@ -146,7 +146,7 @@ static int nommu_vma_show(struct seq_file *m, struct 
vm_area_struct *vma,
  int is_pid)
 {
struct mm_struct *mm = vma->vm_mm;
-   unsigned long ino = 0;
+   u64 ino = 0;
struct file *file;
dev_t dev = 0;
int flags;
@@ -156,15 +156,13 @@ static int nommu_vma_show(struct seq_file *m, struct 
vm_area_struct *vma,
file = vma->vm_file;
 
if (file) {
-   struct inode *inode = file_inode(vma->vm_file);
-   dev = inode->i_sb->s_dev;
-   ino = inode->i_ino;
+   vfs_map_unique_inode_dev(file_dentry(file), , ));
pgoff = (loff_t)vma->vm_pgoff << PAGE_SHIFT;
}
 
seq_setwidth(m, 25 + sizeof(void *) * 6 - 1);
seq_printf(m,
-  "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu ",
+  "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %llu ",
   vma->vm_start,
   vma->vm_end,
   flags & VM_READ ? 'r' : '-',
-- 
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


Re: [RESEND][PATCH v4 0/2] vfs: better dedupe permission check

2018-07-17 Thread Mark Fasheh
CCing Michael Kerrisk and linux-api 

The patch at the end of this e-mail updates our man page for
ioctl_fideduperange to reflect the changes proposed in this patch series:

https://marc.info/?l=linux-fsdevel=153185457324037=2

Any feedback would be appreciated. Thanks in advance.
--Mark

On Tue, Jul 17, 2018 at 12:48:18PM -0700, Darrick J. Wong wrote:
> On Tue, Jul 17, 2018 at 12:09:04PM -0700, Mark Fasheh wrote:
> > Hi Al,
> > 
> > The following patches fix a couple of issues with the permission check
> > we do in vfs_dedupe_file_range(). I sent them out for a few times now,
> > a changelog is attached. If they look ok to you, I'd appreciate them
> > being pushed upstream.
> > 
> > You can get them from git if you like:
> > 
> > git pull https://github.com/markfasheh/linux dedupe-perms
> > 
> > I also have a set of patches against 4.17 if you prefer. The code and
> > testing are identical:
> > 
> > git pull https://github.com/markfasheh/linux dedupe-perms-v4.17
> > 
> > 
> > The first patch expands our check to allow dedupe of a file if the
> > user owns it or otherwise would be allowed to write to it.
> > 
> > Current behavior is that we'll allow dedupe only if:
> > 
> > - the user is an admin (root)
> > - the user has the file open for write
> > 
> > This makes it impossible for a user to dedupe their own file set
> > unless they do it as root, or ensure that all files have write
> > permission. There's a couple of duperemove bugs open for this:
> > 
> > https://github.com/markfasheh/duperemove/issues/129
> > https://github.com/markfasheh/duperemove/issues/86
> > 
> > The other problem we have is also related to forcing the user to open
> > target files for write - A process trying to exec a file currently
> > being deduped gets ETXTBUSY. The answer (as above) is to allow them to
> > open the targets ro - root can already do this. There was a patch from
> > Adam Borowski to fix this back in 2016:
> > 
> > https://lkml.org/lkml/2016/7/17/130
> > 
> > which I have incorporated into my changes.
> > 
> > 
> > The 2nd patch fixes our return code for permission denied to be
> > EPERM. For some reason we're returning EINVAL - I think that's
> > probably my fault. At any rate, we need to be returning something
> > descriptive of the actual problem, otherwise callers see EINVAL and
> > can't really make a valid determination of what's gone wrong.
> > 
> > This has also popped up in duperemove, mostly in the form of cryptic
> > error messages. Because this is a code returned to userspace, I did
> > check the other users of extent-same that I could find. Both 'bees'
> > and 'rust-btrfs' do the same as duperemove and simply report the error
> > (as they should).
> > 
> > Please apply.
> > 
> > Thanks,
> >   --Mark
> > 
> > Changes from V3 to V4:
> > - Add a patch (below) to ioctl_fideduperange.2 explaining our
> >   changes. I will send this patch once the kernel update is
> >   accepted. Thanks to Darrick Wong for this suggestion.
> > - V3 discussion: https://www.spinics.net/lists/linux-btrfs/msg79135.html
> > 
> > Changes from V2 to V3:
> > - Return bool from allow_file_dedupe
> > - V2 discussion: https://www.spinics.net/lists/linux-btrfs/msg78421.html
> > 
> > Changes from V1 to V2:
> > - Add inode_permission check as suggested by Adam Borowski
> > - V1 discussion: https://marc.info/?l=linux-xfs=152606684017965=2
> > 
> > 
> > From: Mark Fasheh 
> > 
> > [PATCH] ioctl_fideduperange.2: clarify permission requirements
> > 
> > dedupe permission checks were recently relaxed - update our man page to
> > reflect those changes.
> > 
> > Signed-off-by: Mark Fasheh 
> > ---
> >  man2/ioctl_fideduperange.2 | 8 +---
> 
> Mmm, man page update, thank you for editing the documentation too!
> 
> Please cc linux-api and Michael Kerrisk so this can go upstream.


From: Mark Fasheh 

[PATCH] ioctl_fideduperange.2: clarify permission requirements

dedupe permission checks were recently relaxed - update our man page to
reflect those changes.

Signed-off-by: Mark Fasheh 
---
 man2/ioctl_fideduperange.2 | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/man2/ioctl_fideduperange.2 b/man2/ioctl_fideduperange.2
index 84d20a276..4040ee064 100644
--- a/man2/ioctl_fideduperange.2
+++ b/man2/ioctl_fideduperange.2
@@ -105,9 +105,12 @@ The field
 must be zero.
 During the call,
 .IR src_fd
-must be open for reading and
+must be open for reading.
 .IR dest_fd
-must be open for writ

Re: [RESEND][PATCH v4 0/2] vfs: better dedupe permission check

2018-07-17 Thread Mark Fasheh
On Tue, Jul 17, 2018 at 12:48:18PM -0700, Darrick J. Wong wrote:
> On Tue, Jul 17, 2018 at 12:09:04PM -0700, Mark Fasheh wrote:
> > From: Mark Fasheh 
> > 
> > [PATCH] ioctl_fideduperange.2: clarify permission requirements
> > 
> > dedupe permission checks were recently relaxed - update our man page to
> > reflect those changes.
> > 
> > Signed-off-by: Mark Fasheh 
> > ---
> >  man2/ioctl_fideduperange.2 | 8 +---
> 
> Mmm, man page update, thank you for editing the documentation too!

No problem, thanks for suggesting I do it.


> Please cc linux-api and Michael Kerrisk so this can go upstream.

Will do. The changes you point out below all look good to me so I'll
incorporate them and send an updated version to the appropriate folks.

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 v4 1/2] vfs: allow dedupe of user owned read-only files

2018-07-17 Thread Mark Fasheh
The permission check in vfs_dedupe_file_range() is too coarse - We
only allow dedupe of the destination file if the user is root, or
they have the file open for write.

This effectively limits a non-root user from deduping their own read-only
files. In addition, the write file descriptor that the user is forced to
hold open can prevent execution of files. As file data during a dedupe
does not change, the behavior is unexpected and this has caused a number of
issue reports. For an example, see:

https://github.com/markfasheh/duperemove/issues/129

So change the check so we allow dedupe on the target if:

- the root or admin is asking for it
- the process has write access
- the owner of the file is asking for the dedupe
- the process could get write access

That way users can open read-only and still get dedupe.

Signed-off-by: Mark Fasheh 
Acked-by: Darrick J. Wong 
---
 fs/read_write.c | 17 +++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/fs/read_write.c b/fs/read_write.c
index e83bd9744b5d..71e9077f8bc1 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1964,6 +1964,20 @@ int vfs_dedupe_file_range_compare(struct inode *src, 
loff_t srcoff,
 }
 EXPORT_SYMBOL(vfs_dedupe_file_range_compare);
 
+/* Check whether we are allowed to dedupe the destination file */
+static bool allow_file_dedupe(struct file *file)
+{
+   if (capable(CAP_SYS_ADMIN))
+   return true;
+   if (file->f_mode & FMODE_WRITE)
+   return true;
+   if (uid_eq(current_fsuid(), file_inode(file)->i_uid))
+   return true;
+   if (!inode_permission(file_inode(file), MAY_WRITE))
+   return true;
+   return false;
+}
+
 int vfs_dedupe_file_range(struct file *file, struct file_dedupe_range *same)
 {
struct file_dedupe_range_info *info;
@@ -1972,7 +1986,6 @@ int vfs_dedupe_file_range(struct file *file, struct 
file_dedupe_range *same)
u64 len;
int i;
int ret;
-   bool is_admin = capable(CAP_SYS_ADMIN);
u16 count = same->dest_count;
struct file *dst_file;
loff_t dst_off;
@@ -2036,7 +2049,7 @@ int vfs_dedupe_file_range(struct file *file, struct 
file_dedupe_range *same)
 
if (info->reserved) {
info->status = -EINVAL;
-   } else if (!(is_admin || (dst_file->f_mode & FMODE_WRITE))) {
+   } else if (!allow_file_dedupe(dst_file)) {
info->status = -EINVAL;
} else if (file->f_path.mnt != dst_file->f_path.mnt) {
info->status = -EXDEV;
-- 
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 v4 2/2] vfs: dedupe should return EPERM if permission is not granted

2018-07-17 Thread Mark Fasheh
Right now we return EINVAL if a process does not have permission to dedupe a
file. This was an oversight on my part. EPERM gives a true description of
the nature of our error, and EINVAL is already used for the case that the
filesystem does not support dedupe.

Signed-off-by: Mark Fasheh 
Reviewed-by: Darrick J. Wong 
Acked-by: David Sterba 
---
 fs/read_write.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/read_write.c b/fs/read_write.c
index 71e9077f8bc1..7188982e2733 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -2050,7 +2050,7 @@ int vfs_dedupe_file_range(struct file *file, struct 
file_dedupe_range *same)
if (info->reserved) {
info->status = -EINVAL;
} else if (!allow_file_dedupe(dst_file)) {
-   info->status = -EINVAL;
+   info->status = -EPERM;
} else if (file->f_path.mnt != dst_file->f_path.mnt) {
info->status = -EXDEV;
} else if (S_ISDIR(dst->i_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


[RESEND][PATCH v4 0/2] vfs: better dedupe permission check

2018-07-17 Thread Mark Fasheh
Hi Al,

The following patches fix a couple of issues with the permission check
we do in vfs_dedupe_file_range(). I sent them out for a few times now,
a changelog is attached. If they look ok to you, I'd appreciate them
being pushed upstream.

You can get them from git if you like:

git pull https://github.com/markfasheh/linux dedupe-perms

I also have a set of patches against 4.17 if you prefer. The code and
testing are identical:

git pull https://github.com/markfasheh/linux dedupe-perms-v4.17


The first patch expands our check to allow dedupe of a file if the
user owns it or otherwise would be allowed to write to it.

Current behavior is that we'll allow dedupe only if:

- the user is an admin (root)
- the user has the file open for write

This makes it impossible for a user to dedupe their own file set
unless they do it as root, or ensure that all files have write
permission. There's a couple of duperemove bugs open for this:

https://github.com/markfasheh/duperemove/issues/129
https://github.com/markfasheh/duperemove/issues/86

The other problem we have is also related to forcing the user to open
target files for write - A process trying to exec a file currently
being deduped gets ETXTBUSY. The answer (as above) is to allow them to
open the targets ro - root can already do this. There was a patch from
Adam Borowski to fix this back in 2016:

https://lkml.org/lkml/2016/7/17/130

which I have incorporated into my changes.


The 2nd patch fixes our return code for permission denied to be
EPERM. For some reason we're returning EINVAL - I think that's
probably my fault. At any rate, we need to be returning something
descriptive of the actual problem, otherwise callers see EINVAL and
can't really make a valid determination of what's gone wrong.

This has also popped up in duperemove, mostly in the form of cryptic
error messages. Because this is a code returned to userspace, I did
check the other users of extent-same that I could find. Both 'bees'
and 'rust-btrfs' do the same as duperemove and simply report the error
(as they should).

Please apply.

Thanks,
  --Mark

Changes from V3 to V4:
- Add a patch (below) to ioctl_fideduperange.2 explaining our
  changes. I will send this patch once the kernel update is
  accepted. Thanks to Darrick Wong for this suggestion.
- V3 discussion: https://www.spinics.net/lists/linux-btrfs/msg79135.html

Changes from V2 to V3:
- Return bool from allow_file_dedupe
- V2 discussion: https://www.spinics.net/lists/linux-btrfs/msg78421.html

Changes from V1 to V2:
- Add inode_permission check as suggested by Adam Borowski
- V1 discussion: https://marc.info/?l=linux-xfs=152606684017965=2


From: Mark Fasheh 

[PATCH] ioctl_fideduperange.2: clarify permission requirements

dedupe permission checks were recently relaxed - update our man page to
reflect those changes.

Signed-off-by: Mark Fasheh 
---
 man2/ioctl_fideduperange.2 | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/man2/ioctl_fideduperange.2 b/man2/ioctl_fideduperange.2
index 84d20a276..7dea0323d 100644
--- a/man2/ioctl_fideduperange.2
+++ b/man2/ioctl_fideduperange.2
@@ -105,9 +105,11 @@ The field
 must be zero.
 During the call,
 .IR src_fd
-must be open for reading and
+must be open for reading.
 .IR dest_fd
-must be open for writing.
+can be open for writing, or reading. If
+.IR dest_fd
+is open for reading, the user should be have write access to the file.
 The combined size of the struct
 .IR file_dedupe_range
 and the struct
@@ -185,8 +187,8 @@ This can appear if the filesystem does not support 
deduplicating either file
 descriptor, or if either file descriptor refers to special inodes.
 .TP
 .B EPERM
+This will be returned if the user lacks permission to dedupe the file 
referenced by
 .IR dest_fd
-is immutable.
 .TP
 .B ETXTBSY
 One of the files is a swap 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


Re: Exporting a unique ino/dev pair to user space

2018-06-07 Thread Mark Fasheh
On Thu, Jun 07, 2018 at 10:38:51AM +0300, Amir Goldstein wrote:
> On Thu, Jun 7, 2018 at 12:38 AM, Mark Fasheh  wrote:
> > Hi,
> >
> > We have an inconsistency in how the kernel is exporting inode number /
> > device pairs for user space. There's of course stat(2) and statx(2),
> > but aside from those we simply dump inode->i_ino and super->s_dev. In
> > some cases, the dumped values differ from what is returned via stat(2)
> > or statx(2). Some filesystems might even show duplicate (but
> > internally different!) pairs when the raw i_ino/s_dev is used.
> >
> > Some examples where we dump raw ino/dev:
> >
> > - /proc//maps. I've written about how this confuses lsof(8):
> >   https://marc.info/?l=linux-btrfs=130074451403261=2
> >
> > - Unsurprisingly, many VFS tracepoints dump ino and/or dev. See
> >   trace/events/lock.h or trace/events/writeback.h for examples.
> >
> > - eventpoll also dumps the raw ino/dev pair via ep_show_fdinfo()
> >
> > - Audit records the raw ino/dev and passes them around. We do seem to
> >   have paths printed from audit as well, but if it's printed with the
> >   wrong ino/dev pair I believe my point still stands.
> >
> 
> knfsd also looks at i_ino. I converted one or two of these places
> to getattr callbacks recently, but there are still some more.
> 
> Anyway, w.r.t. Overlayfs, I believe Miklos' work to make file_inode()
> an overlay inode should resolve several of the issues listed above -
> probably not all, but didn't check every tracepoint..

Ok, thanks for letting me know about knfsd and the overlayfs work. I haven't
had a chance to check out the overlayfs work yet but I will shortly.


> > This breaks software which expects these pairs to be unique, and can
> > put the user in a situation where they might not be able to find an
> > inode referenced from the kernel. What's even worse - depending on how
> > ino is exported, they might even find the *wrong* inode.
> >
> > I also should point out that we're likely at this point because
> > stat(2) has been using an unsigned long for ino. On a 32 bit system,
> > it would have been impossible for the user to get the real inode
> > number in the first place. So there probably wasn't much we could do.
> >
> > These days though, we have statx(2) which will do the right thing on
> > all platforms so we no longer have that excuse. The user ought to be
> > able to take an ino/dev pair and ultimately find the actual file on
> > their system, partially with the help of statx(2).
> >
> >
> > Some examples of how ino is manipulated by filesystems:
> >
> > - On 64 bit i_ino and kstat->ino tend to be filled in correctly (from
> >   what I can tell). stat->dev is not always consistent with super->s_dev.
> >
> > - On 32 bits, many filesystems employ a transformation to squeeze a 64
> >   bit identifier into 32 bits. The exact methods are fs specific,
> >   what's important is that we're losing information, introducing the
> >   possibility of duplicate inode numbers.
> >
> > - On all platforms, Btrfs and Overlayfs can have duplicate inode
> >   numbers. Of course, device can be different across the fs as well
> >   with the kernel reporting s_dev and these filesystems returning
> >   a different device via stat() or statx().
> >
> >
> > Getting the inode number portion of this pair fixed would immediately
> > solve the situation for all filesystems except Btrfs and
> > Overlayfs - they report a different device from stat.
> >
> > Regarding the device portion of the pair, I'm honestly not sure
> > whether Overlayfs cares, and my attempts to fix the s_dev situation
> > for Btrfs have all come to the same dead ends that I've hit briefly
> > looking into this inode number issue - the problems are intrinsically
> > linked.
> >
> > So my questions are:
> >
> > 1) Do we care about this? On one hand, we've had this inconsistency
> >for a long time, for various reasons. On the other hand, I can point
> >to bugzilla's where these inconsistencies have become a problem.
> >
> >In the case that we don't care, any fs-internal solutions are
> >likely to be extremely disruptive to the end user.
> >
> >
> > 2) If we do care, how do we fix this?
> >
> >  2a) Do we use 64 bit i_ino on 32 bit systems? This has some obvious
> >  downsides from a memory usage standpoint. Also it doesn't fully
> >  address the issue - we still have a device field that Btrfs and
> >  Overlayfs override.
> >
> >  We cou

Re: [PATCH v3 1/2] vfs: allow dedupe of user owned read-only files

2018-06-07 Thread Mark Fasheh
Hi Darrick,

On Thu, Jun 07, 2018 at 11:17:51AM -0700, Darrick J. Wong wrote:
> Looks ok, but could you please update the manpage for
> ioctl_fideduperange to elaborate on when userspace can expect EPERM?
> 
> Acked-by: Darrick J. Wong 

Yes, good idea. I can handle that.

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 v3 2/2] vfs: dedupe should return EPERM if permission is not granted

2018-06-07 Thread Mark Fasheh
Right now we return EINVAL if a process does not have permission to dedupe a
file. This was an oversight on my part. EPERM gives a true description of
the nature of our error, and EINVAL is already used for the case that the
filesystem does not support dedupe.

Signed-off-by: Mark Fasheh 
Reviewed-by: Darrick J. Wong 
Acked-by: David Sterba 
---
 fs/read_write.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/read_write.c b/fs/read_write.c
index 71e9077f8bc1..7188982e2733 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -2050,7 +2050,7 @@ int vfs_dedupe_file_range(struct file *file, struct 
file_dedupe_range *same)
if (info->reserved) {
info->status = -EINVAL;
} else if (!allow_file_dedupe(dst_file)) {
-   info->status = -EINVAL;
+   info->status = -EPERM;
} else if (file->f_path.mnt != dst_file->f_path.mnt) {
info->status = -EXDEV;
} else if (S_ISDIR(dst->i_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 v3 0/2] vfs: better dedupe permission check

2018-06-07 Thread Mark Fasheh
Hi Al,

The following patches fix a couple of issues with the permission check
we do in vfs_dedupe_file_range(). I sent them out for review twice, a
changelog is attached. If they look ok to you, I'd appreciate them
being pushed upstream.

You can get them from git if you like:

git pull https://github.com/markfasheh/linux dedupe-perms


The first patch expands our check to allow dedupe of a file if the
user owns it or otherwise would be allowed to write to it.

Current behavior is that we'll allow dedupe only if:

- the user is an admin (root)
- the user has the file open for write

This makes it impossible for a user to dedupe their own file set
unless they do it as root, or ensure that all files have write
permission. There's a couple of duperemove bugs open for this:

https://github.com/markfasheh/duperemove/issues/129
https://github.com/markfasheh/duperemove/issues/86

The other problem we have is also related to forcing the user to open
target files for write - A process trying to exec a file currently
being deduped gets ETXTBUSY. The answer (as above) is to allow them to
open the targets ro - root can already do this. There was a patch from
Adam Borowski to fix this back in 2016:

https://lkml.org/lkml/2016/7/17/130

which I have incorporated into my changes.


The 2nd patch fixes our return code for permission denied to be
EPERM. For some reason we're returning EINVAL - I think that's
probably my fault. At any rate, we need to be returning something
descriptive of the actual problem, otherwise callers see EINVAL and
can't really make a valid determination of what's gone wrong.

This has also popped up in duperemove, mostly in the form of cryptic
error messages. Because this is a code returned to userspace, I did
check the other users of extent-same that I could find. Both 'bees'
and 'rust-btrfs' do the same as duperemove and simply report the error
(as they should).

Please apply.

Thanks,
  --Mark

Changes from V2 to V3:
- Return bool from allow_file_dedupe
- V2 discussion: https://www.spinics.net/lists/linux-btrfs/msg78421.html

Changes from V1 to V2:
- Add inode_permission check as suggested by Adam Borowski
- V1 discussion: https://marc.info/?l=linux-xfs=152606684017965=2
--
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 v3 1/2] vfs: allow dedupe of user owned read-only files

2018-06-07 Thread Mark Fasheh
The permission check in vfs_dedupe_file_range() is too coarse - We
only allow dedupe of the destination file if the user is root, or
they have the file open for write.

This effectively limits a non-root user from deduping their own read-only
files. In addition, the write file descriptor that the user is forced to
hold open can prevent execution of files. As file data during a dedupe
does not change, the behavior is unexpected and this has caused a number of
issue reports. For an example, see:

https://github.com/markfasheh/duperemove/issues/129

So change the check so we allow dedupe on the target if:

- the root or admin is asking for it
- the process has write access
- the owner of the file is asking for the dedupe
- the process could get write access

That way users can open read-only and still get dedupe.

Signed-off-by: Mark Fasheh 
---
 fs/read_write.c | 17 +++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/fs/read_write.c b/fs/read_write.c
index e83bd9744b5d..71e9077f8bc1 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1964,6 +1964,20 @@ int vfs_dedupe_file_range_compare(struct inode *src, 
loff_t srcoff,
 }
 EXPORT_SYMBOL(vfs_dedupe_file_range_compare);
 
+/* Check whether we are allowed to dedupe the destination file */
+static bool allow_file_dedupe(struct file *file)
+{
+   if (capable(CAP_SYS_ADMIN))
+   return true;
+   if (file->f_mode & FMODE_WRITE)
+   return true;
+   if (uid_eq(current_fsuid(), file_inode(file)->i_uid))
+   return true;
+   if (!inode_permission(file_inode(file), MAY_WRITE))
+   return true;
+   return false;
+}
+
 int vfs_dedupe_file_range(struct file *file, struct file_dedupe_range *same)
 {
struct file_dedupe_range_info *info;
@@ -1972,7 +1986,6 @@ int vfs_dedupe_file_range(struct file *file, struct 
file_dedupe_range *same)
u64 len;
int i;
int ret;
-   bool is_admin = capable(CAP_SYS_ADMIN);
u16 count = same->dest_count;
struct file *dst_file;
loff_t dst_off;
@@ -2036,7 +2049,7 @@ int vfs_dedupe_file_range(struct file *file, struct 
file_dedupe_range *same)
 
if (info->reserved) {
info->status = -EINVAL;
-   } else if (!(is_admin || (dst_file->f_mode & FMODE_WRITE))) {
+   } else if (!allow_file_dedupe(dst_file)) {
info->status = -EINVAL;
} else if (file->f_path.mnt != dst_file->f_path.mnt) {
info->status = -EXDEV;
-- 
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


Re: Exporting a unique ino/dev pair to user space

2018-06-06 Thread Mark Fasheh
Hi Ian,

On Thu, Jun 07, 2018 at 08:47:28AM +0800, Ian Kent wrote:
> On Wed, 2018-06-06 at 23:38 +0200, Mark Fasheh wrote:
> > Hi,
> 
> I'm not sure I understand what the problem is.

I'll try to elaborate below.


> > We have an inconsistency in how the kernel is exporting inode number /
> > device pairs for user space. There's of course stat(2) and statx(2),
> > but aside from those we simply dump inode->i_ino and super->s_dev. In
> > some cases, the dumped values differ from what is returned via stat(2)
> > or statx(2). Some filesystems might even show duplicate (but
> > internally different!) pairs when the raw i_ino/s_dev is used.
> 
> How is it that you can dump the raw ino and s_dev if your not in
> kernel code?

If you look below my first paragraph, you'll see a list of places where the
kernel publishes (maybe that's a better word?) ino/dev pairs by printing or
otherwise copying raw ino/s_dev values into user accesible buffers.


> For stat family system calls, if the file system defines the inode
> operation getattr it will be used to fill the stat structure otherwise
> the VFS will fill the stat  structure and it will use inode->i_ino and
> sb->s_dev as you say.

My concern is that those pairs are sometimes not unique and do not line up
with what statx(2) returns. We actually need the true inode / device as is
returned by statx in those places. I go into much more detail in my original
mail.


> > Some examples where we dump raw ino/dev:
> > 
> > - /proc//maps. I've written about how this confuses lsof(8):
> >   https://marc.info/?l=linux-btrfs=130074451403261=2
> > 
> > - Unsurprisingly, many VFS tracepoints dump ino and/or dev. See
> >   trace/events/lock.h or trace/events/writeback.h for examples.
> > 
> > - eventpoll also dumps the raw ino/dev pair via ep_show_fdinfo()
> > 
> > - Audit records the raw ino/dev and passes them around. We do seem to
> >   have paths printed from audit as well, but if it's printed with the
> >   wrong ino/dev pair I believe my point still stands.
> > 
> > 
> > This breaks software which expects these pairs to be unique, and can
> > put the user in a situation where they might not be able to find an
> > inode referenced from the kernel. What's even worse - depending on how
> > ino is exported, they might even find the *wrong* inode.

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


Exporting a unique ino/dev pair to user space

2018-06-06 Thread Mark Fasheh
Hi,

We have an inconsistency in how the kernel is exporting inode number /
device pairs for user space. There's of course stat(2) and statx(2),
but aside from those we simply dump inode->i_ino and super->s_dev. In
some cases, the dumped values differ from what is returned via stat(2)
or statx(2). Some filesystems might even show duplicate (but
internally different!) pairs when the raw i_ino/s_dev is used.

Some examples where we dump raw ino/dev:

- /proc//maps. I've written about how this confuses lsof(8):
  https://marc.info/?l=linux-btrfs=130074451403261=2

- Unsurprisingly, many VFS tracepoints dump ino and/or dev. See
  trace/events/lock.h or trace/events/writeback.h for examples.

- eventpoll also dumps the raw ino/dev pair via ep_show_fdinfo()

- Audit records the raw ino/dev and passes them around. We do seem to
  have paths printed from audit as well, but if it's printed with the
  wrong ino/dev pair I believe my point still stands.


This breaks software which expects these pairs to be unique, and can
put the user in a situation where they might not be able to find an
inode referenced from the kernel. What's even worse - depending on how
ino is exported, they might even find the *wrong* inode.

I also should point out that we're likely at this point because
stat(2) has been using an unsigned long for ino. On a 32 bit system,
it would have been impossible for the user to get the real inode
number in the first place. So there probably wasn't much we could do.

These days though, we have statx(2) which will do the right thing on
all platforms so we no longer have that excuse. The user ought to be
able to take an ino/dev pair and ultimately find the actual file on
their system, partially with the help of statx(2).


Some examples of how ino is manipulated by filesystems:

- On 64 bit i_ino and kstat->ino tend to be filled in correctly (from
  what I can tell). stat->dev is not always consistent with super->s_dev.

- On 32 bits, many filesystems employ a transformation to squeeze a 64
  bit identifier into 32 bits. The exact methods are fs specific,
  what's important is that we're losing information, introducing the
  possibility of duplicate inode numbers.

- On all platforms, Btrfs and Overlayfs can have duplicate inode
  numbers. Of course, device can be different across the fs as well
  with the kernel reporting s_dev and these filesystems returning
  a different device via stat() or statx().


Getting the inode number portion of this pair fixed would immediately
solve the situation for all filesystems except Btrfs and
Overlayfs - they report a different device from stat.

Regarding the device portion of the pair, I'm honestly not sure
whether Overlayfs cares, and my attempts to fix the s_dev situation
for Btrfs have all come to the same dead ends that I've hit briefly
looking into this inode number issue - the problems are intrinsically
linked.

So my questions are:

1) Do we care about this? On one hand, we've had this inconsistency
   for a long time, for various reasons. On the other hand, I can point
   to bugzilla's where these inconsistencies have become a problem.

   In the case that we don't care, any fs-internal solutions are
   likely to be extremely disruptive to the end user.


2) If we do care, how do we fix this?

 2a) Do we use 64 bit i_ino on 32 bit systems? This has some obvious
 downsides from a memory usage standpoint. Also it doesn't fully
 address the issue - we still have a device field that Btrfs and
 Overlayfs override.

 We could combine this with an intermediate structure between the
 inode and super block so s_dev could be abstracted out. See my
 fs_view patches for an example of how this could be done:
 https://www.spinics.net/lists/linux-fsdevel/msg125492.html

 2b) Do we call ->getattr for this information? Plumbing a vfsmount to
 various regions of the kernel like audit, or some of the deeper
 tracepoints looks ugly and prone to life-timing issues (which
 vfsmount do we use?). On the upside, we could probably make it
 really light by only sending down the STATX_INO flag and letting
 the filesystem optimize accordingly.

 2c) I don't think we can really use a dedicated callback without
 passing the vfsmount through since Overlayfs ->getattr might call
 the lower fs ->getattr. At that point we might as well use getattr.

I'd appreciate any comments or suggestions.

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


Re: [PATCH v2 2/2] vfs: dedupe should return EPERM if permission is not granted

2018-05-18 Thread Mark Fasheh
On Fri, May 18, 2018 at 03:04:13PM -0700, Darrick J. Wong wrote:
> On Fri, May 18, 2018 at 02:57:27PM -0700, Mark Fasheh wrote:
> > Right now we return EINVAL if a process does not have permission to dedupe a
> > file. This was an oversight on my part. EPERM gives a true description of
> > the nature of our error, and EINVAL is already used for the case that the
> > filesystem does not support dedupe.
> > 
> > Signed-off-by: Mark Fasheh <mfas...@suse.de>
> 
> Looks ok what with all the okays after I squawked last time,
> Reviewed-by: Darrick J. Wong <darrick.w...@oracle.com>

Awesome, I'll put that in the patch. Thanks Darrick.
--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


Re: [PATCH v2 1/2] vfs: allow dedupe of user owned read-only files

2018-05-18 Thread Mark Fasheh
On Fri, May 18, 2018 at 03:03:38PM -0700, Darrick J. Wong wrote:
> > +/* Check whether we are allowed to dedupe the destination file */
> > +static int allow_file_dedupe(struct file *file)
> 
> Shouldn't this return bool?  It's a predicate, after all...

Yeah that should be bool. Thanks for pointing it out, I'll fix it up in the
next round.
--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 v2 0/2] vfs: better dedupe permission check

2018-05-18 Thread Mark Fasheh
Hi,

The following patches fix a couple of issues with the permission
check we do in vfs_dedupe_file_range().

The first patch expands our check to allow dedupe of a file if the
user owns it or otherwise would be allowed to write to it.

Current behavior is that we'll allow dedupe only if:

- the user is an admin (root)
- the user has the file open for write

This makes it impossible for a user to dedupe their own file set
unless they do it as root, or ensure that all files have write
permission. There's a couple of duperemove bugs open for this:

https://github.com/markfasheh/duperemove/issues/129
https://github.com/markfasheh/duperemove/issues/86

The other problem we have is also related to forcing the user to open
target files for write - A process trying to exec a file currently
being deduped gets ETXTBUSY. The answer (as above) is to allow them to
open the targets ro - root can already do this. There was a patch from
Adam Borowski to fix this back in 2016:

https://lkml.org/lkml/2016/7/17/130

which I have incorporated into my changes.


The 2nd patch fixes our return code for permission denied to be
EPERM. For some reason we're returning EINVAL - I think that's
probably my fault. At any rate, we need to be returning something
descriptive of the actual problem, otherwise callers see EINVAL and
can't really make a valid determination of what's gone wrong.

This has also popped up in duperemove, mostly in the form of cryptic
error messages. Because this is a code returned to userspace, I did
check the other users of extent-same that I could find. Both 'bees'
and 'rust-btrfs' do the same as duperemove and simply report the error
(as they should).

The patches are also available in git:

git pull https://github.com/markfasheh/linux dedupe-perms

Thanks,
  --Mark


Changes from V1 to V2:
- Add inode_permission check as suggested by Adam Borowski
- V1 discussion: https://marc.info/?l=linux-xfs=152606684017965=2
--
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 v2 1/2] vfs: allow dedupe of user owned read-only files

2018-05-18 Thread Mark Fasheh
The permission check in vfs_dedupe_file_range() is too coarse - We
only allow dedupe of the destination file if the user is root, or
they have the file open for write.

This effectively limits a non-root user from deduping their own read-only
files. In addition, the write file descriptor that the user is forced to
hold open can prevent execution of files. As file data during a dedupe
does not change, the behavior is unexpected and this has caused a number of
issue reports. For an example, see:

https://github.com/markfasheh/duperemove/issues/129

So change the check so we allow dedupe on the target if:

- the root or admin is asking for it
- the process has write access
- the owner of the file is asking for the dedupe
- the process could get write access

That way users can open read-only and still get dedupe.

Signed-off-by: Mark Fasheh <mfas...@suse.de>
---
 fs/read_write.c | 17 +++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/fs/read_write.c b/fs/read_write.c
index c4eabbfc90df..cbea4ce58ad1 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1964,6 +1964,20 @@ int vfs_dedupe_file_range_compare(struct inode *src, 
loff_t srcoff,
 }
 EXPORT_SYMBOL(vfs_dedupe_file_range_compare);
 
+/* Check whether we are allowed to dedupe the destination file */
+static int allow_file_dedupe(struct file *file)
+{
+   if (capable(CAP_SYS_ADMIN))
+   return 1;
+   if (file->f_mode & FMODE_WRITE)
+   return 1;
+   if (uid_eq(current_fsuid(), file_inode(file)->i_uid))
+   return 1;
+   if (!inode_permission(file_inode(file), MAY_WRITE))
+   return 1;
+   return 0;
+}
+
 int vfs_dedupe_file_range(struct file *file, struct file_dedupe_range *same)
 {
struct file_dedupe_range_info *info;
@@ -1972,7 +1986,6 @@ int vfs_dedupe_file_range(struct file *file, struct 
file_dedupe_range *same)
u64 len;
int i;
int ret;
-   bool is_admin = capable(CAP_SYS_ADMIN);
u16 count = same->dest_count;
struct file *dst_file;
loff_t dst_off;
@@ -2036,7 +2049,7 @@ int vfs_dedupe_file_range(struct file *file, struct 
file_dedupe_range *same)
 
if (info->reserved) {
info->status = -EINVAL;
-   } else if (!(is_admin || (dst_file->f_mode & FMODE_WRITE))) {
+   } else if (!allow_file_dedupe(dst_file)) {
info->status = -EINVAL;
} else if (file->f_path.mnt != dst_file->f_path.mnt) {
info->status = -EXDEV;
-- 
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 v2 2/2] vfs: dedupe should return EPERM if permission is not granted

2018-05-18 Thread Mark Fasheh
Right now we return EINVAL if a process does not have permission to dedupe a
file. This was an oversight on my part. EPERM gives a true description of
the nature of our error, and EINVAL is already used for the case that the
filesystem does not support dedupe.

Signed-off-by: Mark Fasheh <mfas...@suse.de>
---
 fs/read_write.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/read_write.c b/fs/read_write.c
index cbea4ce58ad1..2238928ca819 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -2050,7 +2050,7 @@ int vfs_dedupe_file_range(struct file *file, struct 
file_dedupe_range *same)
if (info->reserved) {
info->status = -EINVAL;
} else if (!allow_file_dedupe(dst_file)) {
-   info->status = -EINVAL;
+   info->status = -EPERM;
} else if (file->f_path.mnt != dst_file->f_path.mnt) {
info->status = -EXDEV;
} else if (S_ISDIR(dst->i_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


Re: [PATCH 2/2] vfs: dedupe should return EPERM if permission is not granted

2018-05-17 Thread Mark Fasheh
On Thu, May 17, 2018 at 01:15:51AM -0400, Zygo Blaxell wrote:
> On Sun, May 13, 2018 at 11:26:39AM -0700, Darrick J. Wong wrote:
> > On Sun, May 13, 2018 at 06:21:52PM +0000, Mark Fasheh wrote:
> > > On Fri, May 11, 2018 at 05:06:34PM -0700, Darrick J. Wong wrote:
> > > > On Fri, May 11, 2018 at 12:26:51PM -0700, Mark Fasheh wrote:
> > > > > Right now we return EINVAL if a process does not have permission to 
> > > > > dedupe a
> > > > > file. This was an oversight on my part. EPERM gives a true 
> > > > > description of
> > > > > the nature of our error, and EINVAL is already used for the case that 
> > > > > the
> > > > > filesystem does not support dedupe.
> > > > > 
> > > > > Signed-off-by: Mark Fasheh <mfas...@suse.de>
> > > > > ---
> > > > >  fs/read_write.c | 2 +-
> > > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > > > 
> > > > > diff --git a/fs/read_write.c b/fs/read_write.c
> > > > > index 77986a2e2a3b..8edef43a182c 100644
> > > > > --- a/fs/read_write.c
> > > > > +++ b/fs/read_write.c
> > > > > @@ -2038,7 +2038,7 @@ int vfs_dedupe_file_range(struct file *file, 
> > > > > struct file_dedupe_range *same)
> > > > >   info->status = -EINVAL;
> > > > >   } else if (!(is_admin || (dst_file->f_mode & 
> > > > > FMODE_WRITE) ||
> > > > >uid_eq(current_fsuid(), dst->i_uid))) {
> > > > > - info->status = -EINVAL;
> > > > > + info->status = -EPERM;
> > > > 
> > > > Hmm, are we allowed to change this aspect of the kabi after the fact?
> > > > 
> > > > Granted, we're only trading one error code for another, but will the
> > > > existing users of this care?  xfs_io won't and I assume duperemove won't
> > > > either, but what about bees? :)
> > > 
> > > Yeah if you see my initial e-mail I check bees and also rust-btrfs. I 
> > > think
> > > this is fine as we're simply expanding on an error code return. There's no
> > > magic behavior expected with respect to these error codes either.
> > 
> > Ok.  No objections from me, then.
> > 
> > Acked-by: Darrick J. Wong <darrick.w...@oracle.com>
> 
> For what it's worth, no objection from me either.  ;)
> 
> bees runs only with admin privilege and will never hit the modified line.

Awesome, thanks for the review Zygo.
--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


Re: [PATCH 1/2] vfs: allow dedupe of user owned read-only files

2018-05-17 Thread Mark Fasheh
On Sun, May 13, 2018 at 10:50:25PM +0200, Adam Borowski wrote:
> On Sun, May 13, 2018 at 06:16:53PM +0000, Mark Fasheh wrote:
> > On Sat, May 12, 2018 at 04:49:20AM +0200, Adam Borowski wrote:
> > > On Fri, May 11, 2018 at 12:26:50PM -0700, Mark Fasheh wrote:
> > > > The permission check in vfs_dedupe_file_range() is too coarse - We
> > > > only allow dedupe of the destination file if the user is root, or
> > > > they have the file open for write.
> > > > 
> > > > This effectively limits a non-root user from deduping their own
> > > > read-only files. As file data during a dedupe does not change,
> > > > this is unexpected behavior and this has caused a number of issue
> > > > reports.
> [...]
> > > > So change the check so we allow dedupe on the target if:
> > > > 
> > > > - the root or admin is asking for it
> > > > - the owner of the file is asking for the dedupe
> > > > - the process has write access
> > > 
> > > I submitted a similar patch in May 2016, yet it has never been applied
> > > despite multiple pings, with no NAK.  My version allowed dedupe if:
> > > - the root or admin is asking for it
> > > - the file has w permission (on the inode -- ie, could have been opened 
> > > rw)
> > 
> > Ahh, yes I see that now. I did wind up acking it too :)
> > > 
> > > I like this new version better than mine: "root or owner or w" is more
> > > Unixy than "could have been opened w".
> > 
> > I agree, IMHO the behavior in this patch is intuitive. What we had before
> > would surprise users.
> 
> Actually, there's one reason to still consider "could have been opened w":
> with it, deduplication programs can simply open the file r and not care
> about ETXTBSY at all.  Otherwise, every program needs to stat() and have
> logic to pick the proper argument to the open() call (r if owner/root,
> rw or w if not).

That makes sense. The goal after all is to be able to just open r and not
worry about it. I hadn't considered the other possibilities that
inode_permission() covers. I'll make that change for my next series.

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


Re: [PATCH 2/2] vfs: dedupe should return EPERM if permission is not granted

2018-05-13 Thread Mark Fasheh
On Fri, May 11, 2018 at 05:06:34PM -0700, Darrick J. Wong wrote:
> On Fri, May 11, 2018 at 12:26:51PM -0700, Mark Fasheh wrote:
> > Right now we return EINVAL if a process does not have permission to dedupe a
> > file. This was an oversight on my part. EPERM gives a true description of
> > the nature of our error, and EINVAL is already used for the case that the
> > filesystem does not support dedupe.
> > 
> > Signed-off-by: Mark Fasheh <mfas...@suse.de>
> > ---
> >  fs/read_write.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/fs/read_write.c b/fs/read_write.c
> > index 77986a2e2a3b..8edef43a182c 100644
> > --- a/fs/read_write.c
> > +++ b/fs/read_write.c
> > @@ -2038,7 +2038,7 @@ int vfs_dedupe_file_range(struct file *file, struct 
> > file_dedupe_range *same)
> > info->status = -EINVAL;
> > } else if (!(is_admin || (dst_file->f_mode & FMODE_WRITE) ||
> >  uid_eq(current_fsuid(), dst->i_uid))) {
> > -   info->status = -EINVAL;
> > +   info->status = -EPERM;
> 
> Hmm, are we allowed to change this aspect of the kabi after the fact?
> 
> Granted, we're only trading one error code for another, but will the
> existing users of this care?  xfs_io won't and I assume duperemove won't
> either, but what about bees? :)

Yeah if you see my initial e-mail I check bees and also rust-btrfs. I think
this is fine as we're simply expanding on an error code return. There's no
magic behavior expected with respect to these error codes either.
--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


Re: [PATCH 1/2] vfs: allow dedupe of user owned read-only files

2018-05-13 Thread Mark Fasheh
Hey Adam,

On Sat, May 12, 2018 at 04:49:20AM +0200, Adam Borowski wrote:
> On Fri, May 11, 2018 at 12:26:50PM -0700, Mark Fasheh wrote:
> > The permission check in vfs_dedupe_file_range() is too coarse - We
> > only allow dedupe of the destination file if the user is root, or
> > they have the file open for write.
> > 
> > This effectively limits a non-root user from deduping their own
> > read-only files. As file data during a dedupe does not change,
> > this is unexpected behavior and this has caused a number of issue
> > reports. For an example, see:
> > 
> > https://github.com/markfasheh/duperemove/issues/129
> > 
> > So change the check so we allow dedupe on the target if:
> > 
> > - the root or admin is asking for it
> > - the owner of the file is asking for the dedupe
> > - the process has write access
> 
> I submitted a similar patch in May 2016, yet it has never been applied
> despite multiple pings, with no NAK.  My version allowed dedupe if:
> - the root or admin is asking for it
> - the file has w permission (on the inode -- ie, could have been opened rw)

Ahh, yes I see that now. I did wind up acking it too :)

> There was a request to include in xfstests a test case for the ETXTBSY race
> this patch fixes, but there's no reasonable way to make such a test case:
> the race condition is not a bug, it's write-xor-exec working as designed.
> 
> Another idea discussed was about possibly just allowing everyone who can
> open the file to deduplicate it, as the file contents are not modified in
> any way.  Zygo Blaxell expressed a concern that it could be used by an
> unprivileged user who can trigger a crash to abuse writeout bugs.
> 
> I like this new version better than mine: "root or owner or w" is more
> Unixy than "could have been opened w".

I agree, IMHO the behavior in this patch is intuitive. What we had before
would surprise users.

Yeah we've been careful about not letting a user dedupe some other users
file. Data-wise it technically might be ok but I can imagine several
scenarios where you might not want some other user deduping your files.

Thanks for the review,
--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 2/2] vfs: dedupe should return EPERM if permission is not granted

2018-05-11 Thread Mark Fasheh
Right now we return EINVAL if a process does not have permission to dedupe a
file. This was an oversight on my part. EPERM gives a true description of
the nature of our error, and EINVAL is already used for the case that the
filesystem does not support dedupe.

Signed-off-by: Mark Fasheh <mfas...@suse.de>
---
 fs/read_write.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/read_write.c b/fs/read_write.c
index 77986a2e2a3b..8edef43a182c 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -2038,7 +2038,7 @@ int vfs_dedupe_file_range(struct file *file, struct 
file_dedupe_range *same)
info->status = -EINVAL;
} else if (!(is_admin || (dst_file->f_mode & FMODE_WRITE) ||
 uid_eq(current_fsuid(), dst->i_uid))) {
-   info->status = -EINVAL;
+   info->status = -EPERM;
} else if (file->f_path.mnt != dst_file->f_path.mnt) {
info->status = -EXDEV;
} else if (S_ISDIR(dst->i_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 1/2] vfs: allow dedupe of user owned read-only files

2018-05-11 Thread Mark Fasheh
The permission check in vfs_dedupe_file_range() is too coarse - We
only allow dedupe of the destination file if the user is root, or
they have the file open for write.

This effectively limits a non-root user from deduping their own
read-only files. As file data during a dedupe does not change,
this is unexpected behavior and this has caused a number of issue
reports. For an example, see:

https://github.com/markfasheh/duperemove/issues/129

So change the check so we allow dedupe on the target if:

- the root or admin is asking for it
- the owner of the file is asking for the dedupe
- the process has write access

Signed-off-by: Mark Fasheh <mfas...@suse.de>
---
 fs/read_write.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/read_write.c b/fs/read_write.c
index c4eabbfc90df..77986a2e2a3b 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -2036,7 +2036,8 @@ int vfs_dedupe_file_range(struct file *file, struct 
file_dedupe_range *same)
 
if (info->reserved) {
info->status = -EINVAL;
-   } else if (!(is_admin || (dst_file->f_mode & FMODE_WRITE))) {
+   } else if (!(is_admin || (dst_file->f_mode & FMODE_WRITE) ||
+uid_eq(current_fsuid(), dst->i_uid))) {
info->status = -EINVAL;
} else if (file->f_path.mnt != dst_file->f_path.mnt) {
info->status = -EXDEV;
-- 
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 0/2] vfs: better dedupe permission check

2018-05-11 Thread Mark Fasheh
Hi,

The following patches fix a couple of issues with the permission
check we do in vfs_dedupe_file_range().

The first patch expands our check to allow dedupe of a readonly file
if the user owns it. Existing behavior is that we'll allow dedupe only
if:

- the user is an admin (root)
- the user has the file open for write

This makes it impossible for a user to dedupe their own file set
unless they do it as root, or ensure that all files have write
permission. There's a couple of duperemove bugs open for this:

https://github.com/markfasheh/duperemove/issues/129
https://github.com/markfasheh/duperemove/issues/86

The solution is simple - we allow dedupe of the target if the user
owns it. With that patch, a user can dedupe all of their files.

The 2nd patch fixes our return code for permission denied to be
EPERM. For some reason we're returning EINVAL - I think that's
probably my fault. At any rate, we need to be returning something
descriptive of the actual problem, otherwise callers see EINVAL and
can't really make a valid determination of what's gone wrong.

This has also popped up in duperemove, mostly in the form of cryptic
error messages. Because this is a code returned to userspace, I did
check the other users of extent-same that I could find. Both 'bees'
and 'rust-btrfs' do the same as duperemove and simply report the error
(as they should).

The patches are also available in git:

git pull https://github.com/markfasheh/linux dedupe-perms

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


[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 <mfas...@suse.de>
---
 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 <mfas...@suse.de>
---
 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;
+   s

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

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh <mfas...@suse.de>
---
 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 <mfas...@suse.de>
---
 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_I

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

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh <mfas...@suse.de>
---
 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 <mfas...@suse.de>
---
 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 < (1<i_blkbits))
count = 0;
else
diff --git a/drivers/staging/lustre/lustre/llite/dir.c 
b/drivers/staging/lustre/lustre/llite/dir.c
index 99b0b77c75f5..809e493b61da 100644
--- a/drivers/staging/lustre/lustre/llite/dir.c
+++ b/drivers/staging/lustre/lustre/llite/dir.c
@@ -448,7 +448,7 @@ static int ll_dir_setdirstripe(struct inode *parent, struct 
lmv_user_md *lump,
cfs_curproc_cap_pack(), 0, );
ll_finish_md_op_data(op_data);
 
-   err = ll_prep_inode(, request, parent->i_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: looku

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

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh <mfas...@suse.de>
---
 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 

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

2018-05-08 Thread Mark Fasheh
Signed-off-by: Mark Fasheh <mfas...@suse.de>
---
 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 

[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 <mfas...@suse.de>
---
 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, f

[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 <mfas...@suse.de>
---
 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 <mfas...@suse.de>
---
 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)
   

[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 <mfas...@suse.de>
---
 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 <mfas...@suse.de>
---
 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 <mfas...@suse.de>
---
 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-f

[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 <mfas...@suse.de>
---
 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 <mfas...@suse.de>
---
 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 <mfas...@suse.de>
---
 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;
di

[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 <mfas...@suse.de>
---
 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 *

[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 <mfas...@suse.de>
---
 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, fi

[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 <mfas...@suse.de>
---
 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++;
 

[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 <mfas...@suse.de>
---
 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.

[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 <mfas...@suse.de>
---
 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 <mfas...@suse.de>
---
 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_

[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 <mfas...@suse.de>
---
 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 <mfas...@suse.de>
---
 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

[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 <mfas...@suse.de>
---
 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 <mfas...@suse.de>
---
 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 <mfas...@suse.de>
---
 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(

[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 <mfas...@suse.de>
---
 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(con

[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 <mfas...@suse.de>
---
 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-btr

[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 <mfas...@suse.de>
---
 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 <mfas...@suse.de>
---
 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

[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 <mfas...@suse.de>
---
 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_

[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 <mfas...@suse.de>
---
 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(i

[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 <mfas...@suse.de>
---
 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,
+

[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 <mfas...@suse.de>
---
 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;
+   struc

[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 <mfas...@suse.de>
---
 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;

[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 <mfas...@suse.de>
---
 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;
   

[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 <mfas...@suse.de>
---
 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 <mfas...@suse.de>
---
 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 
ad

[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 <mfas...@suse.de>
---
 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 <mfas...@suse.de>
---
 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 <mfas...@suse.de>
---
 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

[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 <mfas...@suse.de>
---
 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, 
)))
  

[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 <mfas...@suse.de>
---
 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;
-   st

[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 <mfas...@suse.de>
---
 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 <mfas...@suse.de>
---
 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_rel

[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 <mfas...@suse.de>
---
 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 <mfas...@suse.de>
---
 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/nil

[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 <mfas...@suse.de>
---
 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))

[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 <mfas...@suse.de>
---
 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 {
   

[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 <mfas...@suse.de>
---
 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 <mfas...@suse.de>
---
 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 <mfas...@suse.de>
---
 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_sh

[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 <mfas...@suse.de>
---
 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


  1   2   3   4   5   >