Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0d424ad0 authored by Jeff Layton's avatar Jeff Layton Committed by Steve French
Browse files

cifs: add cifs_sb_master_tcon and convert some callers to use it



At mount time, we'll always need to create a tcon that will serve as a
template for others that are associated with the mount. This tcon is
known as the "master" tcon.

In some cases, we'll need to use that tcon regardless of who's accessing
the mount. Add an accessor function for the master tcon and go ahead and
switch the appropriate places to use it.

Signed-off-by: default avatarJeff Layton <jlayton@redhat.com>
Signed-off-by: default avatarSteve French <sfrench@us.ibm.com>
parent f6acb9d0
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -222,7 +222,7 @@ cifs_statfs(struct dentry *dentry, struct kstatfs *buf)
{
	struct super_block *sb = dentry->d_sb;
	struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
	struct cifsTconInfo *tcon = cifs_sb_tcon(cifs_sb);
	struct cifsTconInfo *tcon = cifs_sb_master_tcon(cifs_sb);
	int rc = -EOPNOTSUPP;
	int xid;

@@ -364,7 +364,7 @@ static int
cifs_show_options(struct seq_file *s, struct vfsmount *m)
{
	struct cifs_sb_info *cifs_sb = CIFS_SB(m->mnt_sb);
	struct cifsTconInfo *tcon = cifs_sb_tcon(cifs_sb);
	struct cifsTconInfo *tcon = cifs_sb_master_tcon(cifs_sb);
	struct sockaddr *srcaddr;
	srcaddr = (struct sockaddr *)&tcon->ses->server->srcaddr;

@@ -455,7 +455,7 @@ static void cifs_umount_begin(struct super_block *sb)
	if (cifs_sb == NULL)
		return;

	tcon = cifs_sb_tcon(cifs_sb);
	tcon = cifs_sb_master_tcon(cifs_sb);

	read_lock(&cifs_tcp_ses_lock);
	if ((tcon->tc_count > 1) || (tcon->tidStatus == CifsExiting)) {
+7 −0
Original line number Diff line number Diff line
@@ -419,6 +419,13 @@ cifs_sb_tcon(struct cifs_sb_info *cifs_sb)
	return cifs_sb->ptcon;
}

/* This function is always expected to succeed */
static inline struct cifsTconInfo *
cifs_sb_master_tcon(struct cifs_sb_info *cifs_sb)
{
	return cifs_sb->ptcon;
}

static inline char CIFS_DIR_SEP(const struct cifs_sb_info *cifs_sb)
{
	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS)
+2 −2
Original line number Diff line number Diff line
@@ -3025,9 +3025,9 @@ cifs_umount(struct super_block *sb, struct cifs_sb_info *cifs_sb)
{
	int rc = 0;
	char *tmp;
	struct cifsTconInfo *tcon = cifs_sb_master_tcon(cifs_sb);

	if (cifs_sb_tcon(cifs_sb))
		cifs_put_tcon(cifs_sb_tcon(cifs_sb));
	cifs_put_tcon(tcon);

	cifs_sb->ptcon = NULL;
	tmp = cifs_sb->prepath;
+5 −5
Original line number Diff line number Diff line
@@ -54,18 +54,18 @@ build_path_from_dentry(struct dentry *direntry)
	int dfsplen;
	char *full_path;
	char dirsep;
	struct cifs_sb_info *cifs_sb;
	struct cifs_sb_info *cifs_sb = CIFS_SB(direntry->d_sb);
	struct cifsTconInfo *tcon = cifs_sb_master_tcon(cifs_sb);

	if (direntry == NULL)
		return NULL;  /* not much we can do if dentry is freed and
		we need to reopen the file after it was closed implicitly
		when the server crashed */

	cifs_sb = CIFS_SB(direntry->d_sb);
	dirsep = CIFS_DIR_SEP(cifs_sb);
	pplen = cifs_sb->prepathlen;
	if (cifs_sb_tcon(cifs_sb) && (cifs_sb_tcon(cifs_sb)->Flags & SMB_SHARE_IS_IN_DFS))
		dfsplen = strnlen(cifs_sb_tcon(cifs_sb)->treeName, MAX_TREE_SIZE + 1);
	if (tcon->Flags & SMB_SHARE_IS_IN_DFS)
		dfsplen = strnlen(tcon->treeName, MAX_TREE_SIZE + 1);
	else
		dfsplen = 0;
cifs_bp_rename_retry:
@@ -117,7 +117,7 @@ build_path_from_dentry(struct dentry *direntry)
	/* BB test paths to Windows with '/' in the midst of prepath */

	if (dfsplen) {
		strncpy(full_path, cifs_sb_tcon(cifs_sb)->treeName, dfsplen);
		strncpy(full_path, tcon->treeName, dfsplen);
		if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) {
			int i;
			for (i = 0; i < dfsplen; i++) {
+6 −6
Original line number Diff line number Diff line
@@ -62,15 +62,15 @@ static void cifs_fscache_enable_inode_cookie(struct inode *inode)
{
	struct cifsInodeInfo *cifsi = CIFS_I(inode);
	struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
	struct cifsTconInfo *tcon = cifs_sb_master_tcon(cifs_sb);

	if (cifsi->fscache)
		return;

	cifsi->fscache = fscache_acquire_cookie(cifs_sb_tcon(cifs_sb)->fscache,
				&cifs_fscache_inode_object_def,
				cifsi);
	cFYI(1, "CIFS: got FH cookie (0x%p/0x%p)",
			cifs_sb_tcon(cifs_sb)->fscache, cifsi->fscache);
	cifsi->fscache = fscache_acquire_cookie(tcon->fscache,
				&cifs_fscache_inode_object_def, cifsi);
	cFYI(1, "CIFS: got FH cookie (0x%p/0x%p)", tcon->fscache,
				cifsi->fscache);
}

void cifs_fscache_release_inode_cookie(struct inode *inode)
@@ -118,7 +118,7 @@ void cifs_fscache_reset_inode_cookie(struct inode *inode)
		fscache_relinquish_cookie(cifsi->fscache, 1);

		cifsi->fscache = fscache_acquire_cookie(
					cifs_sb_tcon(cifs_sb)->fscache,
					cifs_sb_master_tcon(cifs_sb)->fscache,
					&cifs_fscache_inode_object_def,
					cifsi);
		cFYI(1, "CIFS: new cookie 0x%p oldcookie 0x%p",
Loading