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

Configure Feed

Select the types of activity you want to include in your feed.

debugfs: split short and full proxy wrappers, kill debugfs_real_fops()

All users outside of fs/debugfs/file.c are gone, in there we can just
fully split the wrappers for full and short cases and be done with that.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Link: https://lore.kernel.org/r/20250702212419.GG3406663@ZenIV
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Al Viro and committed by
Greg Kroah-Hartman
d9bc88aa 1c1ec6f0

+38 -51
+38 -49
fs/debugfs/file.c
··· 53 53 } 54 54 EXPORT_SYMBOL_GPL(debugfs_get_aux); 55 55 56 - const struct file_operations *debugfs_real_fops(const struct file *filp) 57 - { 58 - struct debugfs_fsdata *fsd = F_DENTRY(filp)->d_fsdata; 59 - 60 - if (!fsd) { 61 - /* 62 - * Urgh, we've been called w/o a protecting 63 - * debugfs_file_get(). 64 - */ 65 - WARN_ON(1); 66 - return NULL; 67 - } 68 - 69 - return fsd->real_fops; 70 - } 71 - EXPORT_SYMBOL_GPL(debugfs_real_fops); 72 - 73 56 enum dbgfs_get_mode { 74 57 DBGFS_GET_ALREADY, 75 58 DBGFS_GET_REGULAR, ··· 285 302 static int open_proxy_open(struct inode *inode, struct file *filp) 286 303 { 287 304 struct dentry *dentry = F_DENTRY(filp); 288 - const struct file_operations *real_fops = NULL; 305 + const struct file_operations *real_fops = DEBUGFS_I(inode)->real_fops; 289 306 int r; 290 307 291 308 r = __debugfs_file_get(dentry, DBGFS_GET_REGULAR); 292 309 if (r) 293 310 return r == -EIO ? -ENOENT : r; 294 - 295 - real_fops = debugfs_real_fops(filp); 296 311 297 312 r = debugfs_locked_down(inode, filp, real_fops); 298 313 if (r) ··· 333 352 { \ 334 353 struct dentry *dentry = F_DENTRY(filp); \ 335 354 struct debugfs_fsdata *fsd = dentry->d_fsdata; \ 336 - const struct file_operations *real_fops; \ 337 355 ret_type r; \ 338 356 \ 339 357 if (!(fsd->methods & bit)) \ ··· 340 360 r = debugfs_file_get(dentry); \ 341 361 if (unlikely(r)) \ 342 362 return r; \ 343 - real_fops = debugfs_real_fops(filp); \ 344 - r = real_fops->name(args); \ 363 + r = fsd->real_fops->name(args); \ 345 364 debugfs_file_put(dentry); \ 346 365 return r; \ 347 366 } 348 367 349 - #define FULL_PROXY_FUNC_BOTH(name, ret_type, filp, proto, args, bit, ret) \ 350 - static ret_type full_proxy_ ## name(proto) \ 368 + #define SHORT_PROXY_FUNC(name, ret_type, filp, proto, args, bit, ret) \ 369 + static ret_type short_proxy_ ## name(proto) \ 351 370 { \ 352 371 struct dentry *dentry = F_DENTRY(filp); \ 353 372 struct debugfs_fsdata *fsd = dentry->d_fsdata; \ ··· 357 378 r = debugfs_file_get(dentry); \ 358 379 if (unlikely(r)) \ 359 380 return r; \ 360 - if (fsd->real_fops) \ 361 - r = fsd->real_fops->name(args); \ 362 - else \ 363 - r = fsd->short_fops->name(args); \ 381 + r = fsd->short_fops->name(args); \ 364 382 debugfs_file_put(dentry); \ 365 383 return r; \ 366 384 } 367 385 368 - FULL_PROXY_FUNC_BOTH(llseek, loff_t, filp, 369 - PROTO(struct file *filp, loff_t offset, int whence), 370 - ARGS(filp, offset, whence), HAS_LSEEK, -ESPIPE); 386 + SHORT_PROXY_FUNC(llseek, loff_t, filp, 387 + PROTO(struct file *filp, loff_t offset, int whence), 388 + ARGS(filp, offset, whence), HAS_LSEEK, -ESPIPE); 371 389 372 - FULL_PROXY_FUNC_BOTH(read, ssize_t, filp, 373 - PROTO(struct file *filp, char __user *buf, size_t size, 374 - loff_t *ppos), 375 - ARGS(filp, buf, size, ppos), HAS_READ, -EINVAL); 390 + FULL_PROXY_FUNC(llseek, loff_t, filp, 391 + PROTO(struct file *filp, loff_t offset, int whence), 392 + ARGS(filp, offset, whence), HAS_LSEEK, -ESPIPE); 376 393 377 - FULL_PROXY_FUNC_BOTH(write, ssize_t, filp, 378 - PROTO(struct file *filp, const char __user *buf, 379 - size_t size, loff_t *ppos), 380 - ARGS(filp, buf, size, ppos), HAS_WRITE, -EINVAL); 394 + SHORT_PROXY_FUNC(read, ssize_t, filp, 395 + PROTO(struct file *filp, char __user *buf, size_t size, 396 + loff_t *ppos), 397 + ARGS(filp, buf, size, ppos), HAS_READ, -EINVAL); 398 + 399 + FULL_PROXY_FUNC(read, ssize_t, filp, 400 + PROTO(struct file *filp, char __user *buf, size_t size, 401 + loff_t *ppos), 402 + ARGS(filp, buf, size, ppos), HAS_READ, -EINVAL); 403 + 404 + SHORT_PROXY_FUNC(write, ssize_t, filp, 405 + PROTO(struct file *filp, const char __user *buf, 406 + size_t size, loff_t *ppos), 407 + ARGS(filp, buf, size, ppos), HAS_WRITE, -EINVAL); 408 + 409 + FULL_PROXY_FUNC(write, ssize_t, filp, 410 + PROTO(struct file *filp, const char __user *buf, 411 + size_t size, loff_t *ppos), 412 + ARGS(filp, buf, size, ppos), HAS_WRITE, -EINVAL); 381 413 382 414 FULL_PROXY_FUNC(unlocked_ioctl, long, filp, 383 415 PROTO(struct file *filp, unsigned int cmd, unsigned long arg), ··· 400 410 struct dentry *dentry = F_DENTRY(filp); 401 411 struct debugfs_fsdata *fsd = dentry->d_fsdata; 402 412 __poll_t r = 0; 403 - const struct file_operations *real_fops; 404 413 405 414 if (!(fsd->methods & HAS_POLL)) 406 415 return DEFAULT_POLLMASK; 407 416 if (debugfs_file_get(dentry)) 408 417 return EPOLLHUP; 409 418 410 - real_fops = debugfs_real_fops(filp); 411 - r = real_fops->poll(filp, wait); 419 + r = fsd->real_fops->poll(filp, wait); 412 420 debugfs_file_put(dentry); 413 421 return r; 414 422 } 415 423 416 - static int full_proxy_release(struct inode *inode, struct file *filp) 424 + static int full_proxy_release(struct inode *inode, struct file *file) 417 425 { 418 - const struct file_operations *real_fops = debugfs_real_fops(filp); 426 + struct debugfs_fsdata *fsd = F_DENTRY(file)->d_fsdata; 427 + const struct file_operations *real_fops = fsd->real_fops; 419 428 int r = 0; 420 429 421 430 /* ··· 424 435 * ->i_private is still being meaningful here. 425 436 */ 426 437 if (real_fops->release) 427 - r = real_fops->release(inode, filp); 438 + r = real_fops->release(inode, file); 428 439 429 440 fops_put(real_fops); 430 441 return r; ··· 506 517 507 518 const struct file_operations debugfs_full_short_proxy_file_operations = { 508 519 .open = full_proxy_open_short, 509 - .llseek = full_proxy_llseek, 510 - .read = full_proxy_read, 511 - .write = full_proxy_write, 520 + .llseek = short_proxy_llseek, 521 + .read = short_proxy_read, 522 + .write = short_proxy_write, 512 523 }; 513 524 514 525 ssize_t debugfs_attr_read(struct file *file, char __user *buf,
-2
include/linux/debugfs.h
··· 162 162 163 163 void debugfs_lookup_and_remove(const char *name, struct dentry *parent); 164 164 165 - const struct file_operations *debugfs_real_fops(const struct file *filp); 166 165 const void *debugfs_get_aux(const struct file *file); 167 166 168 167 int debugfs_file_get(struct dentry *dentry); ··· 328 329 struct dentry *parent) 329 330 { } 330 331 331 - const struct file_operations *debugfs_real_fops(const struct file *filp); 332 332 void *debugfs_get_aux(const struct file *file); 333 333 334 334 static inline int debugfs_file_get(struct dentry *dentry)