aboutsummaryrefslogtreecommitdiffstats
path: root/fs/locks.c
diff options
context:
space:
mode:
authorJ. Bruce Fields <bfields@redhat.com>2011-07-26 20:10:51 -0400
committerJ. Bruce Fields <bfields@redhat.com>2011-08-19 13:25:33 -0400
commitab83fa4b49a54e6199b076b7d8c1808144e80f0d (patch)
tree3c2d3a7449ac4ff78f8bbe310dcb637c68a4a071 /fs/locks.c
parentaadab6c6f4da38d639394de740602f146c88da0c (diff)
locks: minor lease cleanup
Use a helper function, to simplify upcoming changes. Reviewed-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/locks.c')
-rw-r--r--fs/locks.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/fs/locks.c b/fs/locks.c
index 703f545097de..c528522862b1 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -133,6 +133,11 @@
133#define IS_FLOCK(fl) (fl->fl_flags & FL_FLOCK) 133#define IS_FLOCK(fl) (fl->fl_flags & FL_FLOCK)
134#define IS_LEASE(fl) (fl->fl_flags & FL_LEASE) 134#define IS_LEASE(fl) (fl->fl_flags & FL_LEASE)
135 135
136static bool lease_breaking(struct file_lock *fl)
137{
138 return fl->fl_type & F_INPROGRESS;
139}
140
136int leases_enable = 1; 141int leases_enable = 1;
137int lease_break_time = 45; 142int lease_break_time = 45;
138 143
@@ -1141,7 +1146,7 @@ static void time_out_leases(struct inode *inode)
1141 struct file_lock *fl; 1146 struct file_lock *fl;
1142 1147
1143 before = &inode->i_flock; 1148 before = &inode->i_flock;
1144 while ((fl = *before) && IS_LEASE(fl) && (fl->fl_type & F_INPROGRESS)) { 1149 while ((fl = *before) && IS_LEASE(fl) && lease_breaking(fl)) {
1145 if ((fl->fl_break_time == 0) 1150 if ((fl->fl_break_time == 0)
1146 || time_before(jiffies, fl->fl_break_time)) { 1151 || time_before(jiffies, fl->fl_break_time)) {
1147 before = &fl->fl_next; 1152 before = &fl->fl_next;
@@ -1189,7 +1194,7 @@ int __break_lease(struct inode *inode, unsigned int mode)
1189 if (want_write) { 1194 if (want_write) {
1190 /* If we want write access, we have to revoke any lease. */ 1195 /* If we want write access, we have to revoke any lease. */
1191 future = F_UNLCK | F_INPROGRESS; 1196 future = F_UNLCK | F_INPROGRESS;
1192 } else if (flock->fl_type & F_INPROGRESS) { 1197 } else if (lease_breaking(flock)) {
1193 /* If the lease is already being broken, we just leave it */ 1198 /* If the lease is already being broken, we just leave it */
1194 future = flock->fl_type; 1199 future = flock->fl_type;
1195 } else if (flock->fl_type & F_WRLCK) { 1200 } else if (flock->fl_type & F_WRLCK) {
@@ -1246,7 +1251,7 @@ restart:
1246 /* Wait for the next lease that has not been broken yet */ 1251 /* Wait for the next lease that has not been broken yet */
1247 for (flock = inode->i_flock; flock && IS_LEASE(flock); 1252 for (flock = inode->i_flock; flock && IS_LEASE(flock);
1248 flock = flock->fl_next) { 1253 flock = flock->fl_next) {
1249 if (flock->fl_type & F_INPROGRESS) 1254 if (lease_breaking(flock))
1250 goto restart; 1255 goto restart;
1251 } 1256 }
1252 error = 0; 1257 error = 0;
@@ -2126,7 +2131,7 @@ static void lock_get_status(struct seq_file *f, struct file_lock *fl,
2126 } 2131 }
2127 } else if (IS_LEASE(fl)) { 2132 } else if (IS_LEASE(fl)) {
2128 seq_printf(f, "LEASE "); 2133 seq_printf(f, "LEASE ");
2129 if (fl->fl_type & F_INPROGRESS) 2134 if (lease_breaking(fl))
2130 seq_printf(f, "BREAKING "); 2135 seq_printf(f, "BREAKING ");
2131 else if (fl->fl_file) 2136 else if (fl->fl_file)
2132 seq_printf(f, "ACTIVE "); 2137 seq_printf(f, "ACTIVE ");
@@ -2142,7 +2147,7 @@ static void lock_get_status(struct seq_file *f, struct file_lock *fl,
2142 : (fl->fl_type & LOCK_WRITE) ? "WRITE" : "NONE "); 2147 : (fl->fl_type & LOCK_WRITE) ? "WRITE" : "NONE ");
2143 } else { 2148 } else {
2144 seq_printf(f, "%s ", 2149 seq_printf(f, "%s ",
2145 (fl->fl_type & F_INPROGRESS) 2150 (lease_breaking(fl))
2146 ? (fl->fl_type & F_UNLCK) ? "UNLCK" : "READ " 2151 ? (fl->fl_type & F_UNLCK) ? "UNLCK" : "READ "
2147 : (fl->fl_type & F_WRLCK) ? "WRITE" : "READ "); 2152 : (fl->fl_type & F_WRLCK) ? "WRITE" : "READ ");
2148 } 2153 }