aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Layton <jlayton@poochiereds.net>2014-04-30 09:31:45 -0400
committerSteve French <smfrench@gmail.com>2014-05-21 13:18:05 -0400
commitaff8d5ca7a3dca0bd6f6e86c9a85bf04941262ce (patch)
tree3bb10e19fa53334df6b7731a14e4cfb4bec82f35
parent02323db17e3a73dd335690b7b1a2392912b05513 (diff)
cifs: convert booleans in cifsInodeInfo to a flags field
In later patches, we'll need to have a bitlock, so go ahead and convert these bools to use atomic bitops instead. Also, clean up the initialization of the flags field. There's no need to unset each bit individually just after it was zeroed on allocation. Signed-off-by: Jeff Layton <jlayton@poochiereds.net> Signed-off-by: Steve French <smfrench@gmail.com>
-rw-r--r--fs/cifs/cifsfs.c6
-rw-r--r--fs/cifs/cifsglob.h6
-rw-r--r--fs/cifs/file.c4
-rw-r--r--fs/cifs/inode.c19
4 files changed, 17 insertions, 18 deletions
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 5be1f997ecde..3ef0299ed43e 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -251,11 +251,7 @@ cifs_alloc_inode(struct super_block *sb)
251 * server, can not assume caching of file data or metadata. 251 * server, can not assume caching of file data or metadata.
252 */ 252 */
253 cifs_set_oplock_level(cifs_inode, 0); 253 cifs_set_oplock_level(cifs_inode, 0);
254 cifs_inode->delete_pending = false; 254 cifs_inode->flags = 0;
255 cifs_inode->invalid_mapping = false;
256 clear_bit(CIFS_INODE_PENDING_OPLOCK_BREAK, &cifs_inode->flags);
257 clear_bit(CIFS_INODE_PENDING_WRITERS, &cifs_inode->flags);
258 clear_bit(CIFS_INODE_DOWNGRADE_OPLOCK_TO_L2, &cifs_inode->flags);
259 spin_lock_init(&cifs_inode->writers_lock); 255 spin_lock_init(&cifs_inode->writers_lock);
260 cifs_inode->writers = 0; 256 cifs_inode->writers = 0;
261 cifs_inode->vfs_inode.i_blkbits = 14; /* 2**14 = CIFS_MAX_MSGSIZE */ 257 cifs_inode->vfs_inode.i_blkbits = 14; /* 2**14 = CIFS_MAX_MSGSIZE */
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index 30f6e9251a4a..69da55b750e7 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -1113,12 +1113,12 @@ struct cifsInodeInfo {
1113 __u32 cifsAttrs; /* e.g. DOS archive bit, sparse, compressed, system */ 1113 __u32 cifsAttrs; /* e.g. DOS archive bit, sparse, compressed, system */
1114 unsigned int oplock; /* oplock/lease level we have */ 1114 unsigned int oplock; /* oplock/lease level we have */
1115 unsigned int epoch; /* used to track lease state changes */ 1115 unsigned int epoch; /* used to track lease state changes */
1116 bool delete_pending; /* DELETE_ON_CLOSE is set */
1117 bool invalid_mapping; /* pagecache is invalid */
1118 unsigned long flags;
1119#define CIFS_INODE_PENDING_OPLOCK_BREAK (0) /* oplock break in progress */ 1116#define CIFS_INODE_PENDING_OPLOCK_BREAK (0) /* oplock break in progress */
1120#define CIFS_INODE_PENDING_WRITERS (1) /* Writes in progress */ 1117#define CIFS_INODE_PENDING_WRITERS (1) /* Writes in progress */
1121#define CIFS_INODE_DOWNGRADE_OPLOCK_TO_L2 (2) /* Downgrade oplock to L2 */ 1118#define CIFS_INODE_DOWNGRADE_OPLOCK_TO_L2 (2) /* Downgrade oplock to L2 */
1119#define CIFS_INO_DELETE_PENDING (3) /* delete pending on server */
1120#define CIFS_INO_INVALID_MAPPING (4) /* pagecache is invalid */
1121 unsigned long flags;
1122 spinlock_t writers_lock; 1122 spinlock_t writers_lock;
1123 unsigned int writers; /* Number of writers on this inode */ 1123 unsigned int writers; /* Number of writers on this inode */
1124 unsigned long time; /* jiffies of last update of inode */ 1124 unsigned long time; /* jiffies of last update of inode */
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 5ed03e0b8b40..c8a570e87900 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -392,7 +392,7 @@ void cifsFileInfo_put(struct cifsFileInfo *cifs_file)
392 * again and get at least level II oplock. 392 * again and get at least level II oplock.
393 */ 393 */
394 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_STRICT_IO) 394 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_STRICT_IO)
395 CIFS_I(inode)->invalid_mapping = true; 395 set_bit(CIFS_INO_INVALID_MAPPING, &cifsi->flags);
396 cifs_set_oplock_level(cifsi, 0); 396 cifs_set_oplock_level(cifsi, 0);
397 } 397 }
398 spin_unlock(&cifs_file_list_lock); 398 spin_unlock(&cifs_file_list_lock);
@@ -2562,7 +2562,7 @@ ssize_t cifs_user_writev(struct kiocb *iocb, const struct iovec *iov,
2562 2562
2563 written = cifs_iovec_write(iocb->ki_filp, iov, nr_segs, &pos); 2563 written = cifs_iovec_write(iocb->ki_filp, iov, nr_segs, &pos);
2564 if (written > 0) { 2564 if (written > 0) {
2565 CIFS_I(inode)->invalid_mapping = true; 2565 set_bit(CIFS_INO_INVALID_MAPPING, &CIFS_I(inode)->flags);
2566 iocb->ki_pos = pos; 2566 iocb->ki_pos = pos;
2567 } 2567 }
2568 2568
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index a22d667f1069..fa9ef8d902b5 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -117,7 +117,7 @@ cifs_revalidate_cache(struct inode *inode, struct cifs_fattr *fattr)
117 117
118 cifs_dbg(FYI, "%s: invalidating inode %llu mapping\n", 118 cifs_dbg(FYI, "%s: invalidating inode %llu mapping\n",
119 __func__, cifs_i->uniqueid); 119 __func__, cifs_i->uniqueid);
120 cifs_i->invalid_mapping = true; 120 set_bit(CIFS_INO_INVALID_MAPPING, &cifs_i->flags);
121} 121}
122 122
123/* 123/*
@@ -177,7 +177,10 @@ cifs_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr)
177 else 177 else
178 cifs_i->time = jiffies; 178 cifs_i->time = jiffies;
179 179
180 cifs_i->delete_pending = fattr->cf_flags & CIFS_FATTR_DELETE_PENDING; 180 if (fattr->cf_flags & CIFS_FATTR_DELETE_PENDING)
181 set_bit(CIFS_INO_DELETE_PENDING, &cifs_i->flags);
182 else
183 clear_bit(CIFS_INO_DELETE_PENDING, &cifs_i->flags);
181 184
182 cifs_i->server_eof = fattr->cf_eof; 185 cifs_i->server_eof = fattr->cf_eof;
183 /* 186 /*
@@ -1121,7 +1124,7 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry,
1121 } 1124 }
1122 1125
1123 /* try to set DELETE_ON_CLOSE */ 1126 /* try to set DELETE_ON_CLOSE */
1124 if (!cifsInode->delete_pending) { 1127 if (!test_bit(CIFS_INO_DELETE_PENDING, &cifsInode->flags)) {
1125 rc = CIFSSMBSetFileDisposition(xid, tcon, true, fid.netfid, 1128 rc = CIFSSMBSetFileDisposition(xid, tcon, true, fid.netfid,
1126 current->tgid); 1129 current->tgid);
1127 /* 1130 /*
@@ -1138,7 +1141,7 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry,
1138 rc = -EBUSY; 1141 rc = -EBUSY;
1139 goto undo_rename; 1142 goto undo_rename;
1140 } 1143 }
1141 cifsInode->delete_pending = true; 1144 set_bit(CIFS_INO_DELETE_PENDING, &cifsInode->flags);
1142 } 1145 }
1143 1146
1144out_close: 1147out_close:
@@ -1761,14 +1764,14 @@ cifs_invalidate_mapping(struct inode *inode)
1761 int rc = 0; 1764 int rc = 0;
1762 struct cifsInodeInfo *cifs_i = CIFS_I(inode); 1765 struct cifsInodeInfo *cifs_i = CIFS_I(inode);
1763 1766
1764 cifs_i->invalid_mapping = false; 1767 clear_bit(CIFS_INO_INVALID_MAPPING, &cifs_i->flags);
1765 1768
1766 if (inode->i_mapping && inode->i_mapping->nrpages != 0) { 1769 if (inode->i_mapping && inode->i_mapping->nrpages != 0) {
1767 rc = invalidate_inode_pages2(inode->i_mapping); 1770 rc = invalidate_inode_pages2(inode->i_mapping);
1768 if (rc) { 1771 if (rc) {
1769 cifs_dbg(VFS, "%s: could not invalidate inode %p\n", 1772 cifs_dbg(VFS, "%s: could not invalidate inode %p\n",
1770 __func__, inode); 1773 __func__, inode);
1771 cifs_i->invalid_mapping = true; 1774 set_bit(CIFS_INO_INVALID_MAPPING, &cifs_i->flags);
1772 } 1775 }
1773 } 1776 }
1774 1777
@@ -1842,7 +1845,7 @@ int cifs_revalidate_file(struct file *filp)
1842 if (rc) 1845 if (rc)
1843 return rc; 1846 return rc;
1844 1847
1845 if (CIFS_I(inode)->invalid_mapping) 1848 if (test_bit(CIFS_INO_INVALID_MAPPING, &CIFS_I(inode)->flags))
1846 rc = cifs_invalidate_mapping(inode); 1849 rc = cifs_invalidate_mapping(inode);
1847 return rc; 1850 return rc;
1848} 1851}
@@ -1857,7 +1860,7 @@ int cifs_revalidate_dentry(struct dentry *dentry)
1857 if (rc) 1860 if (rc)
1858 return rc; 1861 return rc;
1859 1862
1860 if (CIFS_I(inode)->invalid_mapping) 1863 if (test_bit(CIFS_INO_INVALID_MAPPING, &CIFS_I(inode)->flags))
1861 rc = cifs_invalidate_mapping(inode); 1864 rc = cifs_invalidate_mapping(inode);
1862 return rc; 1865 return rc;
1863} 1866}