cifs: multiuser mount overhaul (try #3)
Subsystems (3)
cover cifs: multiuser mount overhaul (try #3)
The last version of this patchset was sent back in April. At that time, I called them "multisession mounts". This patchset is the next iteration of that set, rebased against the current state of Steve's cifs-2.6 tree.
The reason for the name change is simple -- people seemed to be confused by calling them "multisession mounts". Hopefully by calling them "multiuser mounts", that confusion will be reduced.
There are really only a couple of changes since the last time I posted these patches:
1) the mount option has been renamed to "multiuser"
2) the tcon_link container is now properly refcounted and timestamped.
This should allow for pruning of unused sessions, probably by scheduling a workqueue task via kernel timer or something along those lines. The patch to do that has not been implemented yet, but the pieces are all in place and I don't expect it will be too tough to do. That can be implemented later -- it's just that unused sessions in multiuser mounts will linger around for now.
The patchset looks quite a bit different than the earlier one, primarily because of this latter piece. Since references to the tcon_link are taken by callers, they have to be put so this necessitates some error handling cleanup.
The patchset seems to work for me so far. I ran it through a few hundred passes of the Connectathon testsuite with unix extensions enabled and disabled. It passed without issue and everything seems to work as expected.
I'd like to see this go into the 2.6.37 release if there are no objections. There will be merge conflicts between this and Metze's mfsymlink work. We'll just need to determine which one goes in first to know who needs to rebase to what.
Jeff Layton (15):
cifs: eliminate redundant xdev check in cifs_rename
cifs: add tcon field to cifsFileInfo struct
cifs: make various routines use the cifsFileInfo->tcon pointer
cifs: fix handling of signing with writepages
cifs: add function to get a tcon from cifs_sb
cifs: temporarily rename cifs_sb->tcon to ptcon to catch stragglers
cifs: add cifs_sb_master_tcon and convert some callers to use it
cifs: have cifs_new_fileinfo take a tcon arg
cifs: add refcounted and timestamped container for holding tcons
cifs: have cifsFileInfo hold a reference to a tlink rather than tcon
pointer
cifs: have find_readable/writable_file filter by fsuid
cifs: fix cifs_show_options to show "username=" or "multiuser"
cifs: add routines to build sessions and tcons on the fly
cifs: on multiuser mount, set ownership to
current_fsuid/current_fsgid
cifs: add "multiuser" mount option
fs/cifs/cifs_dfs_ref.c | 21 ++-- fs/cifs/cifs_fs_sb.h | 10 +- fs/cifs/cifsacl.c | 46 ++++++-- fs/cifs/cifsfs.c | 22 ++-- fs/cifs/cifsglob.h | 39 +++++++ fs/cifs/cifsproto.h | 7 +- fs/cifs/connect.c | 285 ++++++++++++++++++++++++++++++++++++++++++++++- fs/cifs/dir.c | 95 +++++++++++----- fs/cifs/file.c | 161 +++++++++++++++------------ fs/cifs/fscache.c | 13 +- fs/cifs/inode.c | 241 ++++++++++++++++++++++++++++------------ fs/cifs/ioctl.c | 17 +--- fs/cifs/link.c | 55 ++++++---- fs/cifs/misc.c | 2 +- fs/cifs/readdir.c | 45 ++++---- fs/cifs/xattr.c | 60 +++++++---- 16 files changed, 816 insertions(+), 303 deletions(-)
Signature · 1 line
1.7.2.1
PATCH 1/15 cifs: eliminate redundant xdev check in cifs_rename
The VFS always checks that the source and target of a rename are on the same vfsmount, and hence have the same superblock. So, this check is redundant. Remove it and simplify the error handling.
--- fs/cifs/inode.c | 30 +++++++++--------------------- 1 files changed, 9 insertions(+), 21 deletions(-)
fs/cifs/inode.c +9 -21
@@ -1468,29 +1468,18 @@ int cifs_rename(struct inode *source_dir, struct dentry *source_dentry, {char *fromName =NULL ;char *toName =NULL ; -struct cifs_sb_info *cifs_sb_source; -struct cifs_sb_info *cifs_sb_target; +struct cifs_sb_info *cifs_sb;struct cifsTconInfo *tcon;FILE_UNIX_BASIC_INFO *info_buf_source =NULL ;FILE_UNIX_BASIC_INFO *info_buf_target;int xid, rc, tmprc; - cifs_sb_target =CIFS_SB (target_dir->i_sb); - cifs_sb_source =CIFS_SB (source_dir->i_sb); - tcon = cifs_sb_source->tcon; + cifs_sb =CIFS_SB (source_dir->i_sb); + tcon = cifs_sb->tcon; xid =GetXid ();/* -* BB: this might be allowed if same server, but different share. -* Consider adding support for this -*/ -if (tcon != cifs_sb_target->tcon) { - rc = -EXDEV ; - goto cifs_rename_exit; - } - -/* * we already have the rename sem so we do not need to * grab it again here to protect the path integrity */
@@ -1525,17 +1514,16 @@ int cifs_rename(struct inode *source_dir, struct dentry *source_dentry, info_buf_target = info_buf_source +1 ; tmprc =CIFSSMBUnixQPathInfo (xid, tcon, fromName, info_buf_source, - cifs_sb_source->local_nls, - cifs_sb_source->mnt_cifs_flags & + cifs_sb->local_nls, + cifs_sb->mnt_cifs_flags &CIFS_MOUNT_MAP_SPECIAL_CHR );if (tmprc !=0 ) goto unlink_target; - tmprc =CIFSSMBUnixQPathInfo (xid, tcon, - toName, info_buf_target, - cifs_sb_target->local_nls, -/* remap based on source sb */ - cifs_sb_source->mnt_cifs_flags & + tmprc =CIFSSMBUnixQPathInfo (xid, tcon, toName, + info_buf_target, + cifs_sb->local_nls, + cifs_sb->mnt_cifs_flags &CIFS_MOUNT_MAP_SPECIAL_CHR ); if (tmprc == 0 && (info_buf_source->UniqueId ==
Signature · 1 line
1.7.2.1
A message that is not in the archive (sent off-list or not yet received): 1282332731-17444-2-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Re: [PATCH 01/15] cifs: eliminate redundant xdev check in cifs_rename
Quoted 3 lines · Jeff Layton
The VFS always checks that the source and target of a rename are on the same vfsmount, and hence have the same superblock. So, this check is redundant. Remove it and simplify the error handling.
I looked more closely at this, and although EXDEV is checked for in one place (early in the rename syscall), there are other paths to iop->cifs_rename (nfs server and cachefiles for example call vfs_rename directly) which do not check this, so it looks like the cifs EXDEV check
is not redundant and should be kept.
Signature · 3 lines
Thanks, Steve
A message that is not in the archive (sent off-list or not yet received): AANLkTikVRKBA-sv3F8cJMFV3nfqfu4AYXXJ9E4Ja+Qv+-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH 01/15] cifs: eliminate redundant xdev check in cifs_rename
Quoted 5 lines · On Wed, 25 Aug 2010 11:34:07 -0500 Steve French…
Quoted 3 lines · Jeff Layton
The VFS always checks that the source and target of a rename are on the same vfsmount, and hence have the same superblock. So, this check is redundant. Remove it and simplify the error handling.
Quoted 8 lines
I looked more closely at this, and although EXDEV is checked for in one place (early in the rename syscall), there are other paths to
iop->cifs_rename(nfs server and cachefiles for example callvfs_renamedirectly) which do not check this, so it looks like the cifs EXDEV check
is not redundant and should be kept.
(cc'ing linux-fsdevel)
The nfs server checks for it. In nfsd_rename:
host_err = -EXDEV;
if (ffhp->fh_export->ex_path.mnt != tfhp->fh_export->ex_path.mnt)
goto out_dput_new;I don't think cachefiles would work if you split the cache directory across multiple filesystems. Most filesystems don't check for this on their own, so I'm not sure why we need to have cifs do this in a special fashion.
Signature · 1 line
Jeff Layton <[email protected]>
Re: [PATCH 01/15] cifs: eliminate redundant xdev check in cifs_rename
In reply to a message not in the archiveQuoted 10 lines · Steve French
Quoted 3 lines · Jeff Layton
The VFS always checks that the source and target of a rename are on the same vfsmount, and hence have the same superblock. So, this check is redundant. Remove it and simplify the error handling.
I looked more closely at this, and although EXDEV is checked for in one place (early in the rename syscall), there are other paths to
iop->cifs_rename(nfs server and cachefiles for example callvfs_renamedirectly) which do not check this, so it looks like the cifs EXDEV check
is not redundant and should be kept.
If ->rename evers gets called with dentries on different superblocks hell would break lose. nfsd also explicitly checks for it, and in cachefiles it can't happen because we do a lookup_one_len on the local fs for the target. Note that these cases matter for cifs anyway given that it doesn't provide export ops.
There is no need to keep this junk around.
PATCH 2/15 cifs: add tcon field to cifsFileInfo struct
In reply to Jeff LaytonEventually, we'll have more than one tcon per superblock. At that point, we'll need to know which one is associated with a particular fid. For now, this is just set from the cifs_sb->tcon pointer, but eventually the caller of cifs_new_fileinfo will pass a tcon pointer in.
--- fs/cifs/cifsglob.h | 1 + fs/cifs/dir.c | 1 + 2 files changed, 2 insertions(+), 0 deletions(-)
fs/cifs/cifsglob.h +1 -0
@@ -348,6 +348,7 @@ struct cifsFileInfo {struct file *pfile;/* needed for writepage */ struct inode *pInode;/* needed for oplock break */ struct vfsmount *mnt; +struct cifsTconInfo *tcon;struct mutex lock_mutex;struct list_head llist;/* list of byte range locks we have. */ bool closePend:1; /* file is marked to close */
fs/cifs/dir.c +1 -0
@@ -153,6 +153,7 @@ cifs_new_fileinfo(struct inode *newinode, __u16 fileHandle, pCifsFile->pfile = file; pCifsFile->invalidHandle = false; pCifsFile->closePend = false; + pCifsFile->tcon = cifs_sb->tcon;mutex_init (&pCifsFile->fh_mutex);mutex_init (&pCifsFile->lock_mutex);INIT_LIST_HEAD (&pCifsFile->llist);
Signature · 1 line
1.7.2.1
A message that is not in the archive (sent off-list or not yet received): 1282332731-17444-1-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
PATCH 3/15 cifs: make various routines use the cifsFileInfo->tcon pointer
...where it's available and appropriate.
--- fs/cifs/cifsfs.c | 4 ++-- fs/cifs/file.c | 39 ++++++++++++++++----------------------- fs/cifs/inode.c | 22 ++++++++++++++++------ fs/cifs/ioctl.c | 17 +++-------------- fs/cifs/readdir.c | 19 ++++++++----------- 5 files changed, 45 insertions(+), 56 deletions(-)
fs/cifs/cifsfs.c +2 -2
@@ -570,6 +570,7 @@ static int cifs_setlease(struct file *file, long arg, struct file_lock **lease)/* note that this is called by vfs setlease with the BKL held although I doubt that BKL is needed here in cifs */ struct inode *inode = file->f_path.dentry->d_inode; +struct cifsFileInfo *cfile = file->private_data;if (!(S_ISREG (inode->i_mode)))return -EINVAL ;
@@ -580,8 +581,7 @@ static int cifs_setlease(struct file *file, long arg, struct file_lock **lease) ((arg == F_WRLCK) && (CIFS_I(inode)->clientCanCacheAll)))return generic_setlease (file, arg, lease); - else if (CIFS_SB(inode->i_sb)->tcon->local_lease && - !CIFS_I(inode)->clientCanCacheRead) + else if (cfile->tcon->local_lease && !CIFS_I(inode)->clientCanCacheRead)/* If the server claims to support oplock on this file, then we still need to check oplock even if the local_lease mount option is set, but there
fs/cifs/file.c +16 -23
@@ -461,7 +461,7 @@ static int cifs_reopen_file(struct file *file, bool can_flush) } cifs_sb =CIFS_SB (inode->i_sb); - tcon = cifs_sb->tcon; + tcon = pCifsFile->tcon;/* can not grab rename sem here because various ops, including those that already have the rename sem can end up causing writepage
@@ -575,7 +575,7 @@ int cifs_close(struct inode *inode, struct file *file) xid =GetXid (); cifs_sb =CIFS_SB (inode->i_sb); - pTcon = cifs_sb->tcon; + pTcon = pSMBFile->tcon;if (pSMBFile) {struct cifsLockInfo *li, *tmp;write_lock (&GlobalSMBSeslock);
@@ -653,11 +653,7 @@ int cifs_closedir(struct inode *inode, struct file *file) xid =GetXid ();if (pCFileStruct) { -struct cifsTconInfo *pTcon; -struct cifs_sb_info *cifs_sb = -CIFS_SB (file->f_path.dentry->d_sb); - - pTcon = cifs_sb->tcon; +struct cifsTconInfo *pTcon = pCFileStruct->tcon;cFYI (1 ,"Freeing private data in close dir" );write_lock (&GlobalSMBSeslock);
@@ -767,7 +763,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)cFYI (1 ,"Unknown type of lock" ); cifs_sb =CIFS_SB (file->f_path.dentry->d_sb); - tcon = cifs_sb->tcon; + tcon = ((struct cifsFileInfo *)file->private_data)->tcon;if (file->private_data ==NULL ) { rc = -EBADF ;
@@ -960,14 +956,14 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data, cifs_sb =CIFS_SB (file->f_path.dentry->d_sb); - pTcon = cifs_sb->tcon; -/* cFYI(1, " write %d bytes to offset %lld of %s", write_size, *poffset, file->f_path.dentry->d_name.name); */ if (file->private_data ==NULL )return -EBADF ; + open_file = file->private_data; + pTcon = open_file->tcon; rc =generic_write_checks (file, poffset, &write_size,0 );if (rc)
@@ -1062,14 +1058,13 @@ static ssize_t cifs_write(struct file *file, const char *write_data, cifs_sb =CIFS_SB (file->f_path.dentry->d_sb); - pTcon = cifs_sb->tcon; -cFYI (1 ,"write %zd bytes to offset %lld of %s" , write_size, *poffset, file->f_path.dentry->d_name.name);if (file->private_data ==NULL )return -EBADF ; open_file = file->private_data; + pTcon = open_file->tcon; xid =GetXid ();
@@ -1284,7 +1279,6 @@ static int cifs_partialpagewrite(struct page *page, unsigned from, unsigned to)int rc = -EFAULT ;int bytes_written =0 ;struct cifs_sb_info *cifs_sb; -struct cifsTconInfo *pTcon;struct inode *inode;struct cifsFileInfo *open_file;
@@ -1293,7 +1287,6 @@ static int cifs_partialpagewrite(struct page *page, unsigned from, unsigned to) inode = page->mapping->host; cifs_sb =CIFS_SB (inode->i_sb); - pTcon = cifs_sb->tcon; offset += (loff_t )from; write_data =kmap (page);
@@ -1352,6 +1345,7 @@ static int cifs_writepages(struct address_space *mapping,int nr_pages;__u64 offset =0 ;struct cifsFileInfo *open_file; +struct cifsTconInfo *tcon;struct cifsInodeInfo *cifsi =CIFS_I (mapping->host);struct page *page;struct pagevec pvec;
@@ -1501,8 +1495,9 @@ retry:cERROR (1 ,"No writable handles for inode" ); rc = -EBADF ; }else { + tcon = open_file->tcon; long_op =cifs_write_timeout (cifsi, offset); - rc = CIFSSMBWrite2(xid, cifs_sb->tcon, + rc = CIFSSMBWrite2(xid, tcon, open_file->netfid, bytes_to_write, offset, &bytes_written, iov, n_iov,
@@ -1520,8 +1515,7 @@ retry:else set_bit (AS_EIO , &mapping->flags); }else { -cifs_stats_bytes_written (cifs_sb->tcon, - bytes_written); +cifs_stats_bytes_written (tcon, bytes_written); } }for (i =0 ; i < n_iov; i++) {
@@ -1665,7 +1659,7 @@ int cifs_fsync(struct file *file, int datasync)if (rc ==0 ) { rc =CIFS_I (inode)->write_behind_rc;CIFS_I (inode)->write_behind_rc =0 ; - tcon =CIFS_SB (inode->i_sb)->tcon; + tcon = smbfile->tcon;if (!rc && tcon && smbfile && !(CIFS_SB (inode->i_sb)->mnt_cifs_flags &CIFS_MOUNT_NOSSYNC )) rc =CIFSSMBFlush (xid, tcon, smbfile->netfid);
@@ -1750,7 +1744,6 @@ ssize_t cifs_user_read(struct file *file, char __user *read_data, xid =GetXid (); cifs_sb =CIFS_SB (file->f_path.dentry->d_sb); - pTcon = cifs_sb->tcon;if (file->private_data ==NULL ) { rc = -EBADF ;
@@ -1758,6 +1751,7 @@ ssize_t cifs_user_read(struct file *file, char __user *read_data,return rc; } open_file = file->private_data; + pTcon = open_file->tcon;if ((file->f_flags &O_ACCMODE ) ==O_WRONLY )cFYI (1 ,"attempting read on write only file instance" );
@@ -1831,7 +1825,6 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size, xid =GetXid (); cifs_sb =CIFS_SB (file->f_path.dentry->d_sb); - pTcon = cifs_sb->tcon;if (file->private_data ==NULL ) { rc = -EBADF ;
@@ -1839,6 +1832,7 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,return rc; } open_file = file->private_data; + pTcon = open_file->tcon;if ((file->f_flags &O_ACCMODE ) ==O_WRONLY )cFYI (1 ,"attempting read on write only file instance" );
@@ -1974,7 +1968,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping, } open_file = file->private_data; cifs_sb =CIFS_SB (file->f_path.dentry->d_sb); - pTcon = cifs_sb->tcon; + pTcon = open_file->tcon;/* * Reads as many pages as possible from fscache. Returns -ENOBUFS
@@ -2312,7 +2306,6 @@ void cifs_oplock_break(struct work_struct *work) oplock_break);struct inode *inode = cfile->pInode;struct cifsInodeInfo *cinode =CIFS_I (inode); -struct cifs_sb_info *cifs_sb =CIFS_SB (cfile->mnt->mnt_sb);int rc, waitrc =0 ;if (inode &&S_ISREG (inode->i_mode)) {
@@ -2339,7 +2332,7 @@ void cifs_oplock_break(struct work_struct *work)* disconnected since oplock already released by the server */ if (!cfile->closePend && !cfile->oplock_break_cancelled) { - rc =CIFSSMBLock (0 , cifs_sb->tcon, cfile->netfid,0 ,0 ,0 ,0 , + rc =CIFSSMBLock (0 , cfile->tcon, cfile->netfid,0 ,0 ,0 ,0 ,LOCKING_ANDX_OPLOCK_RELEASE , false);cFYI (1 ,"Oplock release rc = %d" , rc); }
fs/cifs/inode.c +16 -6
@@ -288,8 +288,8 @@ int cifs_get_file_info_unix(struct file *filp)struct cifs_fattr fattr;struct inode *inode = filp->f_path.dentry->d_inode;struct cifs_sb_info *cifs_sb =CIFS_SB (inode->i_sb); -struct cifsTconInfo *tcon = cifs_sb->tcon;struct cifsFileInfo *cfile = filp->private_data; +struct cifsTconInfo *tcon = cfile->tcon; xid =GetXid (); rc =CIFSSMBUnixQFileInfo (xid, tcon, cfile->netfid, &find_data);
@@ -516,8 +516,8 @@ int cifs_get_file_info(struct file *filp)struct cifs_fattr fattr;struct inode *inode = filp->f_path.dentry->d_inode;struct cifs_sb_info *cifs_sb =CIFS_SB (inode->i_sb); -struct cifsTconInfo *tcon = cifs_sb->tcon;struct cifsFileInfo *cfile = filp->private_data; +struct cifsTconInfo *tcon = cfile->tcon; xid =GetXid (); rc =CIFSSMBQFileInfo (xid, tcon, cfile->netfid, &find_data);
@@ -883,7 +883,7 @@ cifs_set_file_info(struct inode *inode, struct iattr *attrs, int xid,struct cifsFileInfo *open_file;struct cifsInodeInfo *cifsInode =CIFS_I (inode);struct cifs_sb_info *cifs_sb =CIFS_SB (inode->i_sb); -struct cifsTconInfo *pTcon = cifs_sb->tcon; +struct cifsTconInfo *pTcon;FILE_BASIC_INFO info_buf;if (attrs ==NULL )
@@ -926,9 +926,12 @@ cifs_set_file_info(struct inode *inode, struct iattr *attrs, int xid,if (open_file) { netfid = open_file->netfid; netpid = open_file->pid; + pTcon = open_file->tcon; goto set_via_filehandle; } + pTcon = cifs_sb->tcon; +/* * NT4 apparently returns success on this call, but it doesn't * really work.
@@ -1603,11 +1606,12 @@ int cifs_revalidate_file(struct file *filp) {int rc =0 ;struct inode *inode = filp->f_path.dentry->d_inode; +struct cifsFileInfo *cfile = (struct cifsFileInfo *) filp->private_data;if (!cifs_inode_needs_reval (inode)) goto check_inval; -if (CIFS_SB (inode->i_sb)->tcon->unix_ext) +if (cfile->tcon->unix_ext) rc =cifs_get_file_info_unix (filp);else rc =cifs_get_file_info (filp);
@@ -1712,7 +1716,7 @@ cifs_set_file_size(struct inode *inode, struct iattr *attrs,struct cifsFileInfo *open_file;struct cifsInodeInfo *cifsInode =CIFS_I (inode);struct cifs_sb_info *cifs_sb =CIFS_SB (inode->i_sb); -struct cifsTconInfo *pTcon = cifs_sb->tcon; +struct cifsTconInfo *pTcon =NULL ;/* * To avoid spurious oplock breaks from server, in the case of
@@ -1727,6 +1731,7 @@ cifs_set_file_size(struct inode *inode, struct iattr *attrs,if (open_file) {__u16 nfid = open_file->netfid;__u32 npid = open_file->pid; + pTcon = open_file->tcon; rc =CIFSSMBSetFileSize (xid, pTcon, attrs->ia_size, nfid, npid, false);cifsFileInfo_put (open_file);
@@ -1741,6 +1746,9 @@ cifs_set_file_size(struct inode *inode, struct iattr *attrs, rc = -EINVAL ;if (rc !=0 ) { +if (pTcon ==NULL ) + pTcon = cifs_sb->tcon; +/* Set file size by pathname rather than by handle either because no valid, writeable file handle for it was found or because there was an error setting
@@ -1790,7 +1798,7 @@ cifs_setattr_unix(struct dentry *direntry, struct iattr *attrs)struct inode *inode = direntry->d_inode;struct cifsInodeInfo *cifsInode =CIFS_I (inode);struct cifs_sb_info *cifs_sb =CIFS_SB (inode->i_sb); -struct cifsTconInfo *pTcon = cifs_sb->tcon; +struct cifsTconInfo *pTcon;struct cifs_unix_set_info_args *args =NULL ;struct cifsFileInfo *open_file;
@@ -1881,9 +1889,11 @@ cifs_setattr_unix(struct dentry *direntry, struct iattr *attrs)if (open_file) {u16 nfid = open_file->netfid;u32 npid = open_file->pid; + pTcon = open_file->tcon; rc =CIFSSMBUnixSetFileInfo (xid, pTcon, args, nfid, npid);cifsFileInfo_put (open_file); }else { + pTcon = cifs_sb->tcon; rc = CIFSSMBUnixSetPathInfo(xid, pTcon, full_path, args, cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
fs/cifs/ioctl.c +3 -14
@@ -37,11 +37,11 @@ long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg)int xid;struct cifs_sb_info *cifs_sb;#ifdef CONFIG_CIFS_POSIX +struct cifsFileInfo *pSMBFile = filep->private_data; +struct cifsTconInfo *tcon = pSMBFile->tcon;__u64 ExtAttrBits =0 ;__u64 ExtAttrMask =0 ; -__u64 caps; -struct cifsTconInfo *tcon; -struct cifsFileInfo *pSMBFile = filep->private_data; +__u64 caps =le64_to_cpu (tcon->fsUnixInfo.Capability);#endif /* CONFIG_CIFS_POSIX */ xid =GetXid ();
@@ -50,17 +50,6 @@ long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg) cifs_sb =CIFS_SB (inode->i_sb); -#ifdef CONFIG_CIFS_POSIX - tcon = cifs_sb->tcon; -if (tcon) - caps =le64_to_cpu (tcon->fsUnixInfo.Capability); -else { - rc = -EIO ; -FreeXid (xid); -return -EIO ; - } -#endif /* CONFIG_CIFS_POSIX */ -switch (command) {case CIFS_IOC_CHECKUMOUNT :cFYI (1 ,"User unmount attempted" );
fs/cifs/readdir.c +8 -11
@@ -229,22 +229,21 @@ static int initiate_cifs_search(const int xid, struct file *file)struct cifs_sb_info *cifs_sb;struct cifsTconInfo *pTcon; -if (file->private_data ==NULL ) { + cifs_sb =CIFS_SB (file->f_path.dentry->d_sb); +if (cifs_sb ==NULL ) +return -EINVAL ; + +if (file->private_data ==NULL ) file->private_data =kzalloc (sizeof (struct cifsFileInfo ),GFP_KERNEL ); - }if (file->private_data ==NULL )return -ENOMEM ; cifsFile = file->private_data; cifsFile->invalidHandle = true; cifsFile->srch_inf.endOfSearch = false; - - cifs_sb =CIFS_SB (file->f_path.dentry->d_sb); -if (cifs_sb ==NULL ) -return -EINVAL ; - - pTcon = cifs_sb->tcon; + cifsFile->tcon = cifs_sb->tcon; + pTcon = cifsFile->tcon;if (pTcon ==NULL )return -EINVAL ;
@@ -778,9 +777,6 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir) xid =GetXid (); cifs_sb =CIFS_SB (file->f_path.dentry->d_sb); - pTcon = cifs_sb->tcon; -if (pTcon ==NULL ) -return -EINVAL ;switch ((int ) file->f_pos) {case 0 :
@@ -830,6 +826,7 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)CIFSFindClose(xid, pTcon, cifsFile->netfid); } */ + pTcon = cifsFile->tcon; rc =find_cifs_entry (xid, pTcon, file, ¤t_entry, &num_to_fill);if (rc) {
Signature · 1 line
1.7.2.1
PATCH 5/15 cifs: add function to get a tcon from cifs_sb
In reply to a message not in the archiveWhen 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.
--- fs/cifs/cifs_dfs_ref.c | 2 +- fs/cifs/cifsacl.c | 16 +++++++------- fs/cifs/cifsfs.c | 11 ++------- fs/cifs/cifsglob.h | 6 +++++ fs/cifs/connect.c | 4 +- fs/cifs/dir.c | 20 +++++++++--------- fs/cifs/file.c | 4 +- fs/cifs/fscache.c | 7 +++-- fs/cifs/inode.c | 49 ++++++++++++++++++++++++----------------------- fs/cifs/link.c | 6 ++-- fs/cifs/misc.c | 2 +- fs/cifs/readdir.c | 8 +++--- fs/cifs/xattr.c | 8 +++--- 13 files changed, 73 insertions(+), 70 deletions(-)
fs/cifs/cifs_dfs_ref.c +1 -1
@@ -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 ;
fs/cifs/cifsacl.c +8 -8
@@ -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);
@@ -577,7 +577,7 @@ 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) {
@@ -585,10 +585,10 @@ static struct cifs_ntsd *get_cifs_acl_by_path(struct cifs_sb_info *cifs_sb, 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;
@@ -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);
@@ -634,7 +634,7 @@ 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) {
@@ -642,10 +642,10 @@ static int set_cifs_acl_by_path(struct cifs_sb_info *cifs_sb, const char *path, 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;
fs/cifs/cifsfs.c +3 -8
@@ -136,9 +136,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 );
@@ -224,7 +221,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;
@@ -368,7 +365,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);seq_printf (s,",unc=%s" , tcon->treeName);if (tcon->ses->userName)
@@ -439,9 +436,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)) {
fs/cifs/cifsglob.h +6 -0
@@ -411,6 +411,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 )
fs/cifs/connect.c +2 -2
@@ -2954,8 +2954,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;
fs/cifs/dir.c +10 -10
@@ -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:
@@ -117,7 +117,7 @@ cifs_bp_rename_retry:/* 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++) {
@@ -153,7 +153,7 @@ 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);
@@ -161,7 +161,7 @@ cifs_new_fileinfo(struct inode *newinode, __u16 fileHandle,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*/
@@ -228,7 +228,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 );
@@ -301,7 +301,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 ) {
@@ -376,7 +376,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,
@@ -507,7 +507,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 ) {
@@ -634,7 +634,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.
fs/cifs/file.c +2 -2
@@ -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);
@@ -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
fs/cifs/fscache.c +4 -3
@@ -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)
@@ -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",
fs/cifs/inode.c +25 -24
177 lines not on this page · raw message
fs/cifs/link.c +3 -3
@@ -44,7 +44,7 @@ cifs_hardlink(struct dentry *old_file, struct inode *inode, xid =GetXid (); cifs_sb_target =CIFS_SB (inode->i_sb); - pTcon = cifs_sb_target->tcon; + pTcon =cifs_sb_tcon (cifs_sb_target);/* No need to check for cross device links since server will do that BB note DFS case in future though (when we may have to check) */
@@ -113,7 +113,7 @@ cifs_follow_link(struct dentry *direntry, struct nameidata *nd)char *full_path =NULL ;char *target_path =NULL ;struct cifs_sb_info *cifs_sb =CIFS_SB (inode->i_sb); -struct cifsTconInfo *tcon = cifs_sb->tcon; +struct cifsTconInfo *tcon =cifs_sb_tcon (cifs_sb); xid =GetXid ();
@@ -168,7 +168,7 @@ cifs_symlink(struct inode *inode, struct dentry *direntry, const char *symname) 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);
fs/cifs/misc.c +1 -1
@@ -729,6 +729,6 @@ cifs_autodisable_serverino(struct cifs_sb_info *cifs_sb)"properly. Hardlinks will not be recognized on this " "mount. Consider mounting with the \"noserverino\" " "option to silence this message." , - cifs_sb->tcon->treeName); + cifs_sb_tcon(cifs_sb)->treeName); } }
fs/cifs/readdir.c +4 -4
@@ -102,7 +102,7 @@ cifs_readdir_lookup(struct dentry *parent, struct qstr *name,return NULL ; } -if (CIFS_SB (sb)->tcon->nocase) +if (cifs_sb_tcon (CIFS_SB (sb))->nocase) dentry->d_op = &cifs_ci_dentry_ops;else dentry->d_op = &cifs_dentry_ops;
@@ -172,7 +172,7 @@ static void cifs_std_info_to_fattr(struct cifs_fattr *fattr, FIND_FILE_STANDARD_INFO *info, struct cifs_sb_info *cifs_sb) { - int offset = cifs_sb->tcon->ses->server->timeAdj; + int offset = cifs_sb_tcon(cifs_sb)->ses->server->timeAdj;memset (fattr,0 ,sizeof (*fattr)); fattr->cf_atime = cnvrtDosUnixTm(info->LastAccessDate,
@@ -200,7 +200,7 @@ int get_symlink_reparse_path(char *full_path, struct cifs_sb_info *cifs_sb,int len;int oplock =0 ;int rc; -struct cifsTconInfo *ptcon = cifs_sb->tcon; +struct cifsTconInfo *ptcon =cifs_sb_tcon (cifs_sb);char *tmpbuffer; rc = CIFSSMBOpen(xid, ptcon, full_path, FILE_OPEN, GENERIC_READ,
@@ -242,7 +242,7 @@ static int initiate_cifs_search(const int xid, struct file *file) cifsFile = file->private_data; cifsFile->invalidHandle = true; cifsFile->srch_inf.endOfSearch = false; - cifsFile->tcon = cifs_sb->tcon; + cifsFile->tcon =cifs_sb_tcon (cifs_sb); pTcon = cifsFile->tcon;if (pTcon ==NULL )return -EINVAL ;
fs/cifs/xattr.c +4 -4
@@ -61,7 +61,7 @@ int cifs_removexattr(struct dentry *direntry, const char *ea_name) xid =GetXid (); cifs_sb =CIFS_SB (sb); - pTcon = cifs_sb->tcon; + pTcon =cifs_sb_tcon (cifs_sb); full_path =build_path_from_dentry (direntry);if (full_path ==NULL ) {
@@ -116,7 +116,7 @@ int cifs_setxattr(struct dentry *direntry, const char *ea_name, xid =GetXid (); cifs_sb =CIFS_SB (sb); - pTcon = cifs_sb->tcon; + pTcon =cifs_sb_tcon (cifs_sb); full_path =build_path_from_dentry (direntry);if (full_path ==NULL ) {
@@ -224,7 +224,7 @@ ssize_t cifs_getxattr(struct dentry *direntry, const char *ea_name, xid =GetXid (); cifs_sb =CIFS_SB (sb); - pTcon = cifs_sb->tcon; + pTcon =cifs_sb_tcon (cifs_sb); full_path =build_path_from_dentry (direntry);if (full_path ==NULL ) {
@@ -346,7 +346,7 @@ ssize_t cifs_listxattr(struct dentry *direntry, char *data, size_t buf_size)return -EIO ; cifs_sb =CIFS_SB (sb); - pTcon = cifs_sb->tcon; + pTcon =cifs_sb_tcon (cifs_sb);if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_NO_XATTR )return -EOPNOTSUPP ;
Signature · 1 line
1.7.2.1
PATCH 7/15 cifs: add cifs_sb_master_tcon and convert some callers to use it
In reply to a message not in the archiveAt 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.
--- fs/cifs/cifsfs.c | 6 +++--- fs/cifs/cifsglob.h | 7 +++++++ fs/cifs/connect.c | 4 ++-- fs/cifs/dir.c | 10 +++++----- fs/cifs/fscache.c | 12 ++++++------ fs/cifs/inode.c | 29 ++++++++++++++++------------- fs/cifs/misc.c | 2 +- fs/cifs/readdir.c | 4 ++-- 8 files changed, 42 insertions(+), 32 deletions(-)
fs/cifs/cifsfs.c +3 -3
@@ -221,7 +221,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;
@@ -365,7 +365,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);seq_printf (s,",unc=%s" , tcon->treeName);if (tcon->ses->userName)
@@ -436,7 +436,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)) {
fs/cifs/cifsglob.h +7 -0
@@ -417,6 +417,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 )
fs/cifs/connect.c +2 -2
@@ -2953,9 +2953,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;
fs/cifs/dir.c +5 -5
@@ -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 @@ cifs_bp_rename_retry:/* 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++) {
fs/cifs/fscache.c +6 -6
@@ -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",
fs/cifs/inode.c +16 -13
@@ -52,7 +52,7 @@ static void cifs_set_ops(struct inode *inode, const bool is_dfs_referral)/* check if server can support readpages */ -if (cifs_sb_tcon (cifs_sb)->ses->server->maxBuf < +if (cifs_sb_master_tcon (cifs_sb)->ses->server->maxBuf <PAGE_CACHE_SIZE +MAX_CIFS_HDR_SIZE ) inode->i_data.a_ops = &cifs_addr_ops_smallbuf;else
@@ -469,6 +469,8 @@ static void cifs_all_info_to_fattr(struct cifs_fattr *fattr, FILE_ALL_INFO *info, struct cifs_sb_info *cifs_sb, bool adjust_tz) { + struct cifsTconInfo *tcon = cifs_sb_master_tcon(cifs_sb); +memset (fattr,0 ,sizeof (*fattr)); fattr->cf_cifsattrs =le32_to_cpu (info->Attributes);if (info->DeletePending)
@@ -483,8 +485,8 @@ cifs_all_info_to_fattr(struct cifs_fattr *fattr, FILE_ALL_INFO *info, fattr->cf_mtime =cifs_NTtimeToUnix (info->LastWriteTime);if (adjust_tz) { - fattr->cf_ctime.tv_sec +=cifs_sb_tcon (cifs_sb)->ses->server->timeAdj; - fattr->cf_mtime.tv_sec +=cifs_sb_tcon (cifs_sb)->ses->server->timeAdj; + fattr->cf_ctime.tv_sec += tcon->ses->server->timeAdj; + fattr->cf_mtime.tv_sec += tcon->ses->server->timeAdj; } fattr->cf_eof =le64_to_cpu (info->EndOfFile);
@@ -685,6 +687,7 @@ char *cifs_build_path_to_root(struct cifs_sb_info *cifs_sb)int pplen = cifs_sb->prepathlen;int dfsplen;char *full_path =NULL ; +struct cifsTconInfo *tcon =cifs_sb_master_tcon (cifs_sb);/* if no prefix path, simply set path to the root of share to "" */ if (pplen ==0 ) {
@@ -694,8 +697,8 @@ char *cifs_build_path_to_root(struct cifs_sb_info *cifs_sb)return full_path; } -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 ;
@@ -704,7 +707,7 @@ char *cifs_build_path_to_root(struct cifs_sb_info *cifs_sb)return full_path;if (dfsplen) { -strncpy (full_path,cifs_sb_tcon (cifs_sb)->treeName, dfsplen); +strncpy (full_path, tcon->treeName, dfsplen);/* switch slash direction in prepath depending on whether * windows or posix style path names */
@@ -823,18 +826,18 @@ retry_iget5_locked:struct inode *cifs_root_iget (struct super_block *sb,unsigned long ino) {int xid; -struct cifs_sb_info *cifs_sb; +struct cifs_sb_info *cifs_sb =CIFS_SB (sb);struct inode *inode =NULL ;long rc;char *full_path; +struct cifsTconInfo *tcon =cifs_sb_master_tcon (cifs_sb); - cifs_sb =CIFS_SB (sb); full_path =cifs_build_path_to_root (cifs_sb);if (full_path ==NULL )return ERR_PTR (-ENOMEM ); xid =GetXid (); -if (cifs_sb_tcon (cifs_sb)->unix_ext) +if (tcon->unix_ext) rc =cifs_get_inode_info_unix (&inode, full_path, sb, xid);else rc = cifs_get_inode_info(&inode, full_path, NULL, sb,
@@ -845,10 +848,10 @@ struct inode *cifs_root_iget(struct super_block *sb, unsigned long ino)#ifdef CONFIG_CIFS_FSCACHE /* populate tcon->resource_id */ -cifs_sb_tcon (cifs_sb)->resource_id =CIFS_I (inode)->uniqueid; + tcon->resource_id =CIFS_I (inode)->uniqueid;#endif -if (rc &&cifs_sb_tcon (cifs_sb)->ipc) { +if (rc && tcon->ipc) {cFYI (1 ,"ipc connection - fake read inode" ); inode->i_mode |=S_IFDIR ; inode->i_nlink =2 ;
@@ -1653,7 +1656,7 @@ int cifs_revalidate_dentry(struct dentry *dentry)"jiffies %ld" , full_path, inode, inode->i_count.counter, dentry, dentry->d_time, jiffies); -if (cifs_sb_tcon (CIFS_SB (sb))->unix_ext) +if (cifs_sb_master_tcon (CIFS_SB (sb))->unix_ext) rc =cifs_get_inode_info_unix (&inode, full_path, sb, xid);else rc = cifs_get_inode_info(&inode, full_path, NULL, sb,
@@ -2079,7 +2082,7 @@ cifs_setattr(struct dentry *direntry, struct iattr *attrs) {struct inode *inode = direntry->d_inode;struct cifs_sb_info *cifs_sb =CIFS_SB (inode->i_sb); -struct cifsTconInfo *pTcon =cifs_sb_tcon (cifs_sb); +struct cifsTconInfo *pTcon =cifs_sb_master_tcon (cifs_sb);if (pTcon->unix_ext)return cifs_setattr_unix (direntry, attrs);
fs/cifs/misc.c +1 -1
@@ -729,6 +729,6 @@ cifs_autodisable_serverino(struct cifs_sb_info *cifs_sb)"properly. Hardlinks will not be recognized on this " "mount. Consider mounting with the \"noserverino\" " "option to silence this message." , - cifs_sb_tcon(cifs_sb)->treeName); + cifs_sb_master_tcon(cifs_sb)->treeName); } }
fs/cifs/readdir.c +2 -2
@@ -102,7 +102,7 @@ cifs_readdir_lookup(struct dentry *parent, struct qstr *name,return NULL ; } -if (cifs_sb_tcon (CIFS_SB (sb))->nocase) +if (cifs_sb_master_tcon (CIFS_SB (sb))->nocase) dentry->d_op = &cifs_ci_dentry_ops;else dentry->d_op = &cifs_dentry_ops;
@@ -172,7 +172,7 @@ static void cifs_std_info_to_fattr(struct cifs_fattr *fattr, FIND_FILE_STANDARD_INFO *info, struct cifs_sb_info *cifs_sb) { - int offset = cifs_sb_tcon(cifs_sb)->ses->server->timeAdj; + int offset = cifs_sb_master_tcon(cifs_sb)->ses->server->timeAdj;memset (fattr,0 ,sizeof (*fattr)); fattr->cf_atime = cnvrtDosUnixTm(info->LastAccessDate,
Signature · 1 line
1.7.2.1
PATCH 9/15 cifs: add refcounted and timestamped container for holding tcons
In reply to a message not in the archiveEventually, we'll need to track the use of tcons on a per-sb basis, so that we know when it's ok to tear them down. Begin this conversion by adding a new "tcon_link" struct and accessors that get it. For now, the core data structures are untouched -- cifs_sb still just points to a single tcon and the pointers are just cast to deal with the accessor functions. A later patch will flesh this out.
--- fs/cifs/cifs_dfs_ref.c | 21 ++++--- fs/cifs/cifsacl.c | 42 ++++++++++--- fs/cifs/cifsglob.h | 29 ++++++++- fs/cifs/dir.c | 65 +++++++++++++++----- fs/cifs/file.c | 9 +++- fs/cifs/inode.c | 157 +++++++++++++++++++++++++++++++++++++----------- fs/cifs/link.c | 54 +++++++++++------ fs/cifs/readdir.c | 34 ++++++----- fs/cifs/xattr.c | 60 ++++++++++++------- 9 files changed, 343 insertions(+), 128 deletions(-)
fs/cifs/cifs_dfs_ref.c +12 -9
@@ -306,6 +306,7 @@ cifs_dfs_follow_mountpoint(struct dentry *dentry, struct nameidata *nd)int xid, i;int rc =0 ;struct vfsmount *mnt =ERR_PTR (-ENOENT ); +struct tcon_link *tlink;cFYI (1 ,"in %s" , __func__);BUG_ON (IS_ROOT (dentry));
@@ -315,14 +316,6 @@ cifs_dfs_follow_mountpoint(struct dentry *dentry, struct nameidata *nd)dput (nd->path.dentry); nd->path.dentry =dget (dentry); - cifs_sb =CIFS_SB (dentry->d_inode->i_sb); - ses =cifs_sb_tcon (cifs_sb)->ses; - -if (!ses) { - rc = -EINVAL ; - goto out_err; - } -/* * The MSDFS spec states that paths in DFS referral requests and * responses must be prefixed by a single '\' character instead of
@@ -335,10 +328,20 @@ cifs_dfs_follow_mountpoint(struct dentry *dentry, struct nameidata *nd) goto out_err; } - rc =get_dfs_path (xid, ses , full_path +1 , cifs_sb->local_nls, + cifs_sb =CIFS_SB (dentry->d_inode->i_sb); + tlink =cifs_sb_tlink (cifs_sb); +if (IS_ERR (tlink)) { + rc =PTR_ERR (tlink); + goto out_err; + } + ses =tlink_tcon (tlink)->ses; + + rc =get_dfs_path (xid, ses, full_path +1 , cifs_sb->local_nls, &num_referrals, &referrals, cifs_sb->mnt_cifs_flags &CIFS_MOUNT_MAP_SPECIAL_CHR ); +cifs_put_tlink (tlink); +for (i =0 ; i < num_referrals; i++) {int len;dump_referral (referrals+i);
fs/cifs/cifsacl.c +33 -9
97 lines not on this page · raw message
fs/cifs/cifsglob.h +27 -2
@@ -308,6 +308,19 @@ struct cifsTconInfo { };/* +* This is a refcounted and timestamped container for a tcon pointer. The +* container holds a tcon reference. It is considered safe to free one of +* these when the tl_count goes to 0. The tl_time is the time of the last +* "get" on the container. +*/ +struct tcon_link { +spinlock_t tl_lock; +u32 tl_count; +u64 tl_time; +struct cifsTconInfo *tl_tcon; +}; + +/* * This info hangs off the cifsFileInfo structure, pointed to by llist. * This is used to track byte stream locks on the file */
@@ -411,10 +424,22 @@ CIFS_SB(struct super_block *sb)return sb->s_fs_info; } +static inline struct tcon_link * +cifs_sb_tlink (struct cifs_sb_info *cifs_sb) +{ +return (struct tcon_link *)cifs_sb->ptcon; +} +static inline struct cifsTconInfo * -cifs_sb_tcon (struct cifs_sb_info *cifs_sb) +tlink_tcon (struct tcon_link *tlink) { -return cifs_sb->ptcon; +return (struct cifsTconInfo *)tlink; +} + +static inline void +cifs_put_tlink (struct tcon_link *tlink) +{ +return ; }/* This function is always expected to succeed */
fs/cifs/dir.c +48 -17
167 lines not on this page · raw message
fs/cifs/file.c +8 -1
@@ -224,6 +224,7 @@ int cifs_open(struct inode *inode, struct file *file)__u32 oplock;struct cifs_sb_info *cifs_sb;struct cifsTconInfo *tcon; +struct tcon_link *tlink;struct cifsFileInfo *pCifsFile =NULL ;struct cifsInodeInfo *pCifsInode;char *full_path =NULL ;
@@ -235,7 +236,12 @@ int cifs_open(struct inode *inode, struct file *file) xid =GetXid (); cifs_sb =CIFS_SB (inode->i_sb); - tcon =cifs_sb_tcon (cifs_sb); + tlink =cifs_sb_tlink (cifs_sb); +if (IS_ERR (tlink)) { +FreeXid (xid); +return PTR_ERR (tlink); + } + tcon =tlink_tcon (tlink); pCifsInode =CIFS_I (file->f_path.dentry->d_inode);
@@ -402,6 +408,7 @@ out:kfree (buf);kfree (full_path);FreeXid (xid); +cifs_put_tlink (tlink);return rc; }
fs/cifs/inode.c +122 -35
417 lines not on this page · raw message
fs/cifs/link.c +35 -19
117 lines not on this page · raw message
fs/cifs/readdir.c +19 -15
@@ -224,33 +224,35 @@ int get_symlink_reparse_path(char *full_path, struct cifs_sb_info *cifs_sb,static int initiate_cifs_search (const int xid,struct file *file) {int rc =0 ; -char *full_path; +char *full_path =NULL ;struct cifsFileInfo *cifsFile; -struct cifs_sb_info *cifs_sb; +struct cifs_sb_info *cifs_sb =CIFS_SB (file->f_path.dentry->d_sb); +struct tcon_link *tlink;struct cifsTconInfo *pTcon; - cifs_sb =CIFS_SB (file->f_path.dentry->d_sb); -if (cifs_sb ==NULL ) -return -EINVAL ; - + tlink =cifs_sb_tlink (cifs_sb); +if (IS_ERR (tlink)) +return PTR_ERR (tlink); + pTcon =tlink_tcon (tlink); +if (file->private_data ==NULL ) file->private_data =kzalloc (sizeof (struct cifsFileInfo ),GFP_KERNEL ); +if (file->private_data ==NULL ) { + rc = -ENOMEM ; + goto error_exit; + } -if (file->private_data ==NULL ) -return -ENOMEM ; cifsFile = file->private_data; cifsFile->invalidHandle = true; cifsFile->srch_inf.endOfSearch = false; - cifsFile->tcon =cifs_sb_tcon (cifs_sb); - pTcon = cifsFile->tcon; -if (pTcon ==NULL ) -return -EINVAL ; + cifsFile->tcon = pTcon; full_path =build_path_from_dentry (file->f_path.dentry); - -if (full_path ==NULL ) -return -ENOMEM ; +if (full_path ==NULL ) { + rc = -ENOMEM ; + goto error_exit; + }cFYI (1 ,"Full path: %s start at: %lld" , full_path, file->f_pos);
@@ -283,7 +285,9 @@ ffirst_retry: cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_SERVER_INUM ; goto ffirst_retry; } +error_exit:kfree (full_path); +cifs_put_tlink (tlink);return rc; }
fs/cifs/xattr.c +39 -21
167 lines not on this page · raw message
Signature · 1 line
1.7.2.1
PATCH 14/15 cifs: on multiuser mount, set ownership to current_fsuid/current_fsgid
In reply to a message not in the archive...when unix extensions aren't enabled. This makes everything on the mount appear to be owned by the current user.
--- fs/cifs/inode.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)
fs/cifs/inode.c +8 -0
@@ -1747,11 +1747,19 @@ check_inval:int cifs_getattr (struct vfsmount *mnt,struct dentry *dentry,struct kstat *stat) { +struct cifs_sb_info *cifs_sb =CIFS_SB (dentry->d_sb); +struct cifsTconInfo *tcon =cifs_sb_master_tcon (cifs_sb);int err =cifs_revalidate_dentry (dentry); +if (!err) {generic_fillattr (dentry->d_inode, stat); stat->blksize =CIFS_MAX_MSGSIZE ; stat->ino =CIFS_I (dentry->d_inode)->uniqueid; +if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_MULTIUSER && + !tcon->unix_ext) { + stat->uid =current_fsuid (); + stat->gid =current_fsgid (); + } }return err; }
Signature · 1 line
1.7.2.1
PATCH 4/15 cifs: fix handling of signing with writepages
In reply to Jeff LaytonGet a reference to the file early so we can eventually base the decision about signing on the correct tcon. If that doesn't work for some reason, then fall back to generic_writepages. That's just as likely to fail, but it simplifies the error handling.
In truth, I'm not sure how that could occur anyway, so maybe a NULL open_file here ought to be a BUG()?
--- fs/cifs/file.c | 82 +++++++++++++++++++++++++++---------------------------- 1 files changed, 40 insertions(+), 42 deletions(-)
fs/cifs/file.c +40 -42
@@ -1353,6 +1353,15 @@ static int cifs_writepages(struct address_space *mapping,int scanned =0 ;int xid, long_op; +/* +* BB: Is this meaningful for a non-block-device file system? +* If it is, we should test it again after we do I/O +*/ +if (wbc->nonblocking &&bdi_write_congested (bdi)) { + wbc->encountered_congestion =1 ; +return 0 ; + } + cifs_sb =CIFS_SB (mapping->host->i_sb);/*
@@ -1362,25 +1371,26 @@ static int cifs_writepages(struct address_space *mapping,if (cifs_sb->wsize <PAGE_CACHE_SIZE )return generic_writepages (mapping, wbc); -if ((cifs_sb->tcon->ses) && (cifs_sb->tcon->ses->server)) -if (cifs_sb->tcon->ses->server->secMode & - (SECMODE_SIGN_REQUIRED |SECMODE_SIGN_ENABLED )) -if (!experimEnabled) -return generic_writepages (mapping, wbc); - iov =kmalloc (32 *sizeof (struct kvec ),GFP_KERNEL );if (iov ==NULL )return generic_writepages (mapping, wbc); -/* -* BB: Is this meaningful for a non-block-device file system? -* If it is, we should test it again after we do I/O +* if there's no open file, then this is likely to fail too, +* but it'll at least handle the return. Maybe it should be +* a BUG() instead? */ -if (wbc->nonblocking &&bdi_write_congested (bdi)) { - wbc->encountered_congestion =1 ; + open_file =find_writable_file (CIFS_I (mapping->host)); +if (!open_file) {kfree (iov); -return 0 ; +return generic_writepages (mapping, wbc); + } + + tcon = open_file->tcon; +if (!experimEnabled && tcon->ses->server->secMode & + (SECMODE_SIGN_REQUIRED |SECMODE_SIGN_ENABLED )) { +cifsFileInfo_put (open_file); +return generic_writepages (mapping, wbc); } xid =GetXid ();
@@ -1486,37 +1496,24 @@ retry:break ; }if (n_iov) { -/* Search for a writable handle every time we call -* CIFSSMBWrite2. We can't rely on the last handle -* we used to still be valid -*/ - open_file =find_writable_file (CIFS_I (mapping->host)); -if (!open_file) { -cERROR (1 ,"No writable handles for inode" ); - rc = -EBADF ; + long_op =cifs_write_timeout (cifsi, offset); + rc =CIFSSMBWrite2 (xid, tcon, open_file->netfid, + bytes_to_write, offset, + &bytes_written, iov, n_iov, + long_op); +cifs_update_eof (cifsi, offset, bytes_written); + +if (rc || bytes_written < bytes_to_write) { +cERROR (1 ,"Write2 ret %d, wrote %d" , + rc, bytes_written); +/* BB what if continued retry is +requested via mount flags? */ +if (rc == -ENOSPC ) +set_bit (AS_ENOSPC , &mapping->flags); +else +set_bit (AS_EIO , &mapping->flags); }else { - tcon = open_file->tcon; - long_op =cifs_write_timeout (cifsi, offset); - rc =CIFSSMBWrite2 (xid, tcon, - open_file->netfid, - bytes_to_write, offset, - &bytes_written, iov, n_iov, - long_op); -cifsFileInfo_put (open_file); -cifs_update_eof (cifsi, offset, bytes_written); - -if (rc || bytes_written < bytes_to_write) { -cERROR (1 ,"Write2 ret %d, wrote %d" , - rc, bytes_written); -/* BB what if continued retry is -requested via mount flags? */ -if (rc == -ENOSPC ) -set_bit (AS_ENOSPC , &mapping->flags); -else -set_bit (AS_EIO , &mapping->flags); - }else { -cifs_stats_bytes_written (tcon, bytes_written); - } +cifs_stats_bytes_written (tcon, bytes_written); }for (i =0 ; i < n_iov; i++) { page = pvec.pages[first + i];
@@ -1553,6 +1550,7 @@ retry:if (wbc->range_cyclic || (range_whole && wbc->nr_to_write >0 )) mapping->writeback_index = index; +cifsFileInfo_put (open_file);FreeXid (xid);kfree (iov);return rc;
Signature · 1 line
1.7.2.1
PATCH 6/15 cifs: temporarily rename cifs_sb->tcon to ptcon to catch stragglers
In reply to Jeff Layton--- fs/cifs/cifs_fs_sb.h | 2 +- fs/cifs/cifsglob.h | 2 +- fs/cifs/connect.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-)
fs/cifs/cifs_fs_sb.h +1 -1
@@ -38,7 +38,7 @@#define CIFS_MOUNT_FSCACHE 0x8000/* local caching enabled */ struct cifs_sb_info { -struct cifsTconInfo *tcon;/* primary mount */ +struct cifsTconInfo *ptcon;/* primary mount */ struct list_head nested_tcon_q;struct nls_table *local_nls;unsigned int rsize;
fs/cifs/cifsglob.h +1 -1
@@ -414,7 +414,7 @@ CIFS_SB(struct super_block *sb)static inline struct cifsTconInfo *cifs_sb_tcon (struct cifs_sb_info *cifs_sb) { -return cifs_sb->tcon; +return cifs_sb->ptcon; }static inline char CIFS_DIR_SEP (const struct cifs_sb_info *cifs_sb)
fs/cifs/connect.c +2 -2
@@ -2655,7 +2655,7 @@ try_mount_again: goto remote_path_check; } - cifs_sb->tcon = tcon; + cifs_sb->ptcon = tcon;/* do not care if following two calls succeed - informational */ if (!tcon->ipc) {
@@ -2957,7 +2957,7 @@ cifs_umount(struct super_block *sb, struct cifs_sb_info *cifs_sb)if (cifs_sb_tcon (cifs_sb))cifs_put_tcon (cifs_sb_tcon (cifs_sb)); - cifs_sb->tcon =NULL ; + cifs_sb->ptcon =NULL ; tmp = cifs_sb->prepath; cifs_sb->prepathlen =0 ; cifs_sb->prepath =NULL ;
Signature · 1 line
1.7.2.1
PATCH 8/15 cifs: have cifs_new_fileinfo take a tcon arg
In reply to Jeff LaytonTo minimize calls to cifs_sb_tcon and to allow for a clear error path if a tcon can't be acquired.
--- fs/cifs/cifsproto.h | 3 ++- fs/cifs/dir.c | 20 +++++++++++--------- fs/cifs/file.c | 4 ++-- 3 files changed, 15 insertions(+), 12 deletions(-)
fs/cifs/cifsproto.h +2 -1
@@ -106,7 +106,8 @@ extern struct timespec cnvrtDosUnixTm(__le16 le_date, __le16 le_time,extern struct cifsFileInfo *cifs_new_fileinfo (struct inode *newinode,__u16 fileHandle,struct file *file, -struct vfsmount *mnt,unsigned int oflags); +struct vfsmount *mnt,struct cifsTconInfo *tcon, +unsigned int oflags); extern int cifs_posix_open(char *full_path, struct inode **pinode, struct super_block *sb, int mode, int oflags,
fs/cifs/dir.c +11 -9
@@ -131,8 +131,9 @@ cifs_bp_rename_retry: }struct cifsFileInfo * -cifs_new_fileinfo (struct inode *newinode,__u16 fileHandle, -struct file *file,struct vfsmount *mnt,unsigned int oflags) +cifs_new_fileinfo (struct inode *newinode,__u16 fileHandle,struct file *file, +struct vfsmount *mnt,struct cifsTconInfo *tcon, +unsigned int oflags) {int oplock =0 ;struct cifsFileInfo *pCifsFile;
@@ -153,7 +154,7 @@ cifs_new_fileinfo(struct inode *newinode, __u16 fileHandle, pCifsFile->pfile = file; pCifsFile->invalidHandle = false; pCifsFile->closePend = false; - pCifsFile->tcon =cifs_sb_tcon (cifs_sb); + pCifsFile->tcon = tcon;mutex_init (&pCifsFile->fh_mutex);mutex_init (&pCifsFile->lock_mutex);INIT_LIST_HEAD (&pCifsFile->llist);
@@ -161,7 +162,7 @@ cifs_new_fileinfo(struct inode *newinode, __u16 fileHandle,INIT_WORK (&pCifsFile->oplock_break, cifs_oplock_break);write_lock (&GlobalSMBSeslock); -list_add (&pCifsFile->tlist, &cifs_sb_tcon (cifs_sb)->openFileList); +list_add (&pCifsFile->tlist, &tcon->openFileList); pCifsInode =CIFS_I (newinode);if (pCifsInode) {/* if readable file instance put first in list*/
@@ -194,6 +195,7 @@ int cifs_posix_open(char *full_path, struct inode **pinode,__u32 posix_flags =0 ;struct cifs_sb_info *cifs_sb =CIFS_SB (sb);struct cifs_fattr fattr; +struct cifsTconInfo *tcon =cifs_sb_tcon (cifs_sb);cFYI (1 ,"posix open %s" , full_path);
@@ -228,9 +230,9 @@ int cifs_posix_open(char *full_path, struct inode **pinode, posix_flags |=SMB_O_DIRECT ; mode &= ~current_umask (); - 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 & + rc =CIFSPOSIXCreate (xid, tcon, posix_flags, mode, pnetfid, presp_data, + poplock, full_path, cifs_sb->local_nls, + cifs_sb->mnt_cifs_flags &CIFS_MOUNT_MAP_SPECIAL_CHR );if (rc) goto posix_open_ret;
@@ -469,7 +471,7 @@ cifs_create_set_dentry: } pfile_info =cifs_new_fileinfo (newinode, fileHandle, filp, - nd->path.mnt, oflags); + nd->path.mnt, tcon, oflags);if (pfile_info ==NULL ) {fput (filp);CIFSSMBClose (xid, tcon, fileHandle);
@@ -729,7 +731,7 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry, } cfile =cifs_new_fileinfo (newInode, fileHandle, filp, - nd->path.mnt, + nd->path.mnt, pTcon, nd->intent.open.flags);if (cfile ==NULL ) {fput (filp);
fs/cifs/file.c +2 -2
@@ -277,7 +277,7 @@ int cifs_open(struct inode *inode, struct file *file) pCifsFile =cifs_new_fileinfo (inode, netfid, file, file->f_path.mnt, - oflags); + tcon, oflags);if (pCifsFile ==NULL ) {CIFSSMBClose (xid, tcon, netfid); rc = -ENOMEM ;
@@ -370,7 +370,7 @@ int cifs_open(struct inode *inode, struct file *file) goto out; pCifsFile =cifs_new_fileinfo (inode, netfid, file, file->f_path.mnt, - file->f_flags); + tcon, file->f_flags);if (pCifsFile ==NULL ) { rc = -ENOMEM ; goto out;
Signature · 1 line
1.7.2.1
PATCH 10/15 cifs: have cifsFileInfo hold a reference to a tlink rather than tcon pointer
In reply to Jeff LaytoncifsFileInfo needs a pointer to a tcon, but it doesn't currently hold a reference to it. Change it to keep a pointer to a tcon_link instead and hold a reference to it.
That will keep the tcon from being freed until the file is closed.
--- fs/cifs/cifsfs.c | 3 ++- fs/cifs/cifsglob.h | 45 ++++++++++++++++++++++++++------------------- fs/cifs/cifsproto.h | 2 +- fs/cifs/dir.c | 10 +++++----- fs/cifs/file.c | 31 ++++++++++++++++--------------- fs/cifs/inode.c | 12 ++++++------ fs/cifs/ioctl.c | 2 +- fs/cifs/link.c | 1 - fs/cifs/readdir.c | 4 ++-- 9 files changed, 59 insertions(+), 51 deletions(-)
fs/cifs/cifsfs.c +2 -1
@@ -576,7 +576,8 @@ static int cifs_setlease(struct file *file, long arg, struct file_lock **lease) ((arg == F_WRLCK) && (CIFS_I(inode)->clientCanCacheAll)))return generic_setlease (file, arg, lease); - else if (cfile->tcon->local_lease && !CIFS_I(inode)->clientCanCacheRead) + else if (tlink_tcon(cfile->tlink)->local_lease && + !CIFS_I(inode)->clientCanCacheRead)/* If the server claims to support oplock on this file, then we still need to check oplock even if the local_lease mount option is set, but there
fs/cifs/cifsglob.h +26 -19
69 lines not on this page · raw message
fs/cifs/cifsproto.h +1 -1
@@ -106,7 +106,7 @@ extern struct timespec cnvrtDosUnixTm(__le16 le_date, __le16 le_time,extern struct cifsFileInfo *cifs_new_fileinfo (struct inode *newinode,__u16 fileHandle,struct file *file, -struct vfsmount *mnt,struct cifsTconInfo *tcon, +struct vfsmount *mnt,struct tcon_link *tlink,unsigned int oflags); extern int cifs_posix_open(char *full_path, struct inode **pinode, struct super_block *sb,
fs/cifs/dir.c +5 -5
@@ -132,7 +132,7 @@ cifs_bp_rename_retry:struct cifsFileInfo *cifs_new_fileinfo (struct inode *newinode,__u16 fileHandle,struct file *file, -struct vfsmount *mnt,struct cifsTconInfo *tcon, +struct vfsmount *mnt,struct tcon_link *tlink,unsigned int oflags) {int oplock =0 ;
@@ -153,7 +153,7 @@ cifs_new_fileinfo(struct inode *newinode, __u16 fileHandle, struct file *file, pCifsFile->pfile = file; pCifsFile->invalidHandle = false; pCifsFile->closePend = false; - pCifsFile->tcon = tcon; + pCifsFile->tlink =cifs_get_tlink (tlink);mutex_init (&pCifsFile->fh_mutex);mutex_init (&pCifsFile->lock_mutex);INIT_LIST_HEAD (&pCifsFile->llist);
@@ -161,7 +161,7 @@ cifs_new_fileinfo(struct inode *newinode, __u16 fileHandle, struct file *file,INIT_WORK (&pCifsFile->oplock_break, cifs_oplock_break);write_lock (&GlobalSMBSeslock); -list_add (&pCifsFile->tlist, &tcon->openFileList); +list_add (&pCifsFile->tlist, &(tlink_tcon (tlink)->openFileList)); pCifsInode =CIFS_I (newinode);if (pCifsInode) {/* if readable file instance put first in list*/
@@ -487,7 +487,7 @@ cifs_create_set_dentry: } pfile_info =cifs_new_fileinfo (newinode, fileHandle, filp, - nd->path.mnt, tcon, oflags); + nd->path.mnt, tlink, oflags);if (pfile_info ==NULL ) {fput (filp);CIFSSMBClose (xid, tcon, fileHandle);
@@ -761,7 +761,7 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry, } cfile =cifs_new_fileinfo (newInode, fileHandle, filp, - nd->path.mnt, pTcon, + nd->path.mnt, tlink, nd->intent.open.flags);if (cfile ==NULL ) {fput (filp);
fs/cifs/file.c +16 -15
@@ -283,7 +283,7 @@ int cifs_open(struct inode *inode, struct file *file) pCifsFile =cifs_new_fileinfo (inode, netfid, file, file->f_path.mnt, - tcon, oflags); + tlink, oflags);if (pCifsFile ==NULL ) {CIFSSMBClose (xid, tcon, netfid); rc = -ENOMEM ;
@@ -376,7 +376,7 @@ int cifs_open(struct inode *inode, struct file *file) goto out; pCifsFile =cifs_new_fileinfo (inode, netfid, file, file->f_path.mnt, - tcon, file->f_flags); + tlink, file->f_flags);if (pCifsFile ==NULL ) { rc = -ENOMEM ; goto out;
@@ -468,7 +468,7 @@ static int cifs_reopen_file(struct file *file, bool can_flush) } cifs_sb =CIFS_SB (inode->i_sb); - tcon = pCifsFile->tcon; + tcon =tlink_tcon (pCifsFile->tlink);/* can not grab rename sem here because various ops, including those that already have the rename sem can end up causing writepage
@@ -582,7 +582,7 @@ int cifs_close(struct inode *inode, struct file *file) xid =GetXid (); cifs_sb =CIFS_SB (inode->i_sb); - pTcon = pSMBFile->tcon; + pTcon =tlink_tcon (pSMBFile->tlink);if (pSMBFile) {struct cifsLockInfo *li, *tmp;write_lock (&GlobalSMBSeslock);
@@ -660,7 +660,7 @@ int cifs_closedir(struct inode *inode, struct file *file) xid =GetXid ();if (pCFileStruct) { -struct cifsTconInfo *pTcon = pCFileStruct->tcon; +struct cifsTconInfo *pTcon =tlink_tcon (pCFileStruct->tlink);cFYI (1 ,"Freeing private data in close dir" );write_lock (&GlobalSMBSeslock);
@@ -684,6 +684,7 @@ int cifs_closedir(struct inode *inode, struct file *file)else cifs_buf_release (ptmp); } +cifs_put_tlink (pCFileStruct->tlink);kfree (file->private_data); file->private_data =NULL ; }
@@ -770,7 +771,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)cFYI (1 ,"Unknown type of lock" ); cifs_sb =CIFS_SB (file->f_path.dentry->d_sb); - tcon = ((struct cifsFileInfo *)file->private_data)->tcon; + tcon =tlink_tcon (((struct cifsFileInfo *)file->private_data)->tlink);if (file->private_data ==NULL ) { rc = -EBADF ;
@@ -970,7 +971,7 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data,return -EBADF ; open_file = file->private_data; - pTcon = open_file->tcon; + pTcon =tlink_tcon (open_file->tlink); rc =generic_write_checks (file, poffset, &write_size,0 );if (rc)
@@ -1071,7 +1072,7 @@ static ssize_t cifs_write(struct file *file, const char *write_data,if (file->private_data ==NULL )return -EBADF ; open_file = file->private_data; - pTcon = open_file->tcon; + pTcon =tlink_tcon (open_file->tlink); xid =GetXid ();
@@ -1393,7 +1394,7 @@ static int cifs_writepages(struct address_space *mapping,return generic_writepages (mapping, wbc); } - tcon = open_file->tcon; + tcon =tlink_tcon (open_file->tlink);if (!experimEnabled && tcon->ses->server->secMode & (SECMODE_SIGN_REQUIRED |SECMODE_SIGN_ENABLED )) {cifsFileInfo_put (open_file);
@@ -1664,7 +1665,7 @@ int cifs_fsync(struct file *file, int datasync)if (rc ==0 ) { rc =CIFS_I (inode)->write_behind_rc;CIFS_I (inode)->write_behind_rc =0 ; - tcon = smbfile->tcon; + tcon =tlink_tcon (smbfile->tlink);if (!rc && tcon && smbfile && !(CIFS_SB (inode->i_sb)->mnt_cifs_flags &CIFS_MOUNT_NOSSYNC )) rc =CIFSSMBFlush (xid, tcon, smbfile->netfid);
@@ -1756,7 +1757,7 @@ ssize_t cifs_user_read(struct file *file, char __user *read_data,return rc; } open_file = file->private_data; - pTcon = open_file->tcon; + pTcon =tlink_tcon (open_file->tlink);if ((file->f_flags &O_ACCMODE ) ==O_WRONLY )cFYI (1 ,"attempting read on write only file instance" );
@@ -1837,7 +1838,7 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,return rc; } open_file = file->private_data; - pTcon = open_file->tcon; + pTcon =tlink_tcon (open_file->tlink);if ((file->f_flags &O_ACCMODE ) ==O_WRONLY )cFYI (1 ,"attempting read on write only file instance" );
@@ -1973,7 +1974,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping, } open_file = file->private_data; cifs_sb =CIFS_SB (file->f_path.dentry->d_sb); - pTcon = open_file->tcon; + pTcon =tlink_tcon (open_file->tlink);/* * Reads as many pages as possible from fscache. Returns -ENOBUFS
@@ -2337,8 +2338,8 @@ void cifs_oplock_break(struct work_struct *work)* disconnected since oplock already released by the server */ if (!cfile->closePend && !cfile->oplock_break_cancelled) { - rc =CIFSSMBLock (0 , cfile->tcon, cfile->netfid,0 ,0 ,0 ,0 , -LOCKING_ANDX_OPLOCK_RELEASE , false); + rc =CIFSSMBLock (0 ,tlink_tcon (cfile->tlink), cfile->netfid,0 , +0 ,0 ,0 ,LOCKING_ANDX_OPLOCK_RELEASE , false);cFYI (1 ,"Oplock release rc = %d" , rc); }
fs/cifs/inode.c +6 -6
@@ -289,7 +289,7 @@ int cifs_get_file_info_unix(struct file *filp)struct inode *inode = filp->f_path.dentry->d_inode;struct cifs_sb_info *cifs_sb =CIFS_SB (inode->i_sb);struct cifsFileInfo *cfile = filp->private_data; -struct cifsTconInfo *tcon = cfile->tcon; +struct cifsTconInfo *tcon =tlink_tcon (cfile->tlink); xid =GetXid (); rc =CIFSSMBUnixQFileInfo (xid, tcon, cfile->netfid, &find_data);
@@ -540,7 +540,7 @@ int cifs_get_file_info(struct file *filp)struct inode *inode = filp->f_path.dentry->d_inode;struct cifs_sb_info *cifs_sb =CIFS_SB (inode->i_sb);struct cifsFileInfo *cfile = filp->private_data; -struct cifsTconInfo *tcon = cfile->tcon; +struct cifsTconInfo *tcon =tlink_tcon (cfile->tlink); xid =GetXid (); rc =CIFSSMBQFileInfo (xid, tcon, cfile->netfid, &find_data);
@@ -959,7 +959,7 @@ cifs_set_file_info(struct inode *inode, struct iattr *attrs, int xid,if (open_file) { netfid = open_file->netfid; netpid = open_file->pid; - pTcon = open_file->tcon; + pTcon =tlink_tcon (open_file->tlink); goto set_via_filehandle; }
@@ -1688,7 +1688,7 @@ int cifs_revalidate_file(struct file *filp)if (!cifs_inode_needs_reval (inode)) goto check_inval; -if (cfile->tcon->unix_ext) +if (tlink_tcon (cfile->tlink)->unix_ext) rc =cifs_get_file_info_unix (filp);else rc =cifs_get_file_info (filp);
@@ -1809,7 +1809,7 @@ cifs_set_file_size(struct inode *inode, struct iattr *attrs,if (open_file) {__u16 nfid = open_file->netfid;__u32 npid = open_file->pid; - pTcon = open_file->tcon; + pTcon =tlink_tcon (open_file->tlink); rc =CIFSSMBSetFileSize (xid, pTcon, attrs->ia_size, nfid, npid, false);cifsFileInfo_put (open_file);
@@ -1974,7 +1974,7 @@ cifs_setattr_unix(struct dentry *direntry, struct iattr *attrs)if (open_file) {u16 nfid = open_file->netfid;u32 npid = open_file->pid; - pTcon = open_file->tcon; + pTcon =tlink_tcon (open_file->tlink); rc =CIFSSMBUnixSetFileInfo (xid, pTcon, args, nfid, npid);cifsFileInfo_put (open_file); }else {
fs/cifs/ioctl.c +1 -1
@@ -38,7 +38,7 @@ long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg)struct cifs_sb_info *cifs_sb;#ifdef CONFIG_CIFS_POSIX struct cifsFileInfo *pSMBFile = filep->private_data; -struct cifsTconInfo *tcon = pSMBFile->tcon; +struct cifsTconInfo *tcon =tlink_tcon (pSMBFile->tlink);__u64 ExtAttrBits =0 ;__u64 ExtAttrMask =0 ;__u64 caps =le64_to_cpu (tcon->fsUnixInfo.Capability);
fs/cifs/link.c +0 -1
@@ -56,7 +56,6 @@ cifs_hardlink(struct dentry *old_file, struct inode *inode, goto cifs_hl_exit; } -/* if (cifs_sb_target->tcon->ses->capabilities & CAP_UNIX)*/ if (pTcon->unix_ext) rc = CIFSUnixCreateHardLink(xid, pTcon, fromName, toName, cifs_sb->local_nls,
fs/cifs/readdir.c +2 -2
@@ -246,7 +246,7 @@ static int initiate_cifs_search(const int xid, struct file *file) cifsFile = file->private_data; cifsFile->invalidHandle = true; cifsFile->srch_inf.endOfSearch = false; - cifsFile->tcon = pTcon; + cifsFile->tlink =cifs_get_tlink (tlink); full_path =build_path_from_dentry (file->f_path.dentry);if (full_path ==NULL ) {
@@ -830,7 +830,7 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)CIFSFindClose(xid, pTcon, cifsFile->netfid); } */ - pTcon = cifsFile->tcon; + pTcon =tlink_tcon (cifsFile->tlink); rc =find_cifs_entry (xid, pTcon, file, ¤t_entry, &num_to_fill);if (rc) {
Signature · 1 line
1.7.2.1
PATCH 11/15 cifs: have find_readable/writable_file filter by fsuid
In reply to Jeff LaytonWhen we implement multiuser mounts, we'll need to filter filehandles by fsuid. Add a flag for multiuser mounts and code to filter by fsuid when it's set.
--- fs/cifs/cifs_fs_sb.h | 3 ++- fs/cifs/cifsacl.c | 4 ++-- fs/cifs/cifsproto.h | 4 ++-- fs/cifs/dir.c | 1 + fs/cifs/file.c | 30 +++++++++++++++++++++++------- fs/cifs/inode.c | 6 +++--- 6 files changed, 33 insertions(+), 15 deletions(-)
fs/cifs/cifs_fs_sb.h +2 -1
@@ -36,6 +36,7 @@#define CIFS_MOUNT_NOPOSIXBRL 0x2000/* mandatory not posix byte range lock */ #define CIFS_MOUNT_NOSSYNC 0x4000/* don't do slow SMBflush on every sync*/ #define CIFS_MOUNT_FSCACHE 0x8000/* local caching enabled */ +#define CIFS_MOUNT_MULTIUSER 0x10000/* multiuser mount */ struct cifs_sb_info {struct cifsTconInfo *ptcon;/* primary mount */
@@ -47,7 +48,7 @@ struct cifs_sb_info {gid_t mnt_gid;mode_t mnt_file_mode;mode_t mnt_dir_mode; -int mnt_cifs_flags; +unsigned int mnt_cifs_flags;int prepathlen;char *prepath;/* relative path under the share to mount to */ #ifdef CONFIG_CIFS_DFS_UPCALL
fs/cifs/cifsacl.c +2 -2
@@ -615,7 +615,7 @@ static struct cifs_ntsd *get_cifs_acl(struct cifs_sb_info *cifs_sb,struct cifsFileInfo *open_file =NULL ;if (inode) - open_file =find_readable_file (CIFS_I (inode)); + open_file =find_readable_file (CIFS_I (inode), true);if (!open_file)return get_cifs_acl_by_path (cifs_sb, path, pacllen);
@@ -685,7 +685,7 @@ static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen,cFYI (DBG2 ,"set ACL for %s from mode 0x%x" , path, inode->i_mode); - open_file =find_readable_file (CIFS_I (inode)); + open_file =find_readable_file (CIFS_I (inode), true);if (!open_file)return set_cifs_acl_by_path (cifs_sb, path, pnntsd, acllen);
fs/cifs/cifsproto.h +2 -2
@@ -78,9 +78,9 @@ extern int checkSMB(struct smb_hdr *smb, __u16 mid, unsigned int length);extern bool is_valid_oplock_break (struct smb_hdr *smb,struct TCP_Server_Info *);extern bool is_size_safe_to_change (struct cifsInodeInfo *,__u64 eof); -extern struct cifsFileInfo *find_writable_file (struct cifsInodeInfo *); +extern struct cifsFileInfo *find_writable_file (struct cifsInodeInfo *,bool );#ifdef CONFIG_CIFS_EXPERIMENTAL -extern struct cifsFileInfo *find_readable_file (struct cifsInodeInfo *); +extern struct cifsFileInfo *find_readable_file (struct cifsInodeInfo *,bool );#endif extern unsigned int smbCalcSize (struct smb_hdr *ptr);extern unsigned int smbCalcSize_LE (struct smb_hdr *ptr);
fs/cifs/dir.c +1 -0
@@ -148,6 +148,7 @@ cifs_new_fileinfo(struct inode *newinode, __u16 fileHandle, struct file *file, pCifsFile->netfid = fileHandle; pCifsFile->pid = current->tgid; + pCifsFile->uid =current_fsuid (); pCifsFile->pInode =igrab (newinode); pCifsFile->mnt = mnt; pCifsFile->pfile = file;
fs/cifs/file.c +23 -7
@@ -1168,9 +1168,15 @@ static ssize_t cifs_write(struct file *file, const char *write_data, }#ifdef CONFIG_CIFS_EXPERIMENTAL -struct cifsFileInfo *find_readable_file (struct cifsInodeInfo *cifs_inode) +struct cifsFileInfo *find_readable_file (struct cifsInodeInfo *cifs_inode, +bool fsuid_only) {struct cifsFileInfo *open_file =NULL ; +struct cifs_sb_info *cifs_sb =CIFS_SB (cifs_inode->vfs_inode.i_sb); + +/* only filter by fsuid on multiuser mounts */ +if (!(cifs_sb->mnt_cifs_flags &CIFS_MOUNT_MULTIUSER )) + fsuid_only = false;read_lock (&GlobalSMBSeslock);/* we could simply get the first_list_entry since write-only entries
@@ -1179,6 +1185,8 @@ struct cifsFileInfo *find_readable_file(struct cifsInodeInfo *cifs_inode)list_for_each_entry (open_file, &cifs_inode->openFileList, flist) {if (open_file->closePend)continue ; +if (fsuid_only && open_file->uid !=current_fsuid ()) +continue ;if (open_file->pfile && ((open_file->pfile->f_flags &O_RDWR ) || (open_file->pfile->f_flags &O_RDONLY ))) {if (!open_file->invalidHandle) {
@@ -1198,9 +1206,11 @@ struct cifsFileInfo *find_readable_file(struct cifsInodeInfo *cifs_inode) }#endif -struct cifsFileInfo *find_writable_file (struct cifsInodeInfo *cifs_inode) +struct cifsFileInfo *find_writable_file (struct cifsInodeInfo *cifs_inode, +bool fsuid_only) {struct cifsFileInfo *open_file; +struct cifs_sb_info *cifs_sb =CIFS_SB (cifs_inode->vfs_inode.i_sb);bool any_available = false;int rc;
@@ -1214,13 +1224,19 @@ struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *cifs_inode)return NULL ; } +/* only filter by fsuid on multiuser mounts */ +if (!(cifs_sb->mnt_cifs_flags &CIFS_MOUNT_MULTIUSER )) + fsuid_only = false; +read_lock (&GlobalSMBSeslock); refind_writable:list_for_each_entry (open_file, &cifs_inode->openFileList, flist) { -if (open_file->closePend || - (!any_available && open_file->pid != current->tgid)) +if (open_file->closePend) +continue ; +if (!any_available && open_file->pid != current->tgid) +continue ; +if (fsuid_only && open_file->uid !=current_fsuid ())continue ; -if (open_file->pfile && ((open_file->pfile->f_flags &O_RDWR ) || (open_file->pfile->f_flags &O_WRONLY ))) {
@@ -1315,7 +1331,7 @@ static int cifs_partialpagewrite(struct page *page, unsigned from, unsigned to)if (mapping->host->i_size - offset < (loff_t )to) to = (unsigned )(mapping->host->i_size - offset); - open_file =find_writable_file (CIFS_I (mapping->host)); + open_file =find_writable_file (CIFS_I (mapping->host), false);if (open_file) { bytes_written =cifs_write (open_file->pfile, write_data, to-from, &offset);
@@ -1388,7 +1404,7 @@ static int cifs_writepages(struct address_space *mapping,* but it'll at least handle the return. Maybe it should be * a BUG() instead? */ - open_file =find_writable_file (CIFS_I (mapping->host)); + open_file =find_writable_file (CIFS_I (mapping->host), false);if (!open_file) {kfree (iov);return generic_writepages (mapping, wbc);
fs/cifs/inode.c +3 -3
@@ -955,7 +955,7 @@ cifs_set_file_info(struct inode *inode, struct iattr *attrs, int xid,/* * If the file is already open for write, just use that fileid */ - open_file =find_writable_file (cifsInode); + open_file =find_writable_file (cifsInode, true);if (open_file) { netfid = open_file->netfid; netpid = open_file->pid;
@@ -1805,7 +1805,7 @@ cifs_set_file_size(struct inode *inode, struct iattr *attrs,* writebehind data than the SMB timeout for the SetPathInfo * request would allow */ - open_file =find_writable_file (cifsInode); + open_file =find_writable_file (cifsInode, true);if (open_file) {__u16 nfid = open_file->netfid;__u32 npid = open_file->pid;
@@ -1970,7 +1970,7 @@ cifs_setattr_unix(struct dentry *direntry, struct iattr *attrs) args->ctime =NO_CHANGE_64 ; args->device =0 ; - open_file =find_writable_file (cifsInode); + open_file =find_writable_file (cifsInode, true);if (open_file) {u16 nfid = open_file->netfid;u32 npid = open_file->pid;
Signature · 1 line
1.7.2.1
PATCH 12/15 cifs: fix cifs_show_options to show "username=" or "multiuser"
In reply to Jeff Layton...based on CIFS_MOUNT_MULTIUSER flag.
--- fs/cifs/cifsfs.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)
fs/cifs/cifsfs.c +5 -1
@@ -368,8 +368,12 @@ cifs_show_options(struct seq_file *s, struct vfsmount *m)struct cifsTconInfo *tcon =cifs_sb_master_tcon (cifs_sb);seq_printf (s,",unc=%s" , tcon->treeName); -if (tcon->ses->userName) + +if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_MULTIUSER ) +seq_printf (s,",multiuser" ); +else if (tcon->ses->userName)seq_printf (s,",username=%s" , tcon->ses->userName); +if (tcon->ses->domainName)seq_printf (s,",domain=%s" , tcon->ses->domainName);
Signature · 1 line
1.7.2.1
PATCH 13/15 cifs: add routines to build sessions and tcons on the fly
In reply to Jeff LaytonThis patch is rather large, but it's a bit difficult to do piecemeal...
For non-multiuser mounts, everything will basically work as it does today. A call to cifs_sb_tlink will return the "master" tcon link.
Turn the tcon pointer in the cifs_sb into a radix tree that uses the fsuid of the process as a key. The value is a new "tcon_link" struct that contains info about a tcon that's under construction.
When a new process needs a tcon, it'll call cifs_sb_tcon. That will then look up the tcon_link in the radix tree. If it exists and is valid, it's returned.
If it doesn't exist, then we stuff a new tcon_link into the tree and mark it as pending and then go and try to build the session/tcon. If that works, the tcon pointer in the tcon_link is updated and the pending flag is cleared.
If the construction fails, then we set the tcon pointer to an ERR_PTR and clear the pending flag.
If the radix tree is searched and the tcon_link is marked pending then we go to sleep and wait for the pending flag to be cleared.
--- fs/cifs/cifs_fs_sb.h | 7 +- fs/cifs/cifsglob.h | 31 ++---- fs/cifs/connect.c | 272 ++++++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 282 insertions(+), 28 deletions(-)
fs/cifs/cifs_fs_sb.h +5 -2
@@ -15,6 +15,8 @@* the GNU Lesser General Public License for more details. * */ +#include <linux/radix-tree.h> +#ifndef _CIFS_FS_SB_H#define _CIFS_FS_SB_H
@@ -39,8 +41,9 @@#define CIFS_MOUNT_MULTIUSER 0x10000/* multiuser mount */ struct cifs_sb_info { -struct cifsTconInfo *ptcon;/* primary mount */ -struct list_head nested_tcon_q; +struct radix_tree_root tlink_tree; +#define CIFS_TLINK_MASTER_TAG 0/* tcon is "master" (mount) tcon */ +spinlock_t tlink_tree_lock;struct nls_table *local_nls;unsigned int rsize;unsigned int wsize;
fs/cifs/cifsglob.h +12 -19
@@ -314,33 +314,30 @@ struct cifsTconInfo {* "get" on the container. */ struct tcon_link { -spinlock_t tl_lock; -u32 tl_count; -u64 tl_time; +unsigned long tl_index; +unsigned long tl_flags; +#define TCON_LINK_PENDING 0 +#define TCON_LINK_IN_TREE 1 +unsigned long tl_time; +atomic_t tl_count;struct cifsTconInfo *tl_tcon; }; -static inline struct tcon_link * -cifs_sb_tlink (struct cifs_sb_info *cifs_sb) -{ -return (struct tcon_link *)cifs_sb->ptcon; -} +extern struct tcon_link *cifs_sb_tlink (struct cifs_sb_info *cifs_sb);static inline struct cifsTconInfo *tlink_tcon (struct tcon_link *tlink) { -return (struct cifsTconInfo *)tlink; +return tlink->tl_tcon; } -static inline void -cifs_put_tlink (struct tcon_link *tlink) -{ -return ; -} +extern void cifs_put_tlink (struct tcon_link *tlink);static inline struct tcon_link *cifs_get_tlink (struct tcon_link *tlink) { +if (tlink && !IS_ERR (tlink)) +atomic_inc (&tlink->tl_count);return tlink; }
@@ -450,11 +447,7 @@ CIFS_SB(struct super_block *sb) }/* 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; -} +extern struct cifsTconInfo *cifs_sb_master_tcon (struct cifs_sb_info *cifs_sb);static inline char CIFS_DIR_SEP (const struct cifs_sb_info *cifs_sb) {
fs/cifs/connect.c +265 -7
325 lines not on this page · raw message
Signature · 1 line
1.7.2.1
PATCH 15/15 cifs: add "multiuser" mount option
In reply to Jeff LaytonThis allows someone to declare a mount as a multiuser mount.
Multiuser mounts also imply "noperm" since we want to allow the server to handle permission checking. It also (for now) requires Kerberos authentication. Eventually, we could expand this to other authtypes, but that requires a scheme to allow per-user credential stashing in some form.
--- fs/cifs/connect.c | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-)
fs/cifs/connect.c +13 -0
@@ -100,6 +100,7 @@ struct smb_vol { bool noautotune:1; bool nostrictsync:1; /* do not force expensive SMBflush on every sync */ bool fsc:1; /* enable fscache */ + bool multiuser:1;unsigned int rsize;unsigned int wsize; bool sockopt_tcp_nodelay:1;
@@ -1346,6 +1347,8 @@ cifs_parse_mount_options(char *options, const char *devname, "/proc/fs/cifs/LookupCacheEnabled to 0\n"); }else if (strnicmp (data,"fsc" ,3 ) ==0 ) { vol->fsc = true; + }else if (strnicmp (data,"multiuser" ,8 ) ==0 ) { + vol->multiuser = true; }else printk (KERN_WARNING "CIFS: Unknown mount option %s\n" , data);
@@ -1377,6 +1380,13 @@ cifs_parse_mount_options(char *options, const char *devname,return 1 ; } } + +if (vol->multiuser && !(vol->secFlg &CIFSSEC_MAY_KRB5 )) { +cERROR (1 ,"Multiuser mounts currently require krb5 " +"authentication!" ); +return 1 ; + } +if (vol->UNCip ==NULL ) vol->UNCip = &vol->UNC[2 ];
@@ -2499,6 +2509,9 @@ static void setup_cifs_sb(struct smb_vol *pvolume_info, cifs_sb->mnt_cifs_flags |=CIFS_MOUNT_DYNPERM ;if (pvolume_info->fsc) cifs_sb->mnt_cifs_flags |=CIFS_MOUNT_FSCACHE ; +if (pvolume_info->multiuser) + cifs_sb->mnt_cifs_flags |= (CIFS_MOUNT_MULTIUSER | +CIFS_MOUNT_NO_PERM );if (pvolume_info->direct_io) {cFYI (1 ,"mounting share using direct i/o" ); cifs_sb->mnt_cifs_flags |=CIFS_MOUNT_DIRECT_IO ;
Signature · 1 line
1.7.2.1