Skip to content

Commit

Permalink
cifs: add function to get a tcon from cifs_sb
Browse files Browse the repository at this point in the history
When we convert cifs to do multiple sessions per mount, we'll need more
than one tcon per superblock. At that point "cifs_sb->tcon" will make
no sense. Add a new accessor function that gets a tcon given a cifs_sb.
For now, it just returns cifs_sb->tcon. Later it'll do more.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Steve French <sfrench@us.ibm.com>
  • Loading branch information
Jeff Layton authored and Steve French committed Sep 29, 2010
1 parent ba00ba6 commit a6e8a84
Show file tree
Hide file tree
Showing 13 changed files with 74 additions and 71 deletions.
2 changes: 1 addition & 1 deletion fs/cifs/cifs_dfs_ref.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ cifs_dfs_follow_mountpoint(struct dentry *dentry, struct nameidata *nd)
nd->path.dentry = dget(dentry);

cifs_sb = CIFS_SB(dentry->d_inode->i_sb);
ses = cifs_sb->tcon->ses;
ses = cifs_sb_tcon(cifs_sb)->ses;

if (!ses) {
rc = -EINVAL;
Expand Down
16 changes: 8 additions & 8 deletions fs/cifs/cifsacl.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ static struct cifs_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb,
int xid, rc;

xid = GetXid();
rc = CIFSSMBGetCIFSACL(xid, cifs_sb->tcon, fid, &pntsd, pacllen);
rc = CIFSSMBGetCIFSACL(xid, cifs_sb_tcon(cifs_sb), fid, &pntsd, pacllen);
FreeXid(xid);


Expand All @@ -577,18 +577,18 @@ static struct cifs_ntsd *get_cifs_acl_by_path(struct cifs_sb_info *cifs_sb,

xid = GetXid();

rc = CIFSSMBOpen(xid, cifs_sb->tcon, path, FILE_OPEN, READ_CONTROL, 0,
rc = CIFSSMBOpen(xid, cifs_sb_tcon(cifs_sb), path, FILE_OPEN, READ_CONTROL, 0,
&fid, &oplock, NULL, cifs_sb->local_nls,
cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
if (rc) {
cERROR(1, "Unable to open file to get ACL");
goto out;
}

rc = CIFSSMBGetCIFSACL(xid, cifs_sb->tcon, fid, &pntsd, pacllen);
rc = CIFSSMBGetCIFSACL(xid, cifs_sb_tcon(cifs_sb), fid, &pntsd, pacllen);
cFYI(1, "GetCIFSACL rc = %d ACL len %d", rc, *pacllen);

CIFSSMBClose(xid, cifs_sb->tcon, fid);
CIFSSMBClose(xid, cifs_sb_tcon(cifs_sb), fid);
out:
FreeXid(xid);
return pntsd;
Expand Down Expand Up @@ -618,7 +618,7 @@ static int set_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb, __u16 fid,
int xid, rc;

xid = GetXid();
rc = CIFSSMBSetCIFSACL(xid, cifs_sb->tcon, fid, pnntsd, acllen);
rc = CIFSSMBSetCIFSACL(xid, cifs_sb_tcon(cifs_sb), fid, pnntsd, acllen);
FreeXid(xid);

cFYI(DBG2, "SetCIFSACL rc = %d", rc);
Expand All @@ -634,18 +634,18 @@ static int set_cifs_acl_by_path(struct cifs_sb_info *cifs_sb, const char *path,

xid = GetXid();

rc = CIFSSMBOpen(xid, cifs_sb->tcon, path, FILE_OPEN, WRITE_DAC, 0,
rc = CIFSSMBOpen(xid, cifs_sb_tcon(cifs_sb), path, FILE_OPEN, WRITE_DAC, 0,
&fid, &oplock, NULL, cifs_sb->local_nls,
cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
if (rc) {
cERROR(1, "Unable to open file to set ACL");
goto out;
}

rc = CIFSSMBSetCIFSACL(xid, cifs_sb->tcon, fid, pnntsd, acllen);
rc = CIFSSMBSetCIFSACL(xid, cifs_sb_tcon(cifs_sb), fid, pnntsd, acllen);
cFYI(DBG2, "SetCIFSACL rc = %d", rc);

CIFSSMBClose(xid, cifs_sb->tcon, fid);
CIFSSMBClose(xid, cifs_sb_tcon(cifs_sb), fid);
out:
FreeXid(xid);
return rc;
Expand Down
11 changes: 3 additions & 8 deletions fs/cifs/cifsfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,6 @@ cifs_read_super(struct super_block *sb, void *data,
sb->s_magic = CIFS_MAGIC_NUMBER;
sb->s_op = &cifs_super_ops;
sb->s_bdi = &cifs_sb->bdi;
/* if (cifs_sb->tcon->ses->server->maxBuf > MAX_CIFS_HDR_SIZE + 512)
sb->s_blocksize =
cifs_sb->tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE; */
sb->s_blocksize = CIFS_MAX_MSGSIZE;
sb->s_blocksize_bits = 14; /* default 2**14 = CIFS_MAX_MSGSIZE */
inode = cifs_root_iget(sb, ROOT_I);
Expand Down Expand Up @@ -225,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;
struct cifsTconInfo *tcon = cifs_sb_tcon(cifs_sb);
int rc = -EOPNOTSUPP;
int xid;

Expand Down Expand Up @@ -367,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;
struct cifsTconInfo *tcon = cifs_sb_tcon(cifs_sb);
struct sockaddr *srcaddr;
srcaddr = (struct sockaddr *)&tcon->ses->server->srcaddr;

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

tcon = cifs_sb->tcon;
if (tcon == NULL)
return;
tcon = cifs_sb_tcon(cifs_sb);

read_lock(&cifs_tcp_ses_lock);
if ((tcon->tc_count > 1) || (tcon->tidStatus == CifsExiting)) {
Expand Down
6 changes: 6 additions & 0 deletions fs/cifs/cifsglob.h
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,12 @@ CIFS_SB(struct super_block *sb)
return sb->s_fs_info;
}

static inline struct cifsTconInfo *
cifs_sb_tcon(struct cifs_sb_info *cifs_sb)
{
return cifs_sb->tcon;
}

static inline char CIFS_DIR_SEP(const struct cifs_sb_info *cifs_sb)
{
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS)
Expand Down
4 changes: 2 additions & 2 deletions fs/cifs/connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -3026,8 +3026,8 @@ cifs_umount(struct super_block *sb, struct cifs_sb_info *cifs_sb)
int rc = 0;
char *tmp;

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

cifs_sb->tcon = NULL;
tmp = cifs_sb->prepath;
Expand Down
20 changes: 10 additions & 10 deletions fs/cifs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ build_path_from_dentry(struct dentry *direntry)
cifs_sb = CIFS_SB(direntry->d_sb);
dirsep = CIFS_DIR_SEP(cifs_sb);
pplen = cifs_sb->prepathlen;
if (cifs_sb->tcon && (cifs_sb->tcon->Flags & SMB_SHARE_IS_IN_DFS))
dfsplen = strnlen(cifs_sb->tcon->treeName, MAX_TREE_SIZE + 1);
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);
else
dfsplen = 0;
cifs_bp_rename_retry:
Expand Down Expand Up @@ -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->treeName, dfsplen);
strncpy(full_path, cifs_sb_tcon(cifs_sb)->treeName, dfsplen);
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) {
int i;
for (i = 0; i < dfsplen; i++) {
Expand Down Expand Up @@ -150,15 +150,15 @@ cifs_new_fileinfo(struct inode *newinode, __u16 fileHandle,
pCifsFile->pfile = file;
pCifsFile->invalidHandle = false;
pCifsFile->closePend = false;
pCifsFile->tcon = cifs_sb->tcon;
pCifsFile->tcon = cifs_sb_tcon(cifs_sb);
mutex_init(&pCifsFile->fh_mutex);
mutex_init(&pCifsFile->lock_mutex);
INIT_LIST_HEAD(&pCifsFile->llist);
atomic_set(&pCifsFile->count, 1);
INIT_WORK(&pCifsFile->oplock_break, cifs_oplock_break);

write_lock(&GlobalSMBSeslock);
list_add(&pCifsFile->tlist, &cifs_sb->tcon->openFileList);
list_add(&pCifsFile->tlist, &cifs_sb_tcon(cifs_sb)->openFileList);
pCifsInode = CIFS_I(newinode);
if (pCifsInode) {
/* if readable file instance put first in list*/
Expand Down Expand Up @@ -225,7 +225,7 @@ int cifs_posix_open(char *full_path, struct inode **pinode,
posix_flags |= SMB_O_DIRECT;

mode &= ~current_umask();
rc = CIFSPOSIXCreate(xid, cifs_sb->tcon, posix_flags, mode,
rc = CIFSPOSIXCreate(xid, cifs_sb_tcon(cifs_sb), posix_flags, mode,
pnetfid, presp_data, poplock, full_path,
cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR);
Expand Down Expand Up @@ -298,7 +298,7 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
xid = GetXid();

cifs_sb = CIFS_SB(inode->i_sb);
tcon = cifs_sb->tcon;
tcon = cifs_sb_tcon(cifs_sb);

full_path = build_path_from_dentry(direntry);
if (full_path == NULL) {
Expand Down Expand Up @@ -373,7 +373,7 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
if (!tcon->unix_ext && (mode & S_IWUGO) == 0)
create_options |= CREATE_OPTION_READONLY;

if (cifs_sb->tcon->ses->capabilities & CAP_NT_SMBS)
if (tcon->ses->capabilities & CAP_NT_SMBS)
rc = CIFSSMBOpen(xid, tcon, full_path, disposition,
desiredAccess, create_options,
&fileHandle, &oplock, buf, cifs_sb->local_nls,
Expand Down Expand Up @@ -504,7 +504,7 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode,
xid = GetXid();

cifs_sb = CIFS_SB(inode->i_sb);
pTcon = cifs_sb->tcon;
pTcon = cifs_sb_tcon(cifs_sb);

full_path = build_path_from_dentry(direntry);
if (full_path == NULL) {
Expand Down Expand Up @@ -631,7 +631,7 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry,
/* check whether path exists */

cifs_sb = CIFS_SB(parent_dir_inode->i_sb);
pTcon = cifs_sb->tcon;
pTcon = cifs_sb_tcon(cifs_sb);

/*
* Don't allow the separator character in a path component.
Expand Down
4 changes: 2 additions & 2 deletions fs/cifs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ int cifs_open(struct inode *inode, struct file *file)
xid = GetXid();

cifs_sb = CIFS_SB(inode->i_sb);
tcon = cifs_sb->tcon;
tcon = cifs_sb_tcon(cifs_sb);

pCifsInode = CIFS_I(file->f_path.dentry->d_inode);

Expand Down Expand Up @@ -345,7 +345,7 @@ int cifs_open(struct inode *inode, struct file *file)
goto out;
}

if (cifs_sb->tcon->ses->capabilities & CAP_NT_SMBS)
if (tcon->ses->capabilities & CAP_NT_SMBS)
rc = CIFSSMBOpen(xid, tcon, full_path, disposition,
desiredAccess, CREATE_NOT_DIR, &netfid, &oplock, buf,
cifs_sb->local_nls, cifs_sb->mnt_cifs_flags
Expand Down
7 changes: 4 additions & 3 deletions fs/cifs/fscache.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ static void cifs_fscache_enable_inode_cookie(struct inode *inode)
if (cifsi->fscache)
return;

cifsi->fscache = fscache_acquire_cookie(cifs_sb->tcon->fscache,
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->fscache, cifsi->fscache);
cifs_sb_tcon(cifs_sb)->fscache, cifsi->fscache);
}

void cifs_fscache_release_inode_cookie(struct inode *inode)
Expand Down Expand Up @@ -117,7 +117,8 @@ void cifs_fscache_reset_inode_cookie(struct inode *inode)
/* retire the current fscache cache and get a new one */
fscache_relinquish_cookie(cifsi->fscache, 1);

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

0 comments on commit a6e8a84

Please sign in to comment.