Skip to contentSkip to conversation

cifs: clean up management of open filehandles (try #5)

PATCH In review Jeff Layton 4 participants 23 messages Oct 15, 2010 – Oct 24, 2010 9 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover cifs: clean up management of open filehandles (try #5)

Fifth attempt at a cleanup of the filehandle management code in CIFS. The changes from the last set are pretty minimal.

Steve has committed the first three patches in the set, so they've been dropped from this patchbomb.

Also, I've put the list ordering back in for the flist. I still think it's a worthless optimization and just makes the code more confusing and fragile, but Steve feels strongly that it should stay as an ordered list.

I'd like to see this merged before the 2.6.37 merge window opens. Comments and suggestions welcome...

Jeff Layton (13):
cifs: fix flags handling in cifs_posix_open
cifs: eliminate oflags option from cifs_new_fileinfo
cifs: eliminate the inode argument from cifs_new_fileinfo
cifs: clean up cifs_reopen_file
cifs: cifs_write argument change and cleanup
cifs: eliminate pfile pointer from cifsFileInfo
cifs: move cifs_new_fileinfo to file.c
cifs: convert GlobalSMBSeslock from a rwlock to regular spinlock
cifs: move cifsFileInfo_put to file.c
cifs: move close processing from cifs_close to cifsFileInfo_put
cifs: convert cifsFileInfo->count to non-atomic counter
cifs: wait for writeback to complete in cifs_flush
cifs: eliminate cifsInodeInfo->write_behind_rc

 fs/cifs/cifsfs.c    |    3 +-
 fs/cifs/cifsglob.h  |   25 +--
 fs/cifs/cifsproto.h |    8 +-
 fs/cifs/cifssmb.c   |    4 +-
 fs/cifs/dir.c       |  156 +-------------
 fs/cifs/file.c      |  612 +++++++++++++++++++++++++--------------------------
 fs/cifs/inode.c     |   15 +-
 fs/cifs/misc.c      |   16 +-
 fs/cifs/readdir.c   |    6 +-
 9 files changed, 334 insertions(+), 511 deletions(-)
Signature · 1 line
1.7.2.3

A message that is not in the archive (sent off-list or not yet received): 1287171248-464-1-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

#2 lore raw

PATCH 1/13 cifs: fix flags handling in cifs_posix_open

The way flags are passed and converted for cifs_posix_open is rather non-sensical. Some callers call cifs_posix_convert_flags on the flags before they pass them to cifs_posix_open, whereas some don't. Two flag conversion steps is just confusing though.

Change the function instead to clearly expect input in f_flags format, and fix the callers to pass that in. Then, have cifs_posix_open call cifs_convert_posix_flags to do the conversion. Move cifs_posix_open to file.c as well so we can keep cifs_convert_posix_flags as a static function.

Fix it also to not ignore O_CREAT, O_EXCL and O_TRUNC, and instead have cifs_reopen_file mask those bits off before calling cifs_posix_open.

---
 fs/cifs/cifsproto.h |    2 +-
 fs/cifs/dir.c       |   99 +++------------------------------------------
 fs/cifs/file.c      |  113 +++++++++++++++++++++++++++++++++++++++-----------
 3 files changed, 95 insertions(+), 119 deletions(-)
fs/cifs/cifsproto.h +1 -1
index 7f416ab..4f7edba 100644
@@ -111,7 +111,7 @@ extern struct cifsFileInfo *cifs_new_fileinfo(struct inode *newinode,
 				unsigned int oflags, __u32 oplock);
 extern int cifs_posix_open(char *full_path, struct inode **pinode,
 				struct super_block *sb,
-				int mode, int oflags,
+				int mode, unsigned int f_flags,
 				__u32 *poplock, __u16 *pnetfid, int xid);
 void cifs_fill_uniqueid(struct super_block *sb, struct cifs_fattr *fattr);
 extern void cifs_unix_basic_to_fattr(struct cifs_fattr *fattr,
fs/cifs/dir.c +6 -93

128 lines not on this page · raw message

fs/cifs/file.c +88 -25

148 lines not on this page · raw message

Signature · 1 line
1.7.2.3

A message that is not in the archive (sent off-list or not yet received): 1287171248-464-2-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

Reviewed-by
#4 lore raw

Re: [PATCH 01/13] cifs: fix flags handling in cifs_posix_open

Quoted 14 lines · Jeff Layton

The way flags are passed and converted for cifs_posix_open is rather non-sensical. Some callers call cifs_posix_convert_flags on the flags before they pass them to cifs_posix_open, whereas some don't. Two flag conversion steps is just confusing though.

Change the function instead to clearly expect input in f_flags format, and fix the callers to pass that in. Then, have cifs_posix_open call cifs_convert_posix_flags to do the conversion. Move cifs_posix_open to file.c as well so we can keep cifs_convert_posix_flags as a static function.

Fix it also to not ignore O_CREAT, O_EXCL and O_TRUNC, and instead have cifs_reopen_file mask those bits off before calling cifs_posix_open.

Quoted 6 lines
---
 fs/cifs/cifsproto.h |    2 +-
 fs/cifs/dir.c       |   99 +++------------------------------------------
 fs/cifs/file.c      |  113 +++++++++++++++++++++++++++++++++++++++-----------
 3 files changed, 95 insertions(+), 119 deletions(-)

Nice cleanup. Looks good to me.

#5 lore raw

PATCH 2/13 cifs: eliminate oflags option from cifs_new_fileinfo

In reply to a message not in the archive

Eliminate the poor, misunderstood "oflags" option from cifs_new_fileinfo. The callers mostly pass in the filp->f_flags here.

That's not correct however since we're checking that value for the presence of FMODE_READ. Luckily that only affects how the f_list is ordered. What it really wants here is the file->f_mode. Just use that field from the filp to determine it.

---
 fs/cifs/cifsproto.h |    3 +--
 fs/cifs/dir.c       |    9 ++++-----
 fs/cifs/file.c      |    5 ++---
 3 files changed, 7 insertions(+), 10 deletions(-)
fs/cifs/cifsproto.h +1 -2
index 4f7edba..781676e 100644
@@ -107,8 +107,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 tcon_link *tlink,
-				unsigned int oflags, __u32 oplock);
+				struct tcon_link *tlink, __u32 oplock);
 extern int cifs_posix_open(char *full_path, struct inode **pinode,
 				struct super_block *sb,
 				int mode, unsigned int f_flags,
fs/cifs/dir.c +4 -5
index 8c1af71..ce1fa30 100644
@@ -132,7 +132,7 @@ cifs_bp_rename_retry:
 
 struct cifsFileInfo *
 cifs_new_fileinfo(struct inode *newinode, __u16 fileHandle, struct file *file,
-		  struct tcon_link *tlink, unsigned int oflags, __u32 oplock)
+		  struct tcon_link *tlink, __u32 oplock)
 {
 	struct dentry *dentry = file->f_path.dentry;
 	struct cifsFileInfo *pCifsFile;
@@ -161,7 +161,7 @@ cifs_new_fileinfo(struct inode *newinode, __u16 fileHandle, struct file *file,
 	pCifsInode = CIFS_I(newinode);
 	if (pCifsInode) {
 		/* if readable file instance put first in list*/
-		if (oflags & FMODE_READ)
+		if (file->f_mode & FMODE_READ)
 			list_add(&pCifsFile->flist, &pCifsInode->openFileList);
 		else
 			list_add_tail(&pCifsFile->flist,
@@ -396,7 +396,7 @@ cifs_create_set_dentry:
 		}
 
 		pfile_info = cifs_new_fileinfo(newinode, fileHandle, filp,
-						tlink, oflags, oplock);
+						tlink, oplock);
 		if (pfile_info == NULL) {
 			fput(filp);
 			CIFSSMBClose(xid, tcon, fileHandle);
@@ -670,8 +670,7 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry,
 			}
 
 			cfile = cifs_new_fileinfo(newInode, fileHandle, filp,
-						  tlink, nd->intent.open.flags,
-						  oplock);
+						  tlink, oplock);
 			if (cfile == NULL) {
 				fput(filp);
 				CIFSSMBClose(xid, pTcon, fileHandle);
fs/cifs/file.c +2 -3
index b1ca6a4..774e3ac 100644
@@ -273,7 +273,7 @@ int cifs_open(struct inode *inode, struct file *file)
 			cFYI(1, "posix open succeeded");
 
 			pCifsFile = cifs_new_fileinfo(inode, netfid, file,
-							tlink, oflags, oplock);
+							tlink, oplock);
 			if (pCifsFile == NULL) {
 				CIFSSMBClose(xid, tcon, netfid);
 				rc = -ENOMEM;
@@ -365,8 +365,7 @@ int cifs_open(struct inode *inode, struct file *file)
 	if (rc != 0)
 		goto out;
 
-	pCifsFile = cifs_new_fileinfo(inode, netfid, file, tlink,
-					file->f_flags, oplock);
+	pCifsFile = cifs_new_fileinfo(inode, netfid, file, tlink, oplock);
 	if (pCifsFile == NULL) {
 		rc = -ENOMEM;
 		goto out;
Signature · 1 line
1.7.2.3

A message that is not in the archive (sent off-list or not yet received): 1287171248-464-3-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

Reviewed-by
#7 lore raw

Re: [PATCH 02/13] cifs: eliminate oflags option from cifs_new_fileinfo

Quoted 8 lines · Jeff Layton

Eliminate the poor, misunderstood "oflags" option from cifs_new_fileinfo. The callers mostly pass in the filp->f_flags here.

That's not correct however since we're checking that value for the presence of FMODE_READ. Luckily that only affects how the f_list is ordered. What it really wants here is the file->f_mode. Just use that field from the filp to determine it.

Quoted 7 lines
---
 fs/cifs/cifsproto.h |    3 +--
 fs/cifs/dir.c       |    9 ++++-----
 fs/cifs/file.c      |    5 ++---
 3 files changed, 7 insertions(+), 10 deletions(-)

Looks good to me.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#9 lore raw

Re: [PATCH 02/13] cifs: eliminate oflags option from cifs_new_fileinfo

Quoted 18 lines · Suresh Jayaraman
Quoted 8 lines · Jeff Layton

Eliminate the poor, misunderstood "oflags" option from cifs_new_fileinfo. The callers mostly pass in the filp->f_flags here.

That's not correct however since we're checking that value for the presence of FMODE_READ. Luckily that only affects how the f_list is ordered. What it really wants here is the file->f_mode. Just use that field from the filp to determine it.

Quoted 7 lines

---
 fs/cifs/cifsproto.h |    3 +--
 fs/cifs/dir.c       |    9 ++++-----
 fs/cifs/file.c      |    5 ++---

 3 files changed, 7 insertions(+), 10 deletions(-)
Quoted 3 lines

Looks good to me.

Thx - Looks like these last two patches eliminate some of the annoying sparse warnings too.   Down to only a few:

fs/cifs/dir.c:275:21: warning: restricted fmode_t degrades to integer fs/cifs/dir.c:277:21: warning: restricted fmode_t degrades to integer

--
Thanks,

Steve

#10 lore raw

PATCH 3/13 cifs: eliminate the inode argument from cifs_new_fileinfo

In reply to a message not in the archive

It already takes a file pointer. The inode associated with that had damn well better be the same one we're passing in anyway. Thus, there's no need for a separate argument here.

Also, get rid of the bogus check for a null pCifsInode pointer. The CIFS_I macro uses container_of(), and that will virtually never return a NULL pointer anyway.

Finally, move the setting of the canCache* flags outside of the lock. Other places in the code don't hold that lock when setting it, so I assume it's not really needed here either.

---
 fs/cifs/cifsproto.h |    3 +--
 fs/cifs/dir.c       |   40 ++++++++++++++++++----------------------
 fs/cifs/file.c      |    6 +++---
 3 files changed, 22 insertions(+), 27 deletions(-)
fs/cifs/cifsproto.h +1 -2
index 781676e..ca6a0d9 100644
@@ -105,8 +105,7 @@ extern u64 cifs_UnixTimeToNT(struct timespec);
 extern struct timespec cnvrtDosUnixTm(__le16 le_date, __le16 le_time,
 				      int offset);
 
-extern struct cifsFileInfo *cifs_new_fileinfo(struct inode *newinode,
-				__u16 fileHandle, struct file *file,
+extern struct cifsFileInfo *cifs_new_fileinfo(__u16 fileHandle, struct file *file,
 				struct tcon_link *tlink, __u32 oplock);
 extern int cifs_posix_open(char *full_path, struct inode **pinode,
 				struct super_block *sb,
fs/cifs/dir.c +18 -22
index ce1fa30..36cf3e2 100644
@@ -131,12 +131,13 @@ cifs_bp_rename_retry:
 }
 
 struct cifsFileInfo *
-cifs_new_fileinfo(struct inode *newinode, __u16 fileHandle, struct file *file,
+cifs_new_fileinfo(__u16 fileHandle, struct file *file,
 		  struct tcon_link *tlink, __u32 oplock)
 {
 	struct dentry *dentry = file->f_path.dentry;
+	struct inode *inode = dentry->d_inode;
+	struct cifsInodeInfo *pCifsInode = CIFS_I(inode);
 	struct cifsFileInfo *pCifsFile;
-	struct cifsInodeInfo *pCifsInode;
 
 	pCifsFile = kzalloc(sizeof(struct cifsFileInfo), GFP_KERNEL);
 	if (pCifsFile == NULL)
@@ -158,24 +159,20 @@ cifs_new_fileinfo(struct inode *newinode, __u16 fileHandle, struct file *file,
 
 	write_lock(&GlobalSMBSeslock);
 	list_add(&pCifsFile->tlist, &(tlink_tcon(tlink)->openFileList));
-	pCifsInode = CIFS_I(newinode);
-	if (pCifsInode) {
-		/* if readable file instance put first in list*/
-		if (file->f_mode & FMODE_READ)
-			list_add(&pCifsFile->flist, &pCifsInode->openFileList);
-		else
-			list_add_tail(&pCifsFile->flist,
-				      &pCifsInode->openFileList);
-
-		if ((oplock & 0xF) == OPLOCK_EXCLUSIVE) {
-			pCifsInode->clientCanCacheAll = true;
-			pCifsInode->clientCanCacheRead = true;
-			cFYI(1, "Exclusive Oplock inode %p", newinode);
-		} else if ((oplock & 0xF) == OPLOCK_READ)
-				pCifsInode->clientCanCacheRead = true;
-	}
+	/* if readable file instance put first in list*/
+	if (file->f_mode & FMODE_READ)
+		list_add(&pCifsFile->flist, &pCifsInode->openFileList);
+	else
+		list_add_tail(&pCifsFile->flist, &pCifsInode->openFileList);
 	write_unlock(&GlobalSMBSeslock);
 
+	if ((oplock & 0xF) == OPLOCK_EXCLUSIVE) {
+		pCifsInode->clientCanCacheAll = true;
+		pCifsInode->clientCanCacheRead = true;
+		cFYI(1, "Exclusive Oplock inode %p", inode);
+	} else if ((oplock & 0xF) == OPLOCK_READ)
+		pCifsInode->clientCanCacheRead = true;
+
 	file->private_data = pCifsFile;
 
 	return pCifsFile;
@@ -395,8 +392,7 @@ cifs_create_set_dentry:
 			goto cifs_create_out;
 		}
 
-		pfile_info = cifs_new_fileinfo(newinode, fileHandle, filp,
-						tlink, oplock);
+		pfile_info = cifs_new_fileinfo(fileHandle, filp, tlink, oplock);
 		if (pfile_info == NULL) {
 			fput(filp);
 			CIFSSMBClose(xid, tcon, fileHandle);
@@ -669,8 +665,8 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry,
 				goto lookup_out;
 			}
 
-			cfile = cifs_new_fileinfo(newInode, fileHandle, filp,
-						  tlink, oplock);
+			cfile = cifs_new_fileinfo(fileHandle, filp, tlink,
+						  oplock);
 			if (cfile == NULL) {
 				fput(filp);
 				CIFSSMBClose(xid, pTcon, fileHandle);
fs/cifs/file.c +3 -3
index 774e3ac..394cf28 100644
@@ -272,8 +272,8 @@ int cifs_open(struct inode *inode, struct file *file)
 		if (rc == 0) {
 			cFYI(1, "posix open succeeded");
 
-			pCifsFile = cifs_new_fileinfo(inode, netfid, file,
-							tlink, oplock);
+			pCifsFile = cifs_new_fileinfo(netfid, file, tlink,
+						      oplock);
 			if (pCifsFile == NULL) {
 				CIFSSMBClose(xid, tcon, netfid);
 				rc = -ENOMEM;
@@ -365,7 +365,7 @@ int cifs_open(struct inode *inode, struct file *file)
 	if (rc != 0)
 		goto out;
 
-	pCifsFile = cifs_new_fileinfo(inode, netfid, file, tlink, oplock);
+	pCifsFile = cifs_new_fileinfo(netfid, file, tlink, oplock);
 	if (pCifsFile == NULL) {
 		rc = -ENOMEM;
 		goto out;
Signature · 1 line
1.7.2.3
#11 lore raw

PATCH 4/13 cifs: clean up cifs_reopen_file

In reply to a message not in the archive

Add a f_flags field that holds the f_flags field from the filp. We'll need this info in case the filp ever goes away before the cifsFileInfo does. Have cifs_reopen_file use that value instead of filp->f_flags too and have it take a cifsFileInfo arg instead of a filp.

While we're at it, get rid of some bogus cargo-cult NULL pointer checks in that function and reduce the level of indentation.

---
 fs/cifs/cifsglob.h |    1 +
 fs/cifs/dir.c      |    1 +
 fs/cifs/file.c     |  129 ++++++++++++++++++++++------------------------------
 3 files changed, 57 insertions(+), 74 deletions(-)
fs/cifs/cifsglob.h +1 -0
index 9fc77a4..2eb054b 100644
@@ -390,6 +390,7 @@ struct cifsFileInfo {
 	/* lock scope id (0 if none) */
 	struct file *pfile; /* needed for writepage */
 	struct dentry *dentry;
+	unsigned int f_flags;
 	struct tcon_link *tlink;
 	struct mutex lock_mutex;
 	struct list_head llist; /* list of byte range locks we have. */
fs/cifs/dir.c +1 -0
index 36cf3e2..3c23d88 100644
@@ -147,6 +147,7 @@ cifs_new_fileinfo(__u16 fileHandle, struct file *file,
 	pCifsFile->pid = current->tgid;
 	pCifsFile->uid = current_fsuid();
 	pCifsFile->dentry = dget(dentry);
+	pCifsFile->f_flags = file->f_flags;
 	pCifsFile->pfile = file;
 	pCifsFile->invalidHandle = false;
 	pCifsFile->closePend = false;
fs/cifs/file.c +55 -74

223 lines not on this page · raw message

Signature · 1 line
1.7.2.3
#12 lore raw

PATCH 5/13 cifs: cifs_write argument change and cleanup

In reply to a message not in the archive

Have cifs_write take a cifsFileInfo pointer instead of a filp. Since cifsFileInfo holds references on the dentry, and that holds one to the inode, we can eliminate some unneeded NULL pointer checks.

---
 fs/cifs/file.c |   51 +++++++++++++++++----------------------------------
 1 files changed, 17 insertions(+), 34 deletions(-)
fs/cifs/file.c +17 -34
index dd922a5..d5f3007 100644
@@ -1027,8 +1027,9 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data,
 	return total_written;
 }
 
-static ssize_t cifs_write(struct file *file, const char *write_data,
-			  size_t write_size, loff_t *poffset)
+static ssize_t cifs_write(struct cifsFileInfo *open_file,
+			  const char *write_data, size_t write_size,
+			  loff_t *poffset)
 {
 	int rc = 0;
 	unsigned int bytes_written = 0;
@@ -1036,17 +1037,14 @@ static ssize_t cifs_write(struct file *file, const char *write_data,
 	struct cifs_sb_info *cifs_sb;
 	struct cifsTconInfo *pTcon;
 	int xid, long_op;
-	struct cifsFileInfo *open_file;
-	struct cifsInodeInfo *cifsi = CIFS_I(file->f_path.dentry->d_inode);
+	struct dentry *dentry = open_file->dentry;
+	struct cifsInodeInfo *cifsi = CIFS_I(dentry->d_inode);
 
-	cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
+	cifs_sb = CIFS_SB(dentry->d_sb);
 
 	cFYI(1, "write %zd bytes to offset %lld of %s", write_size,
-	   *poffset, file->f_path.dentry->d_name.name);
+	   *poffset, dentry->d_name.name);
 
-	if (file->private_data == NULL)
-		return -EBADF;
-	open_file = file->private_data;
 	pTcon = tlink_tcon(open_file->tlink);
 
 	xid = GetXid();
@@ -1056,15 +1054,6 @@ static ssize_t cifs_write(struct file *file, const char *write_data,
 	     total_written += bytes_written) {
 		rc = -EAGAIN;
 		while (rc == -EAGAIN) {
-			if (file->private_data == NULL) {
-				/* file has been closed on us */
-				FreeXid(xid);
-			/* if we have gotten here we have written some data
-			   and blocked, and the file has been freed on us
-			   while we blocked so return what we managed to
-			   write */
-				return total_written;
-			}
 			if (open_file->closePend) {
 				FreeXid(xid);
 				if (total_written)
@@ -1124,20 +1113,13 @@ static ssize_t cifs_write(struct file *file, const char *write_data,
 
 	cifs_stats_bytes_written(pTcon, total_written);
 
-	/* since the write may have blocked check these pointers again */
-	if ((file->f_path.dentry) && (file->f_path.dentry->d_inode)) {
-/*BB We could make this contingent on superblock ATIME flag too */
-/*		file->f_path.dentry->d_inode->i_ctime =
-		file->f_path.dentry->d_inode->i_mtime = CURRENT_TIME;*/
-		if (total_written > 0) {
-			spin_lock(&file->f_path.dentry->d_inode->i_lock);
-			if (*poffset > file->f_path.dentry->d_inode->i_size)
-				i_size_write(file->f_path.dentry->d_inode,
-					     *poffset);
-			spin_unlock(&file->f_path.dentry->d_inode->i_lock);
-		}
-		mark_inode_dirty_sync(file->f_path.dentry->d_inode);
+	if (total_written > 0) {
+		spin_lock(&dentry->d_inode->i_lock);
+		if (*poffset > dentry->d_inode->i_size)
+			i_size_write(dentry->d_inode, *poffset);
+		spin_unlock(&dentry->d_inode->i_lock);
 	}
+	mark_inode_dirty_sync(dentry->d_inode);
 	FreeXid(xid);
 	return total_written;
 }
@@ -1308,8 +1290,8 @@ static int cifs_partialpagewrite(struct page *page, unsigned from, unsigned to)
 
 	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);
+		bytes_written = cifs_write(open_file, write_data,
+					   to - from, &offset);
 		cifsFileInfo_put(open_file);
 		/* Does mm or vfs already set times? */
 		inode->i_atime = inode->i_mtime = current_fs_time(inode->i_sb);
@@ -1624,7 +1606,8 @@ static int cifs_write_end(struct file *file, struct address_space *mapping,
 		/* BB check if anything else missing out of ppw
 		   such as updating last write time */
 		page_data = kmap(page);
-		rc = cifs_write(file, page_data + offset, copied, &pos);
+		rc = cifs_write(file->private_data, page_data + offset,
+				copied, &pos);
 		/* if (rc < 0) should we set writebehind rc? */
 		kunmap(page);
 
Signature · 1 line
1.7.2.3
#13 lore raw

PATCH 6/13 cifs: eliminate pfile pointer from cifsFileInfo

In reply to a message not in the archive

All the remaining users of cifsFileInfo->pfile just use it to get at the f_flags/f_mode. Now that we store that separately in the cifsFileInfo, there's no need to consult the pfile at all from a cifsFileInfo pointer.

---
 fs/cifs/cifsglob.h |    1 -
 fs/cifs/dir.c      |    1 -
 fs/cifs/file.c     |   11 +++--------
 3 files changed, 3 insertions(+), 10 deletions(-)
fs/cifs/cifsglob.h +0 -1
index 2eb054b..2ecf675 100644
@@ -388,7 +388,6 @@ struct cifsFileInfo {
 	__u16 netfid;		/* file id from remote */
 	/* BB add lock scope info here if needed */ ;
 	/* lock scope id (0 if none) */
-	struct file *pfile; /* needed for writepage */
 	struct dentry *dentry;
 	unsigned int f_flags;
 	struct tcon_link *tlink;
fs/cifs/dir.c +0 -1
index 3c23d88..600eac1 100644
@@ -148,7 +148,6 @@ cifs_new_fileinfo(__u16 fileHandle, struct file *file,
 	pCifsFile->uid = current_fsuid();
 	pCifsFile->dentry = dget(dentry);
 	pCifsFile->f_flags = file->f_flags;
-	pCifsFile->pfile = file;
 	pCifsFile->invalidHandle = false;
 	pCifsFile->closePend = false;
 	pCifsFile->tlink = cifs_get_tlink(tlink);
fs/cifs/file.c +3 -8
index d5f3007..7935816 100644
@@ -1144,8 +1144,7 @@ struct cifsFileInfo *find_readable_file(struct cifsInodeInfo *cifs_inode,
 			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_FMODE(open_file->f_flags) & FMODE_READ) {
 			if (!open_file->invalidHandle) {
 				/* found a good file */
 				/* lock it so it will not be closed on us */
@@ -1194,9 +1193,7 @@ refind_writable:
 			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))) {
+		if (OPEN_FMODE(open_file->f_flags) & FMODE_WRITE) {
 			cifsFileInfo_get(open_file);
 
 			if (!open_file->invalidHandle) {
@@ -2160,9 +2157,7 @@ static int is_inode_writable(struct cifsInodeInfo *cifs_inode)
 	list_for_each_entry(open_file, &cifs_inode->openFileList, flist) {
 		if (open_file->closePend)
 			continue;
-		if (open_file->pfile &&
-		    ((open_file->pfile->f_flags & O_RDWR) ||
-		     (open_file->pfile->f_flags & O_WRONLY))) {
+		if (OPEN_FMODE(open_file->f_flags) & FMODE_WRITE) {
 			read_unlock(&GlobalSMBSeslock);
 			return 1;
 		}
Signature · 1 line
1.7.2.3
#14 lore raw

PATCH 7/13 cifs: move cifs_new_fileinfo to file.c

In reply to a message not in the archive

It's currently in dir.c which makes little sense...

---
 fs/cifs/dir.c  |   48 ------------------------------------------------
 fs/cifs/file.c |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+), 48 deletions(-)
fs/cifs/dir.c +0 -48
index 600eac1..3840edd 100644
@@ -130,54 +130,6 @@ cifs_bp_rename_retry:
 	return full_path;
 }
 
-struct cifsFileInfo *
-cifs_new_fileinfo(__u16 fileHandle, struct file *file,
-		  struct tcon_link *tlink, __u32 oplock)
-{
-	struct dentry *dentry = file->f_path.dentry;
-	struct inode *inode = dentry->d_inode;
-	struct cifsInodeInfo *pCifsInode = CIFS_I(inode);
-	struct cifsFileInfo *pCifsFile;
-
-	pCifsFile = kzalloc(sizeof(struct cifsFileInfo), GFP_KERNEL);
-	if (pCifsFile == NULL)
-		return pCifsFile;
-
-	pCifsFile->netfid = fileHandle;
-	pCifsFile->pid = current->tgid;
-	pCifsFile->uid = current_fsuid();
-	pCifsFile->dentry = dget(dentry);
-	pCifsFile->f_flags = file->f_flags;
-	pCifsFile->invalidHandle = false;
-	pCifsFile->closePend = false;
-	pCifsFile->tlink = cifs_get_tlink(tlink);
-	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, &(tlink_tcon(tlink)->openFileList));
-	/* if readable file instance put first in list*/
-	if (file->f_mode & FMODE_READ)
-		list_add(&pCifsFile->flist, &pCifsInode->openFileList);
-	else
-		list_add_tail(&pCifsFile->flist, &pCifsInode->openFileList);
-	write_unlock(&GlobalSMBSeslock);
-
-	if ((oplock & 0xF) == OPLOCK_EXCLUSIVE) {
-		pCifsInode->clientCanCacheAll = true;
-		pCifsInode->clientCanCacheRead = true;
-		cFYI(1, "Exclusive Oplock inode %p", inode);
-	} else if ((oplock & 0xF) == OPLOCK_READ)
-		pCifsInode->clientCanCacheRead = true;
-
-	file->private_data = pCifsFile;
-
-	return pCifsFile;
-}
-
 static void setup_cifs_dentry(struct cifsTconInfo *tcon,
 			      struct dentry *direntry,
 			      struct inode *newinode)
fs/cifs/file.c +47 -0

53 lines not on this page · raw message

Signature · 1 line
1.7.2.3

A message that is not in the archive (sent off-list or not yet received): 1287171248-464-8-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

#17 lore raw

PATCH 8/13 cifs: convert GlobalSMBSeslock from a rwlock to regular spinlock

In reply to a message not in the archive

Convert this lock to a regular spinlock

A rwlock_t offers little value here. It's more expensive than a regular spinlock unless you have a fairly large section of code that runs under the read lock and can benefit from the concurrency.

Additionally, we need to ensure that the refcounting for files isn't racy and to do that we need to lock areas that can increment it for write. That means that the areas that can actually use a read_lock are very few and relatively infrequently used.

While we're at it, change the name to something easier to type, and fix a bug in find_writable_file. cifsFileInfo_put can sleep and shouldn't be called while holding the lock.

---
 fs/cifs/cifsfs.c   |    2 +-
 fs/cifs/cifsglob.h |    2 +-
 fs/cifs/cifssmb.c  |    4 +-
 fs/cifs/file.c     |   54 ++++++++++++++++++++++++++--------------------------
 fs/cifs/misc.c     |    8 +++---
 fs/cifs/readdir.c  |    6 ++--
 6 files changed, 38 insertions(+), 38 deletions(-)
fs/cifs/cifsfs.c +1 -1
index 3facf25..c25e928 100644
@@ -942,8 +942,8 @@ init_cifs(void)
 	GlobalTotalActiveXid = 0;
 	GlobalMaxActiveXid = 0;
 	memset(Local_System_Name, 0, 15);
-	rwlock_init(&GlobalSMBSeslock);
 	rwlock_init(&cifs_tcp_ses_lock);
+	spin_lock_init(&cifs_file_list_lock);
 	spin_lock_init(&GlobalMid_Lock);
 
 	if (cifs_max_pending < 2) {
fs/cifs/cifsglob.h +1 -1
index 2ecf675..087bc4b 100644
@@ -722,7 +722,7 @@ GLOBAL_EXTERN rwlock_t		cifs_tcp_ses_lock;
  * If cifs_tcp_ses_lock and the lock below are both needed to be held, then
  * the cifs_tcp_ses_lock must be grabbed first and released last.
  */
-GLOBAL_EXTERN rwlock_t GlobalSMBSeslock;
+GLOBAL_EXTERN spinlock_t	cifs_file_list_lock;
 
 /* Outstanding dir notify requests */
 GLOBAL_EXTERN struct list_head GlobalDnotifyReqList;
fs/cifs/cifssmb.c +2 -2
index a420c7b..bfb59a6 100644
@@ -91,13 +91,13 @@ static void mark_open_files_invalid(struct cifsTconInfo *pTcon)
 	struct list_head *tmp1;
 
 /* list all files open on tree connection and mark them invalid */
-	write_lock(&GlobalSMBSeslock);
+	spin_lock(&cifs_file_list_lock);
 	list_for_each_safe(tmp, tmp1, &pTcon->openFileList) {
 		open_file = list_entry(tmp, struct cifsFileInfo, tlist);
 		open_file->invalidHandle = true;
 		open_file->oplock_break_cancelled = true;
 	}
-	write_unlock(&GlobalSMBSeslock);
+	spin_unlock(&cifs_file_list_lock);
 	/* BB Add call to invalidate_inodes(sb) for all superblocks mounted
 	   to this tcon */
 }
fs/cifs/file.c +27 -27

188 lines not on this page · raw message

fs/cifs/misc.c +4 -4
index 9bac3e7..de6073c 100644
@@ -560,7 +560,7 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
 				continue;
 
 			cifs_stats_inc(&tcon->num_oplock_brks);
-			read_lock(&GlobalSMBSeslock);
+			spin_lock(&cifs_file_list_lock);
 			list_for_each(tmp2, &tcon->openFileList) {
 				netfile = list_entry(tmp2, struct cifsFileInfo,
 						     tlist);
@@ -572,7 +572,7 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
 				 * closed anyway.
 				 */
 				if (netfile->closePend) {
-					read_unlock(&GlobalSMBSeslock);
+					spin_unlock(&cifs_file_list_lock);
 					read_unlock(&cifs_tcp_ses_lock);
 					return true;
 				}
@@ -594,11 +594,11 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
 					cifs_oplock_break_get(netfile);
 				netfile->oplock_break_cancelled = false;
 
-				read_unlock(&GlobalSMBSeslock);
+				spin_unlock(&cifs_file_list_lock);
 				read_unlock(&cifs_tcp_ses_lock);
 				return true;
 			}
-			read_unlock(&GlobalSMBSeslock);
+			spin_unlock(&cifs_file_list_lock);
 			read_unlock(&cifs_tcp_ses_lock);
 			cFYI(1, "No matching file for oplock break");
 			return true;
fs/cifs/readdir.c +3 -3
index 7bdcb35..c8961c5 100644
@@ -529,14 +529,14 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
 	   (index_to_find < first_entry_in_buffer)) {
 		/* close and restart search */
 		cFYI(1, "search backing up - close and restart search");
-		write_lock(&GlobalSMBSeslock);
+		spin_lock(&cifs_file_list_lock);
 		if (!cifsFile->srch_inf.endOfSearch &&
 		    !cifsFile->invalidHandle) {
 			cifsFile->invalidHandle = true;
-			write_unlock(&GlobalSMBSeslock);
+			spin_unlock(&cifs_file_list_lock);
 			CIFSFindClose(xid, pTcon, cifsFile->netfid);
 		} else
-			write_unlock(&GlobalSMBSeslock);
+			spin_unlock(&cifs_file_list_lock);
 		if (cifsFile->srch_inf.ntwrk_buf_start) {
 			cFYI(1, "freeing SMB ff cache buf on search rewind");
 			if (cifsFile->srch_inf.smallBuf)
Signature · 1 line
1.7.2.3

A message that is not in the archive (sent off-list or not yet received): 1287171248-464-9-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

#19 lore raw

Re: [PATCH 08/13] cifs: convert GlobalSMBSeslock from a rwlock to regular spinlock

Nice writeup on lwn with the more detailed explanation of the topic of rwlocks

http://lwn.net/Articles/364583/

This patch and patch 9 reviewed/merged now as well.

Also FYI - I fixed a checkpatch warning on patch 2

Quoted 343 lines · Jeff Layton

Convert this lock to a regular spinlock

A rwlock_t offers little value here. It's more expensive than a regular spinlock unless you have a fairly large section of code that runs under the read lock and can benefit from the concurrency.

Additionally, we need to ensure that the refcounting for files isn't racy and to do that we need to lock areas that can increment it for write. That means that the areas that can actually use a read_lock are very few and relatively infrequently used.

While we're at it, change the name to something easier to type, and fix a bug in find_writable_file. cifsFileInfo_put can sleep and shouldn't be called while holding the lock.

---
 fs/cifs/cifsfs.c   |    2 +-
 fs/cifs/cifsglob.h |    2 +-
 fs/cifs/cifssmb.c  |    4 +-
 fs/cifs/file.c     |   54 ++++++++++++++++++++++++++-------------------------- fs/cifs/misc.c     |    8 +++---
 fs/cifs/readdir.c  |    6 ++--

 6 files changed, 38 insertions(+), 38 deletions(-)
fs/cifs/cifsfs.c +1 -1
index 3facf25..c25e928 100644
@@ -942,8 +942,8 @@ init_cifs(void)
        GlobalTotalActiveXid = 0;
        GlobalMaxActiveXid = 0;
        memset(Local_System_Name, 0, 15);
-       rwlock_init(&GlobalSMBSeslock);
        rwlock_init(&cifs_tcp_ses_lock);
+       spin_lock_init(&cifs_file_list_lock);
        spin_lock_init(&GlobalMid_Lock);
 
        if (cifs_max_pending < 2) {
fs/cifs/cifsglob.h +1 -1
index 2ecf675..087bc4b 100644
@@ -722,7 +722,7 @@ GLOBAL_EXTERN rwlock_t              cifs_tcp_ses_lock;
  * If cifs_tcp_ses_lock and the lock below are both needed to be held, then
  * the cifs_tcp_ses_lock must be grabbed first and released last.
  */
-GLOBAL_EXTERN rwlock_t GlobalSMBSeslock;
+GLOBAL_EXTERN spinlock_t       cifs_file_list_lock;
 
  /* Outstanding dir notify requests */
  GLOBAL_EXTERN struct list_head GlobalDnotifyReqList;
fs/cifs/cifssmb.c +2 -2
index a420c7b..bfb59a6 100644
@@ -91,13 +91,13 @@ static void mark_open_files_invalid(struct cifsTconInfo *pTcon)
        struct list_head *tmp1;
 
  /* list all files open on tree connection and mark them invalid */
-       write_lock(&GlobalSMBSeslock);
+       spin_lock(&cifs_file_list_lock);
        list_for_each_safe(tmp, tmp1, &pTcon->openFileList) {
                open_file = list_entry(tmp, struct cifsFileInfo, tlist);
                open_file->invalidHandle = true;
                open_file->oplock_break_cancelled = true;
        }
-       write_unlock(&GlobalSMBSeslock);
+       spin_unlock(&cifs_file_list_lock);
        /* BB Add call to invalidate_inodes(sb) for all superblocks mounted

          to this tcon */
 }

fs/cifs/file.c +1 -1
index 293e9b7..26048dc 100644
@@ -246,14 +246,14 @@ cifs_new_fileinfo(__u16 fileHandle, struct file *file,
        atomic_set(&pCifsFile->count, 1);
        INIT_WORK(&pCifsFile->oplock_break, cifs_oplock_break);
 
-       write_lock(&GlobalSMBSeslock);
+       spin_lock(&cifs_file_list_lock);
        list_add(&pCifsFile->tlist, &(tlink_tcon(tlink)->openFileList));
        /* if readable file instance put first in list*/
        if (file->f_mode & FMODE_READ)
                list_add(&pCifsFile->flist, &pCifsInode->openFileList);

       else
               list_add_tail(&pCifsFile->flist, &pCifsInode->openFileList);
-       write_unlock(&GlobalSMBSeslock);
+       spin_unlock(&cifs_file_list_lock);

       if ((oplock & 0xF) == OPLOCK_EXCLUSIVE) { pCifsInode->clientCanCacheAll = true;

fs/cifs/file.c +1 -1
@@ -607,13 +607,13 @@ int cifs_close(struct inode *inode, struct file *file)
        pTcon = tlink_tcon(pSMBFile->tlink);
        if (pSMBFile) {
                struct cifsLockInfo *li, *tmp;
-               write_lock(&GlobalSMBSeslock);
+               spin_lock(&cifs_file_list_lock);
                pSMBFile->closePend = true;
                if (pTcon) {
                        /* no sense reconnecting to close a file that is

                          already closed */
                       if (!pTcon->need_reconnect) {
-                               write_unlock(&GlobalSMBSeslock);
+                               spin_unlock(&cifs_file_list_lock); timeout = 2;
                               while ((atomic_read(&pSMBFile->count) != 1) && (timeout <= 2048)) {

fs/cifs/file.c +2 -2
@@ -633,9 +633,9 @@ int cifs_close(struct inode *inode, struct file *file)
                                        rc = CIFSSMBClose(xid, pTcon,
                                                  pSMBFile->netfid);
                        } else
-                               write_unlock(&GlobalSMBSeslock);
+                               spin_unlock(&cifs_file_list_lock);
                } else
-                       write_unlock(&GlobalSMBSeslock);
+                       spin_unlock(&cifs_file_list_lock);
 
                /* Delete any outstanding lock records.

                  We'll lose them when the file is closed anyway. */

fs/cifs/file.c +5 -5
@@ -646,16 +646,16 @@ int cifs_close(struct inode *inode, struct file *file)
                }
                mutex_unlock(&pSMBFile->lock_mutex);
 
-               write_lock(&GlobalSMBSeslock);
+               spin_lock(&cifs_file_list_lock);
                list_del(&pSMBFile->flist);
                list_del(&pSMBFile->tlist);
-               write_unlock(&GlobalSMBSeslock);
+               spin_unlock(&cifs_file_list_lock);
                cifsFileInfo_put(file->private_data);
                file->private_data = NULL;
        } else
                rc = -EBADF;
 
-       read_lock(&GlobalSMBSeslock);
+       spin_lock(&cifs_file_list_lock);
        if (list_empty(&(CIFS_I(inode)->openFileList))) {
                cFYI(1, "closing last open instance for inode %p", inode);
                /* if the file is not open we do not know if we can cache info
@@ -663,7 +663,7 @@ int cifs_close(struct inode *inode, struct file *file)
                CIFS_I(inode)->clientCanCacheRead = false;
                CIFS_I(inode)->clientCanCacheAll  = false;
        }
-       read_unlock(&GlobalSMBSeslock);
+       spin_unlock(&cifs_file_list_lock);
        if ((rc == 0) && CIFS_I(inode)->write_behind_rc)
                rc = CIFS_I(inode)->write_behind_rc;
        FreeXid(xid);
@@ -685,18 +685,18 @@ int cifs_closedir(struct inode *inode, struct file *file)
                struct cifsTconInfo *pTcon = tlink_tcon(pCFileStruct->tlink);
 
                cFYI(1, "Freeing private data in close dir");
-               write_lock(&GlobalSMBSeslock);
+               spin_lock(&cifs_file_list_lock);

               if (!pCFileStruct->srch_inf.endOfSearch && !pCFileStruct->invalidHandle) { pCFileStruct->invalidHandle = true;
-                       write_unlock(&GlobalSMBSeslock);
+                       spin_unlock(&cifs_file_list_lock);
                       rc = CIFSFindClose(xid, pTcon, pCFileStruct->netfid); cFYI(1, "Closing uncompleted readdir with rc %d", rc);
                       /* not much we can do if it fails anyway, ignore rc */ rc = 0;
               } else
-                       write_unlock(&GlobalSMBSeslock);
+                       spin_unlock(&cifs_file_list_lock);
               ptmp = pCFileStruct->srch_inf.ntwrk_buf_start;
               if (ptmp) {
                       cFYI(1, "closedir free smb buf in srch struct");

fs/cifs/file.c +1 -1
@@ -1182,7 +1182,7 @@ struct cifsFileInfo *find_readable_file(struct cifsInodeInfo *cifs_inode,
        if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MULTIUSER))
                fsuid_only = false;
 
-       read_lock(&GlobalSMBSeslock);
+       spin_lock(&cifs_file_list_lock);
        /* we could simply get the first_list_entry since write-only entries

          are always at the end of the list but since the first entry might have a close pending, we go through the whole list */

fs/cifs/file.c +1 -1
@@ -1196,7 +1196,7 @@ struct cifsFileInfo *find_readable_file(struct cifsInodeInfo *cifs_inode,
                                /* found a good file */
                                /* lock it so it will not be closed on us */
                                cifsFileInfo_get(open_file);
-                               read_unlock(&GlobalSMBSeslock);
+                               spin_unlock(&cifs_file_list_lock);
                                return open_file;
                        } /* else might as well continue, and look for

                            another, or simply have the caller reopen it

fs/cifs/file.c +0 -0
@@ -1204,7 +1204,7 @@ struct cifsFileInfo *find_readable_file(struct cifsInodeInfo *cifs_inode,
                } else /* write only file */

                       break; /* write only files are last so must be done */ }
-       read_unlock(&GlobalSMBSeslock);
+       spin_unlock(&cifs_file_list_lock);
       return NULL;
 }
 #endif

fs/cifs/file.c +1 -1
@@ -1231,7 +1231,7 @@ struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *cifs_inode,
        if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MULTIUSER))
                fsuid_only = false;
 
-       read_lock(&GlobalSMBSeslock);
+       spin_lock(&cifs_file_list_lock);

 refind_writable:
       list_for_each_entry(open_file, &cifs_inode->openFileList, flist) { if (open_file->closePend)

fs/cifs/file.c +2 -2
@@ -1245,11 +1245,11 @@ refind_writable:
 
                        if (!open_file->invalidHandle) {
                                /* found a good writable file */
-                               read_unlock(&GlobalSMBSeslock);
+                               spin_unlock(&cifs_file_list_lock);
                                return open_file;
                        }
 
-                       read_unlock(&GlobalSMBSeslock);
+                       spin_unlock(&cifs_file_list_lock);
                        /* Had to unlock since following call can block */
                        rc = cifs_reopen_file(open_file, false);
                        if (!rc) {
@@ -1257,7 +1257,7 @@ refind_writable:
                                        return open_file;

                               else { /* start over in case this was deleted */ /* since the list could be modified */
-                                       read_lock(&GlobalSMBSeslock);
+                                       spin_lock(&cifs_file_list_lock); cifsFileInfo_put(open_file); goto refind_writable;
                               }

fs/cifs/file.c +0 -0
@@ -1271,7 +1271,7 @@ refind_writable:

                       to hold up writepages here (rather than in caller) with continuous retries */ cFYI(1, "wp failed on reopen file");
-                       read_lock(&GlobalSMBSeslock);
+                       spin_lock(&cifs_file_list_lock); /* can not use this handle, no write pending on this one after all */ cifsFileInfo_put(open_file);

fs/cifs/file.c +6 -6
@@ -1292,7 +1292,7 @@ refind_writable:
                any_available = true;
                goto refind_writable;
        }
-       read_unlock(&GlobalSMBSeslock);
+       spin_unlock(&cifs_file_list_lock);
        return NULL;
  }
 
@@ -2200,16 +2200,16 @@ static int is_inode_writable(struct cifsInodeInfo *cifs_inode)
  {
        struct cifsFileInfo *open_file;
 
-       read_lock(&GlobalSMBSeslock);
+       spin_lock(&cifs_file_list_lock);
        list_for_each_entry(open_file, &cifs_inode->openFileList, flist) {
                if (open_file->closePend)
                        continue;
                if (OPEN_FMODE(open_file->f_flags) & FMODE_WRITE) {
-                       read_unlock(&GlobalSMBSeslock);
+                       spin_unlock(&cifs_file_list_lock);
                        return 1;
                }
        }
-       read_unlock(&GlobalSMBSeslock);
+       spin_unlock(&cifs_file_list_lock);
        return 0;
  }
 
@@ -2373,8 +2373,8 @@ void cifs_oplock_break(struct work_struct *work)
         * finished grabbing reference for us.  Make sure it's done by
         * waiting for GlobalSMSSeslock.
         */
-       write_lock(&GlobalSMBSeslock);
-       write_unlock(&GlobalSMBSeslock);
+       spin_lock(&cifs_file_list_lock);
+       spin_unlock(&cifs_file_list_lock);
 
        cifs_oplock_break_put(cfile);
  }
fs/cifs/misc.c +4 -4
index 9bac3e7..de6073c 100644
@@ -560,7 +560,7 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
                                continue;
 
                        cifs_stats_inc(&tcon->num_oplock_brks);
-                       read_lock(&GlobalSMBSeslock);
+                       spin_lock(&cifs_file_list_lock);
                        list_for_each(tmp2, &tcon->openFileList) {
                                netfile = list_entry(tmp2, struct cifsFileInfo,
                                                     tlist);
@@ -572,7 +572,7 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
                                 * closed anyway.
                                 */
                                if (netfile->closePend) {
-                                       read_unlock(&GlobalSMBSeslock);
+                                       spin_unlock(&cifs_file_list_lock);
                                        read_unlock(&cifs_tcp_ses_lock);
                                        return true;
                                }
@@ -594,11 +594,11 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
                                        cifs_oplock_break_get(netfile);
                                netfile->oplock_break_cancelled = false;
 
-                               read_unlock(&GlobalSMBSeslock);
+                               spin_unlock(&cifs_file_list_lock);
                                read_unlock(&cifs_tcp_ses_lock);
                                return true;
                        }
-                       read_unlock(&GlobalSMBSeslock);
+                       spin_unlock(&cifs_file_list_lock);
                        read_unlock(&cifs_tcp_ses_lock);
                        cFYI(1, "No matching file for oplock break");
                        return true;
fs/cifs/readdir.c +1 -1
index 7bdcb35..c8961c5 100644
@@ -529,14 +529,14 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
           (index_to_find < first_entry_in_buffer)) {
                /* close and restart search */
                cFYI(1, "search backing up - close and restart search");
-               write_lock(&GlobalSMBSeslock);
+               spin_lock(&cifs_file_list_lock);

               if (!cifsFile->srch_inf.endOfSearch && !cifsFile->invalidHandle) { cifsFile->invalidHandle = true;
-                       write_unlock(&GlobalSMBSeslock);
+                       spin_unlock(&cifs_file_list_lock); CIFSFindClose(xid, pTcon, cifsFile->netfid); } else
-                       write_unlock(&GlobalSMBSeslock);
+                       spin_unlock(&cifs_file_list_lock);
               if (cifsFile->srch_inf.ntwrk_buf_start) {
                       cFYI(1, "freeing SMB ff cache buf on search rewind"); if (cifsFile->srch_inf.smallBuf)
--
1.7.2.3

Signature · 3 lines
Thanks,

Steve
#20 lore raw

PATCH 9/13 cifs: move cifsFileInfo_put to file.c

In reply to a message not in the archive

...and make it non-inlined in preparation for the move of most of cifs_close to it.

---
 fs/cifs/cifsglob.h |   10 +---------
 fs/cifs/file.c     |   10 ++++++++++
 2 files changed, 11 insertions(+), 9 deletions(-)
fs/cifs/cifsglob.h +1 -9
index 087bc4b..d5beb42 100644
@@ -408,15 +408,7 @@ static inline void cifsFileInfo_get(struct cifsFileInfo *cifs_file)
 	atomic_inc(&cifs_file->count);
 }
 
-/* Release a reference on the file private data */
-static inline void cifsFileInfo_put(struct cifsFileInfo *cifs_file)
-{
-	if (atomic_dec_and_test(&cifs_file->count)) {
-		cifs_put_tlink(cifs_file->tlink);
-		dput(cifs_file->dentry);
-		kfree(cifs_file);
-	}
-}
+void cifsFileInfo_put(struct cifsFileInfo *cifs_file);
 
 /*
  * One of these for each file inode
fs/cifs/file.c +10 -0
index 26048dc..a3634e4 100644
@@ -266,6 +266,16 @@ cifs_new_fileinfo(__u16 fileHandle, struct file *file,
 	return pCifsFile;
 }
 
+/* Release a reference on the file private data */
+void cifsFileInfo_put(struct cifsFileInfo *cifs_file)
+{
+	if (atomic_dec_and_test(&cifs_file->count)) {
+		cifs_put_tlink(cifs_file->tlink);
+		dput(cifs_file->dentry);
+		kfree(cifs_file);
+	}
+}
+
 int cifs_open(struct inode *inode, struct file *file)
 {
 	int rc = -EACCES;
Signature · 1 line
1.7.2.3
#21 lore raw

PATCH 10/13 cifs: move close processing from cifs_close to cifsFileInfo_put

In reply to a message not in the archive

Now that it's feasible for a cifsFileInfo to outlive the filp under which it was created, move the close processing into cifsFileInfo_put.

This means that the last user of the filehandle always does the actual on the wire close call. This also allows us to get rid of the closePend flag from cifsFileInfo. If we have an active reference to the file then it's never going to have a close pending.

cifs_close is converted to simply put the filehandle.

---
 fs/cifs/cifsglob.h |    1 -
 fs/cifs/file.c     |  187 +++++++++++++++++-----------------------------------
 fs/cifs/misc.c     |   10 ---
 3 files changed, 60 insertions(+), 138 deletions(-)
fs/cifs/cifsglob.h +0 -1
index d5beb42..df4629e 100644
@@ -393,7 +393,6 @@ struct cifsFileInfo {
 	struct tcon_link *tlink;
 	struct mutex lock_mutex;
 	struct list_head llist; /* list of byte range locks we have. */
-	bool closePend:1;	/* file is marked to close */
 	bool invalidHandle:1;	/* file closed via session abend */
 	bool oplock_break_cancelled:1;
 	atomic_t count;		/* reference count */
fs/cifs/file.c +60 -127

275 lines not on this page · raw message

fs/cifs/misc.c +0 -10
index de6073c..b86b423 100644
@@ -567,16 +567,6 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
 				if (pSMB->Fid != netfile->netfid)
 					continue;
 
-				/*
-				 * don't do anything if file is about to be
-				 * closed anyway.
-				 */
-				if (netfile->closePend) {
-					spin_unlock(&cifs_file_list_lock);
-					read_unlock(&cifs_tcp_ses_lock);
-					return true;
-				}
-
 				cFYI(1, "file id match, oplock break");
 				pCifsInode = CIFS_I(netfile->dentry->d_inode);
 				pCifsInode->clientCanCacheAll = false;
Signature · 1 line
1.7.2.3
#22 lore raw

PATCH 11/13 cifs: convert cifsFileInfo->count to non-atomic counter

In reply to a message not in the archive

The count for cifsFileInfo is currently an atomic, but that just adds complexity for little value. We generally need to hold cifs_file_list_lock to traverse the lists anyway so we might as well make this counter non-atomic and simply use the cifs_file_list_lock to protect it.

---
 fs/cifs/cifsglob.h |    9 ++++++---
 fs/cifs/file.c     |    8 +++++---
 2 files changed, 11 insertions(+), 6 deletions(-)
fs/cifs/cifsglob.h +6 -3
index df4629e..a97e0e5 100644
@@ -395,16 +395,19 @@ struct cifsFileInfo {
 	struct list_head llist; /* list of byte range locks we have. */
 	bool invalidHandle:1;	/* file closed via session abend */
 	bool oplock_break_cancelled:1;
-	atomic_t count;		/* reference count */
+	int count;		/* refcount -- protected by cifs_file_list_lock */
 	struct mutex fh_mutex; /* prevents reopen race after dead ses*/
 	struct cifs_search_info srch_inf;
 	struct work_struct oplock_break; /* work for oplock breaks */
 };
 
-/* Take a reference on the file private data */
+/*
+ * Take a reference on the file private data. Must be called with
+ * cifs_file_list_lock held.
+ */
 static inline void cifsFileInfo_get(struct cifsFileInfo *cifs_file)
 {
-	atomic_inc(&cifs_file->count);
+	++cifs_file->count;
 }
 
 void cifsFileInfo_put(struct cifsFileInfo *cifs_file);
fs/cifs/file.c +5 -3
index 8c81e7b..baf4b50 100644
@@ -232,6 +232,7 @@ cifs_new_fileinfo(__u16 fileHandle, struct file *file,
 	if (pCifsFile == NULL)
 		return pCifsFile;
 
+	pCifsFile->count = 1;
 	pCifsFile->netfid = fileHandle;
 	pCifsFile->pid = current->tgid;
 	pCifsFile->uid = current_fsuid();
@@ -242,7 +243,6 @@ cifs_new_fileinfo(__u16 fileHandle, struct file *file,
 	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);
 
 	spin_lock(&cifs_file_list_lock);
@@ -267,7 +267,8 @@ cifs_new_fileinfo(__u16 fileHandle, struct file *file,
 
 /*
  * Release a reference on the file private data. This may involve closing
- * the filehandle out on the server.
+ * the filehandle out on the server. Must be called without holding
+ * cifs_file_list_lock.
  */
 void cifsFileInfo_put(struct cifsFileInfo *cifs_file)
 {
@@ -276,7 +277,7 @@ void cifsFileInfo_put(struct cifsFileInfo *cifs_file)
 	struct cifsLockInfo *li, *tmp;
 
 	spin_lock(&cifs_file_list_lock);
-	if (!atomic_dec_and_test(&cifs_file->count)) {
+	if (--cifs_file->count > 0) {
 		spin_unlock(&cifs_file_list_lock);
 		return;
 	}
@@ -2322,6 +2323,7 @@ void cifs_oplock_break(struct work_struct *work)
 	cifs_oplock_break_put(cfile);
 }
 
+/* must be called while holding cifs_file_list_lock */
 void cifs_oplock_break_get(struct cifsFileInfo *cfile)
 {
 	cifs_sb_active(cfile->dentry->d_sb);
Signature · 1 line
1.7.2.3

A message that is not in the archive (sent off-list or not yet received): 1287171248-464-12-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

#24 lore raw

Re: [PATCH 11/13] cifs: convert cifsFileInfo->count to non-atomic counter

Merged. Made trivial checkpatch cleanup.

As mentioned earlier, I don't think that this patch helps (atomic_t type is small
on most arch and the atomic operations are single instructions), but is harmless and don't won't to create merge conflicts with the next patch so merging this.

Quoted 7 lines · Jeff Layton

The count for cifsFileInfo is currently an atomic, but that just adds complexity for little value. We generally need to hold cifs_file_list_lock to traverse the lists anyway so we might as well make this counter non-atomic and simply use the cifs_file_list_lock to protect it.

Signature · 3 lines
Thanks,

Steve

A message that is not in the archive (sent off-list or not yet received): AANLkTimfSq1vrGjcdLRh5+p=t0oF9ouEOzaVsE5vcZBq-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#26 lore raw

Re: [PATCH 11/13] cifs: convert cifsFileInfo->count to non-atomic counter

Quoted 7 lines · On Sat, 23 Oct 2010 11:57:52 -0500 Steve French…

Merged. Made trivial checkpatch cleanup.

As mentioned earlier, I don't think that this patch helps (atomic_t type is small
on most arch and the atomic operations are single instructions), but is harmless and don't won't to create merge conflicts with the next patch so merging this.

Thanks.

atomic_t's are fine for simple counters that don't require locking around them. They help ensure that the compiler doesn't erroneously optimize access to the counter when it shouldn't (which would cause races). This isn't free however -- it comes at a cost (albeit a small one) in loss of optimization.

If you need to hold a spinlock when you access that variable _anyway_ (and that is the case here), there is no benefit to using an atomic_t .
It's akin to using both belt and suspenders to hold up your pants.

Signature · 1 line
Jeff Layton <[email protected]>
#27 lore raw

PATCH 12/13 cifs: wait for writeback to complete in cifs_flush

In reply to a message not in the archive

The f_op->flush operation is the last chance to return a writeback related error when closing a file. Ensure that we don't miss reporting any errors by waiting for writeback to complete in cifs_flush before proceeding.

There's no reason to do this when the file isn't open for write however.

---
 fs/cifs/file.c |   21 +++++++--------------
 1 files changed, 7 insertions(+), 14 deletions(-)
fs/cifs/file.c +7 -14
index baf4b50..128e07b 100644
@@ -1688,20 +1688,13 @@ int cifs_flush(struct file *file, fl_owner_t id)
 	struct inode *inode = file->f_path.dentry->d_inode;
 	int rc = 0;
 
-	/* Rather than do the steps manually:
-	   lock the inode for writing
-	   loop through pages looking for write behind data (dirty pages)
-	   coalesce into contiguous 16K (or smaller) chunks to write to server
-	   send to server (prefer in parallel)
-	   deal with writebehind errors
-	   unlock inode for writing
-	   filemapfdatawrite appears easier for the time being */
-
-	rc = filemap_fdatawrite(inode->i_mapping);
-	/* reset wb rc if we were able to write out dirty pages */
-	if (!rc) {
-		rc = CIFS_I(inode)->write_behind_rc;
-		CIFS_I(inode)->write_behind_rc = 0;
+	if (file->f_mode & FMODE_WRITE) {
+		rc = filemap_write_and_wait(inode->i_mapping);
+		/* reset wb rc if we were able to write out dirty pages */
+		if (!rc) {
+			rc = CIFS_I(inode)->write_behind_rc;
+			CIFS_I(inode)->write_behind_rc = 0;
+		}
 	}
 
 	cFYI(1, "Flush inode %p file %p rc %d", inode, file, rc);
Signature · 1 line
1.7.2.3
#28 lore raw

PATCH 13/13 cifs: eliminate cifsInodeInfo->write_behind_rc

In reply to a message not in the archive

write_behind_rc is redundant and just adds complexity to the code. What we really want to do instead is to use mapping_set_error to reset the flags on the mapping when we find a writeback error and can't report it to userspace yet.

For cifs_flush and cifs_fsync, we shouldn't reset the flags since errors returned there do get reported to userspace.

---
 fs/cifs/cifsfs.c   |    1 -
 fs/cifs/cifsglob.h |    1 -
 fs/cifs/file.c     |   34 ++++++++--------------------------
 fs/cifs/inode.c    |   15 +++++----------
 4 files changed, 13 insertions(+), 38 deletions(-)
fs/cifs/cifsfs.c +0 -1
index c25e928..6e3e2e8 100644
@@ -323,7 +323,6 @@ cifs_alloc_inode(struct super_block *sb)
 		return NULL;
 	cifs_inode->cifsAttrs = 0x20;	/* default */
 	cifs_inode->time = 0;
-	cifs_inode->write_behind_rc = 0;
 	/* Until the file is open and we have gotten oplock
 	info back from the server, can not assume caching of
 	file data or metadata */
fs/cifs/cifsglob.h +0 -1
index a97e0e5..89c3de0 100644
@@ -420,7 +420,6 @@ struct cifsInodeInfo {
 	struct list_head lockList;
 	/* BB add in lists for dirty pages i.e. write caching info for oplock */
 	struct list_head openFileList;
-	int write_behind_rc;
 	__u32 cifsAttrs; /* e.g. DOS archive bit, sparse, compressed, system */
 	unsigned long time;	/* jiffies of last update/check of inode */
 	bool clientCanCacheRead:1;	/* read oplock */
fs/cifs/file.c +8 -26
index 128e07b..3a97055 100644
@@ -131,8 +131,7 @@ static inline int cifs_open_inode_helper(struct inode *inode,
 			/* BB no need to lock inode until after invalidate
 			since namei code should already have it locked? */
 			rc = filemap_write_and_wait(inode->i_mapping);
-			if (rc != 0)
-				pCifsInode->write_behind_rc = rc;
+			mapping_set_error(inode->i_mapping, rc);
 		}
 		cFYI(1, "invalidating remote inode since open detected it "
 			 "changed");
@@ -606,8 +605,7 @@ reopen_success:
 
 	if (can_flush) {
 		rc = filemap_write_and_wait(inode->i_mapping);
-		if (rc != 0)
-			CIFS_I(inode)->write_behind_rc = rc;
+		mapping_set_error(inode->i_mapping, rc);
 
 		pCifsInode->clientCanCacheAll = false;
 		pCifsInode->clientCanCacheRead = false;
@@ -1489,12 +1487,7 @@ retry:
 			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);
+				mapping_set_error(mapping, rc);
 			} else {
 				cifs_stats_bytes_written(tcon, bytes_written);
 			}
@@ -1639,10 +1632,8 @@ int cifs_fsync(struct file *file, int datasync)
 
 	rc = filemap_write_and_wait(inode->i_mapping);
 	if (rc == 0) {
-		rc = CIFS_I(inode)->write_behind_rc;
-		CIFS_I(inode)->write_behind_rc = 0;
 		tcon = tlink_tcon(smbfile->tlink);
-		if (!rc && tcon && smbfile &&
+		if (rc == 0 &&
 		   !(CIFS_SB(inode->i_sb)->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC))
 			rc = CIFSSMBFlush(xid, tcon, smbfile->netfid);
 	}
@@ -1688,14 +1679,8 @@ int cifs_flush(struct file *file, fl_owner_t id)
 	struct inode *inode = file->f_path.dentry->d_inode;
 	int rc = 0;
 
-	if (file->f_mode & FMODE_WRITE) {
+	if (file->f_mode & FMODE_WRITE)
 		rc = filemap_write_and_wait(inode->i_mapping);
-		/* reset wb rc if we were able to write out dirty pages */
-		if (!rc) {
-			rc = CIFS_I(inode)->write_behind_rc;
-			CIFS_I(inode)->write_behind_rc = 0;
-		}
-	}
 
 	cFYI(1, "Flush inode %p file %p rc %d", inode, file, rc);
 
@@ -2274,7 +2259,7 @@ void cifs_oplock_break(struct work_struct *work)
 						  oplock_break);
 	struct inode *inode = cfile->dentry->d_inode;
 	struct cifsInodeInfo *cinode = CIFS_I(inode);
-	int rc, waitrc = 0;
+	int rc = 0;
 
 	if (inode && S_ISREG(inode->i_mode)) {
 		if (cinode->clientCanCacheRead)
@@ -2283,13 +2268,10 @@ void cifs_oplock_break(struct work_struct *work)
 			break_lease(inode, O_WRONLY);
 		rc = filemap_fdatawrite(inode->i_mapping);
 		if (cinode->clientCanCacheRead == 0) {
-			waitrc = filemap_fdatawait(inode->i_mapping);
+			rc = filemap_fdatawait(inode->i_mapping);
+			mapping_set_error(inode->i_mapping, rc);
 			invalidate_remote_inode(inode);
 		}
-		if (!rc)
-			rc = waitrc;
-		if (rc)
-			cinode->write_behind_rc = rc;
 		cFYI(1, "Oplock flush inode %p rc %d", inode, rc);
 	}
 
fs/cifs/inode.c +5 -10
index cfe2339..ed5558b 100644
@@ -1688,8 +1688,7 @@ cifs_invalidate_mapping(struct inode *inode)
 	/* write back any cached data */
 	if (inode->i_mapping && inode->i_mapping->nrpages != 0) {
 		rc = filemap_write_and_wait(inode->i_mapping);
-		if (rc)
-			cifs_i->write_behind_rc = rc;
+		mapping_set_error(inode->i_mapping, rc);
 	}
 	invalidate_remote_inode(inode);
 	cifs_fscache_reset_inode_cookie(inode);
@@ -1949,10 +1948,8 @@ cifs_setattr_unix(struct dentry *direntry, struct iattr *attrs)
 	 * the flush returns error?
 	 */
 	rc = filemap_write_and_wait(inode->i_mapping);
-	if (rc != 0) {
-		cifsInode->write_behind_rc = rc;
-		rc = 0;
-	}
+	mapping_set_error(inode->i_mapping, rc);
+	rc = 0;
 
 	if (attrs->ia_valid & ATTR_SIZE) {
 		rc = cifs_set_file_size(inode, attrs, xid, full_path);
@@ -2093,10 +2090,8 @@ cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs)
 	 * the flush returns error?
 	 */
 	rc = filemap_write_and_wait(inode->i_mapping);
-	if (rc != 0) {
-		cifsInode->write_behind_rc = rc;
-		rc = 0;
-	}
+	mapping_set_error(inode->i_mapping, rc);
+	rc = 0;
 
 	if (attrs->ia_valid & ATTR_SIZE) {
 		rc = cifs_set_file_size(inode, attrs, xid, full_path);
Signature · 1 line
1.7.2.3

A message that is not in the archive (sent off-list or not yet received): 1287171248-464-14-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

#30 lore raw

Re: [PATCH 13/13] cifs: eliminate cifsInodeInfo->write_behind_rc

Quoted 8 lines · Jeff Layton

write_behind_rc is redundant and just adds complexity to the code. What we really want to do instead is to use mapping_set_error to reset the flags on the mapping when we find a writeback error and can't report it to userspace yet.

For cifs_flush and cifs_fsync, we shouldn't reset the flags since errors returned there do get reported to userspace.

Quoted 8 lines
---
 fs/cifs/cifsfs.c   |    1 -
 fs/cifs/cifsglob.h |    1 -
 fs/cifs/file.c     |   34 ++++++++--------------------------
 fs/cifs/inode.c    |   15 +++++----------
 4 files changed, 13 insertions(+), 38 deletions(-)

--- snip ---

fs/cifs/file.c int cifs_fsync(struct file *file, int datasync) · line 1636

Quoted 9 lines
fs/cifs/file.c +1 -3
@@ -1639,10 +1632,8 @@ int cifs_fsync(struct file *file, int datasync)
 
 	rc = filemap_write_and_wait(inode->i_mapping);
 	if (rc == 0) {
-		rc = CIFS_I(inode)->write_behind_rc;
-		CIFS_I(inode)->write_behind_rc = 0;
 		tcon = tlink_tcon(smbfile->tlink);
-		if (!rc && tcon && smbfile &&
+		if (rc == 0 &&

The above is redundant now, isn't it? We no longer set rc since the last test.

Quoted 3 lines
fs/cifs/file.c +0 -0
 		   !(CIFS_SB(inode->i_sb)->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC))
 			rc = CIFSSMBFlush(xid, tcon, smbfile->netfid);
 	}
Signature · 2 lines
Dave Kleikamp
IBM Linux Technology Center
#31 lore raw

Re: [PATCH 13/13] cifs: eliminate cifsInodeInfo->write_behind_rc

Quoted 22 lines · On Fri, 22 Oct 2010 13:11:30 -0500 Dave Kleikamp…
Quoted 8 lines · Jeff Layton

write_behind_rc is redundant and just adds complexity to the code. What we really want to do instead is to use mapping_set_error to reset the flags on the mapping when we find a writeback error and can't report it to userspace yet.

For cifs_flush and cifs_fsync, we shouldn't reset the flags since errors returned there do get reported to userspace.

Quoted 8 lines
---
 fs/cifs/cifsfs.c   |    1 -
 fs/cifs/cifsglob.h |    1 -
 fs/cifs/file.c     |   34 ++++++++--------------------------
 fs/cifs/inode.c    |   15 +++++----------
 4 files changed, 13 insertions(+), 38 deletions(-)

--- snip ---

Quoted 2 lines
(quoted diff) +0 -0
@@ -1639,10 +1632,8 @@ int cifs_fsync(struct file *file, int datasync)
 
Quoted 15 lines

fs/cifs/file.c int cifs_fsync(struct file *file, int datasync) · line 1636

Quoted 7 lines
fs/cifs/file.c +1 -3
 	rc = filemap_write_and_wait(inode->i_mapping);
 	if (rc == 0) {
-		rc = CIFS_I(inode)->write_behind_rc;
-		CIFS_I(inode)->write_behind_rc = 0;
 		tcon = tlink_tcon(smbfile->tlink);
-		if (!rc && tcon && smbfile &&
+		if (rc == 0 &&

The above is redundant now, isn't it? We no longer set rc since the last test.

Quoted 3 lines
fs/cifs/file.c +0 -0
 		   !(CIFS_SB(inode->i_sb)->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC))
 			rc = CIFSSMBFlush(xid, tcon, smbfile->netfid);
 	}

Yeah, duh. Good catch.

Steve, should I respin that one?

Signature · 1 line
Jeff Layton <[email protected]>