CIFS: Migrate to shared superblock model
Add cifs_match_super to use in sget to share superblock between mounts
that have the same //server/sharename, credentials and mount options.
It helps us to improve performance on work with future SMB2.1 leases.
Reviewed-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Pavel Shilovsky <piastry@etersoft.ru>
Signed-off-by: Steve French <sfrench@us.ibm.com>
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 46fdd55..360fe2e 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -630,6 +630,7 @@
struct super_block *sb;
struct cifs_sb_info *cifs_sb;
struct smb_vol *volume_info;
+ struct cifs_mnt_data mnt_data;
struct dentry *root;
cFYI(1, "Devname: %s flags: %d ", dev_name, flags);
@@ -646,12 +647,21 @@
cifs_setup_cifs_sb(volume_info, cifs_sb);
- sb = sget(fs_type, NULL, set_anon_super, NULL);
+ mnt_data.vol = volume_info;
+ mnt_data.cifs_sb = cifs_sb;
+ mnt_data.flags = flags;
+
+ sb = sget(fs_type, cifs_match_super, set_anon_super, &mnt_data);
if (IS_ERR(sb)) {
root = ERR_CAST(sb);
goto out_cifs_sb;
}
+ if (sb->s_fs_info) {
+ cFYI(1, "Use existing superblock");
+ goto out_shared;
+ }
+
/*
* Copy mount params for use in submounts. Better to do
* the copy here and deal with the error before cleanup gets
@@ -680,9 +690,16 @@
root = cifs_get_root(volume_info, sb);
if (root == NULL)
goto out_super;
+
cFYI(1, "dentry root is: %p", root);
goto out;
+out_shared:
+ root = cifs_get_root(volume_info, sb);
+ if (root)
+ cFYI(1, "dentry root is: %p", root);
+ goto out;
+
out_super:
kfree(cifs_sb->mountdata);
deactivate_locked_super(sb);