Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

9p: adapt to breakup of struct file_lock

Most of the existing APIs have remained the same, but subsystems that
access file_lock fields directly need to reach into struct
file_lock_core now.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Link: https://lore.kernel.org/r/20240131-flsplit-v3-34-c6129007ee8d@kernel.org
Reviewed-by: NeilBrown <neilb@suse.de>
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

Jeff Layton and committed by
Christian Brauner
459c814a a1c2af32

+19 -20
+19 -20
fs/9p/vfs_file.c
··· 9 9 #include <linux/module.h> 10 10 #include <linux/errno.h> 11 11 #include <linux/fs.h> 12 - #define _NEED_FILE_LOCK_FIELD_MACROS 13 12 #include <linux/filelock.h> 14 13 #include <linux/sched.h> 15 14 #include <linux/file.h> ··· 107 108 108 109 p9_debug(P9_DEBUG_VFS, "filp: %p lock: %p\n", filp, fl); 109 110 110 - if ((IS_SETLK(cmd) || IS_SETLKW(cmd)) && fl->fl_type != F_UNLCK) { 111 + if ((IS_SETLK(cmd) || IS_SETLKW(cmd)) && fl->c.flc_type != F_UNLCK) { 111 112 filemap_write_and_wait(inode->i_mapping); 112 113 invalidate_mapping_pages(&inode->i_data, 0, -1); 113 114 } ··· 126 127 fid = filp->private_data; 127 128 BUG_ON(fid == NULL); 128 129 129 - BUG_ON((fl->fl_flags & FL_POSIX) != FL_POSIX); 130 + BUG_ON((fl->c.flc_flags & FL_POSIX) != FL_POSIX); 130 131 131 132 res = locks_lock_file_wait(filp, fl); 132 133 if (res < 0) ··· 135 136 /* convert posix lock to p9 tlock args */ 136 137 memset(&flock, 0, sizeof(flock)); 137 138 /* map the lock type */ 138 - switch (fl->fl_type) { 139 + switch (fl->c.flc_type) { 139 140 case F_RDLCK: 140 141 flock.type = P9_LOCK_TYPE_RDLCK; 141 142 break; ··· 151 152 flock.length = 0; 152 153 else 153 154 flock.length = fl->fl_end - fl->fl_start + 1; 154 - flock.proc_id = fl->fl_pid; 155 + flock.proc_id = fl->c.flc_pid; 155 156 flock.client_id = fid->clnt->name; 156 157 if (IS_SETLKW(cmd)) 157 158 flock.flags = P9_LOCK_FLAGS_BLOCK; ··· 206 207 * incase server returned error for lock request, revert 207 208 * it locally 208 209 */ 209 - if (res < 0 && fl->fl_type != F_UNLCK) { 210 - unsigned char type = fl->fl_type; 210 + if (res < 0 && fl->c.flc_type != F_UNLCK) { 211 + unsigned char type = fl->c.flc_type; 211 212 212 - fl->fl_type = F_UNLCK; 213 + fl->c.flc_type = F_UNLCK; 213 214 /* Even if this fails we want to return the remote error */ 214 215 locks_lock_file_wait(filp, fl); 215 - fl->fl_type = type; 216 + fl->c.flc_type = type; 216 217 } 217 218 if (flock.client_id != fid->clnt->name) 218 219 kfree(flock.client_id); ··· 234 235 * if we have a conflicting lock locally, no need to validate 235 236 * with server 236 237 */ 237 - if (fl->fl_type != F_UNLCK) 238 + if (fl->c.flc_type != F_UNLCK) 238 239 return res; 239 240 240 241 /* convert posix lock to p9 tgetlock args */ ··· 245 246 glock.length = 0; 246 247 else 247 248 glock.length = fl->fl_end - fl->fl_start + 1; 248 - glock.proc_id = fl->fl_pid; 249 + glock.proc_id = fl->c.flc_pid; 249 250 glock.client_id = fid->clnt->name; 250 251 251 252 res = p9_client_getlock_dotl(fid, &glock); ··· 254 255 /* map 9p lock type to os lock type */ 255 256 switch (glock.type) { 256 257 case P9_LOCK_TYPE_RDLCK: 257 - fl->fl_type = F_RDLCK; 258 + fl->c.flc_type = F_RDLCK; 258 259 break; 259 260 case P9_LOCK_TYPE_WRLCK: 260 - fl->fl_type = F_WRLCK; 261 + fl->c.flc_type = F_WRLCK; 261 262 break; 262 263 case P9_LOCK_TYPE_UNLCK: 263 - fl->fl_type = F_UNLCK; 264 + fl->c.flc_type = F_UNLCK; 264 265 break; 265 266 } 266 267 if (glock.type != P9_LOCK_TYPE_UNLCK) { ··· 269 270 fl->fl_end = OFFSET_MAX; 270 271 else 271 272 fl->fl_end = glock.start + glock.length - 1; 272 - fl->fl_pid = -glock.proc_id; 273 + fl->c.flc_pid = -glock.proc_id; 273 274 } 274 275 out: 275 276 if (glock.client_id != fid->clnt->name) ··· 293 294 p9_debug(P9_DEBUG_VFS, "filp: %p cmd:%d lock: %p name: %pD\n", 294 295 filp, cmd, fl, filp); 295 296 296 - if ((IS_SETLK(cmd) || IS_SETLKW(cmd)) && fl->fl_type != F_UNLCK) { 297 + if ((IS_SETLK(cmd) || IS_SETLKW(cmd)) && fl->c.flc_type != F_UNLCK) { 297 298 filemap_write_and_wait(inode->i_mapping); 298 299 invalidate_mapping_pages(&inode->i_data, 0, -1); 299 300 } ··· 324 325 p9_debug(P9_DEBUG_VFS, "filp: %p cmd:%d lock: %p name: %pD\n", 325 326 filp, cmd, fl, filp); 326 327 327 - if (!(fl->fl_flags & FL_FLOCK)) 328 + if (!(fl->c.flc_flags & FL_FLOCK)) 328 329 goto out_err; 329 330 330 - if ((IS_SETLK(cmd) || IS_SETLKW(cmd)) && fl->fl_type != F_UNLCK) { 331 + if ((IS_SETLK(cmd) || IS_SETLKW(cmd)) && fl->c.flc_type != F_UNLCK) { 331 332 filemap_write_and_wait(inode->i_mapping); 332 333 invalidate_mapping_pages(&inode->i_data, 0, -1); 333 334 } 334 335 /* Convert flock to posix lock */ 335 - fl->fl_flags |= FL_POSIX; 336 - fl->fl_flags ^= FL_FLOCK; 336 + fl->c.flc_flags |= FL_POSIX; 337 + fl->c.flc_flags ^= FL_FLOCK; 337 338 338 339 if (IS_SETLK(cmd) | IS_SETLKW(cmd)) 339 340 ret = v9fs_file_do_lock(filp, cmd, fl);