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

Merge tag 'for-linus-4.16' of git://git.kernel.org/pub/scm/linux/kernel/git/hubcap/linux

Pull orangefs updates from Mike Marshall:
"Mostly cleanups, but three bug fixes:

- don't pass garbage return codes back up the call chain (Mike
Marshall)

- fix stale inode test (Martin Brandenburg)

- fix off-by-one errors (Xiongfeng Wang)

Also add Martin as a reviewer in the Maintainers file"

* tag 'for-linus-4.16' of git://git.kernel.org/pub/scm/linux/kernel/git/hubcap/linux:
orangefs: reverse sense of is-inode-stale test in d_revalidate
orangefs: simplify orangefs_inode_is_stale
Orangefs: don't propogate whacky error codes
orangefs: use correct string length
orangefs: make orangefs_make_bad_inode static
orangefs: remove ORANGEFS_KERNEL_DEBUG
orangefs: remove gossip_ldebug and gossip_lerr
orangefs: make orangefs_client_debug_init static
MAINTAINERS: update orangefs list and add myself as reviewer

+76 -93
+2 -1
MAINTAINERS
··· 10331 10331 10332 10332 ORANGEFS FILESYSTEM 10333 10333 M: Mike Marshall <hubcap@omnibond.com> 10334 - L: pvfs2-developers@beowulf-underground.org (subscribers-only) 10334 + R: Martin Brandenburg <martin@omnibond.com> 10335 + L: devel@lists.orangefs.org 10335 10336 T: git git://git.kernel.org/pub/scm/linux/kernel/git/hubcap/linux.git 10336 10337 S: Supported 10337 10338 F: fs/orangefs/
+8 -11
fs/orangefs/dcache.c
··· 33 33 new_op->upcall.req.lookup.parent_refn = parent->refn; 34 34 strncpy(new_op->upcall.req.lookup.d_name, 35 35 dentry->d_name.name, 36 - ORANGEFS_NAME_MAX); 36 + ORANGEFS_NAME_MAX - 1); 37 37 38 38 gossip_debug(GOSSIP_DCACHE_DEBUG, 39 39 "%s:%s:%d interrupt flag [%d]\n", ··· 118 118 return 0; 119 119 120 120 /* We do not need to continue with negative dentries. */ 121 - if (!dentry->d_inode) 122 - goto out; 121 + if (!dentry->d_inode) { 122 + gossip_debug(GOSSIP_DCACHE_DEBUG, 123 + "%s: negative dentry or positive dentry and inode valid.\n", 124 + __func__); 125 + return 1; 126 + } 123 127 124 128 /* Now we must perform a getattr to validate the inode contents. */ 125 129 ··· 133 129 __FILE__, __func__, __LINE__); 134 130 return 0; 135 131 } 136 - if (ret == 0) 137 - return 0; 138 - 139 - out: 140 - gossip_debug(GOSSIP_DCACHE_DEBUG, 141 - "%s: negative dentry or positive dentry and inode valid.\n", 142 - __func__); 143 - return 1; 132 + return !ret; 144 133 } 145 134 146 135 const struct dentry_operations orangefs_dentry_operations = {
+8 -8
fs/orangefs/namei.c
··· 41 41 ORANGEFS_TYPE_METAFILE, mode); 42 42 43 43 strncpy(new_op->upcall.req.create.d_name, 44 - dentry->d_name.name, ORANGEFS_NAME_MAX); 44 + dentry->d_name.name, ORANGEFS_NAME_MAX - 1); 45 45 46 46 ret = service_operation(new_op, __func__, get_interruptible_flag(dir)); 47 47 ··· 142 142 new_op->upcall.req.lookup.parent_refn = parent->refn; 143 143 144 144 strncpy(new_op->upcall.req.lookup.d_name, dentry->d_name.name, 145 - ORANGEFS_NAME_MAX); 145 + ORANGEFS_NAME_MAX - 1); 146 146 147 147 gossip_debug(GOSSIP_NAME_DEBUG, 148 148 "%s: doing lookup on %s under %pU,%d\n", ··· 244 244 245 245 new_op->upcall.req.remove.parent_refn = parent->refn; 246 246 strncpy(new_op->upcall.req.remove.d_name, dentry->d_name.name, 247 - ORANGEFS_NAME_MAX); 247 + ORANGEFS_NAME_MAX - 1); 248 248 249 249 ret = service_operation(new_op, "orangefs_unlink", 250 250 get_interruptible_flag(inode)); ··· 300 300 301 301 strncpy(new_op->upcall.req.sym.entry_name, 302 302 dentry->d_name.name, 303 - ORANGEFS_NAME_MAX); 304 - strncpy(new_op->upcall.req.sym.target, symname, ORANGEFS_NAME_MAX); 303 + ORANGEFS_NAME_MAX - 1); 304 + strncpy(new_op->upcall.req.sym.target, symname, ORANGEFS_NAME_MAX - 1); 305 305 306 306 ret = service_operation(new_op, __func__, get_interruptible_flag(dir)); 307 307 ··· 372 372 ORANGEFS_TYPE_DIRECTORY, mode); 373 373 374 374 strncpy(new_op->upcall.req.mkdir.d_name, 375 - dentry->d_name.name, ORANGEFS_NAME_MAX); 375 + dentry->d_name.name, ORANGEFS_NAME_MAX - 1); 376 376 377 377 ret = service_operation(new_op, __func__, get_interruptible_flag(dir)); 378 378 ··· 453 453 454 454 strncpy(new_op->upcall.req.rename.d_old_name, 455 455 old_dentry->d_name.name, 456 - ORANGEFS_NAME_MAX); 456 + ORANGEFS_NAME_MAX - 1); 457 457 strncpy(new_op->upcall.req.rename.d_new_name, 458 458 new_dentry->d_name.name, 459 - ORANGEFS_NAME_MAX); 459 + ORANGEFS_NAME_MAX - 1); 460 460 461 461 ret = service_operation(new_op, 462 462 "orangefs_rename",
+2 -2
fs/orangefs/orangefs-debugfs.c
··· 328 328 /* 329 329 * initialize the client-debug file. 330 330 */ 331 - int orangefs_client_debug_init(void) 331 + static int orangefs_client_debug_init(void) 332 332 { 333 333 334 334 int rc = -ENOMEM; ··· 1056 1056 client_debug_string, 1057 1057 llu(mask_info.mask_value)); 1058 1058 } else { 1059 - gossip_lerr("Invalid mask type....\n"); 1059 + gossip_err("Invalid mask type....\n"); 1060 1060 return -EINVAL; 1061 1061 } 1062 1062
-1
fs/orangefs/orangefs-debugfs.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 */ 2 2 int orangefs_debugfs_init(int); 3 3 void orangefs_debugfs_cleanup(void); 4 - int orangefs_client_debug_init(void); 5 4 int orangefs_prepare_debugfs_help_string(int); 6 5 int orangefs_debugfs_new_client_mask(void __user *); 7 6 int orangefs_debugfs_new_client_string(void __user *);
+2 -8
fs/orangefs/orangefs-kernel.h
··· 56 56 57 57 #include "orangefs-dev-proto.h" 58 58 59 - #ifdef ORANGEFS_KERNEL_DEBUG 60 - #define ORANGEFS_DEFAULT_OP_TIMEOUT_SECS 10 61 - #else 62 59 #define ORANGEFS_DEFAULT_OP_TIMEOUT_SECS 20 63 - #endif 64 60 65 61 #define ORANGEFS_BUFMAP_WAIT_TIMEOUT_SECS 30 66 62 ··· 100 104 * orangefs kernel memory related flags 101 105 */ 102 106 103 - #if ((defined ORANGEFS_KERNEL_DEBUG) && (defined CONFIG_DEBUG_SLAB)) 107 + #if (defined CONFIG_DEBUG_SLAB) 104 108 #define ORANGEFS_CACHE_CREATE_FLAGS SLAB_RED_ZONE 105 109 #else 106 110 #define ORANGEFS_CACHE_CREATE_FLAGS 0 107 - #endif /* ((defined ORANGEFS_KERNEL_DEBUG) && (defined CONFIG_DEBUG_SLAB)) */ 111 + #endif 108 112 109 113 extern int orangefs_init_acl(struct inode *inode, struct inode *dir); 110 114 extern const struct xattr_handler *orangefs_xattr_handlers[]; ··· 466 470 int orangefs_inode_check_changed(struct inode *inode); 467 471 468 472 int orangefs_inode_setattr(struct inode *inode, struct iattr *iattr); 469 - 470 - void orangefs_make_bad_inode(struct inode *inode); 471 473 472 474 int orangefs_unmount_sb(struct super_block *sb); 473 475
+50 -43
fs/orangefs/orangefs-utils.c
··· 230 230 return -1; 231 231 } 232 232 233 - static int orangefs_inode_is_stale(struct inode *inode, int new, 233 + static void orangefs_make_bad_inode(struct inode *inode) 234 + { 235 + if (is_root_handle(inode)) { 236 + /* 237 + * if this occurs, the pvfs2-client-core was killed but we 238 + * can't afford to lose the inode operations and such 239 + * associated with the root handle in any case. 240 + */ 241 + gossip_debug(GOSSIP_UTILS_DEBUG, 242 + "*** NOT making bad root inode %pU\n", 243 + get_khandle_from_ino(inode)); 244 + } else { 245 + gossip_debug(GOSSIP_UTILS_DEBUG, 246 + "*** making bad inode %pU\n", 247 + get_khandle_from_ino(inode)); 248 + make_bad_inode(inode); 249 + } 250 + } 251 + 252 + static int orangefs_inode_is_stale(struct inode *inode, 234 253 struct ORANGEFS_sys_attr_s *attrs, char *link_target) 235 254 { 236 255 struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode); 237 256 int type = orangefs_inode_type(attrs->objtype); 238 - if (!new) { 239 - /* 240 - * If the inode type or symlink target have changed then this 241 - * inode is stale. 242 - */ 243 - if (type == -1 || !(inode->i_mode & type)) { 244 - orangefs_make_bad_inode(inode); 245 - return 1; 246 - } 247 - if (type == S_IFLNK && strncmp(orangefs_inode->link_target, 248 - link_target, ORANGEFS_NAME_MAX)) { 249 - orangefs_make_bad_inode(inode); 250 - return 1; 251 - } 257 + /* 258 + * If the inode type or symlink target have changed then this 259 + * inode is stale. 260 + */ 261 + if (type == -1 || !(inode->i_mode & type)) { 262 + orangefs_make_bad_inode(inode); 263 + return 1; 264 + } 265 + if (type == S_IFLNK && strncmp(orangefs_inode->link_target, 266 + link_target, ORANGEFS_NAME_MAX)) { 267 + orangefs_make_bad_inode(inode); 268 + return 1; 252 269 } 253 270 return 0; 254 271 } ··· 311 294 if (ret != 0) 312 295 goto out; 313 296 314 - type = orangefs_inode_type(new_op-> 315 - downcall.resp.getattr.attributes.objtype); 316 - ret = orangefs_inode_is_stale(inode, new, 317 - &new_op->downcall.resp.getattr.attributes, 318 - new_op->downcall.resp.getattr.link_target); 319 - if (ret) { 320 - ret = -ESTALE; 321 - goto out; 297 + if (!new) { 298 + ret = orangefs_inode_is_stale(inode, 299 + &new_op->downcall.resp.getattr.attributes, 300 + new_op->downcall.resp.getattr.link_target); 301 + if (ret) { 302 + ret = -ESTALE; 303 + goto out; 304 + } 322 305 } 323 306 307 + type = orangefs_inode_type(new_op-> 308 + downcall.resp.getattr.attributes.objtype); 324 309 switch (type) { 325 310 case S_IFREG: 326 311 inode->i_flags = orangefs_inode_flags(&new_op-> ··· 367 348 inode->i_link = orangefs_inode->link_target; 368 349 } 369 350 break; 351 + /* i.e. -1 */ 352 + default: 353 + /* XXX: ESTALE? This is what is done if it is not new. */ 354 + orangefs_make_bad_inode(inode); 355 + ret = -ESTALE; 356 + goto out; 370 357 } 371 358 372 359 inode->i_uid = make_kuid(&init_user_ns, new_op-> ··· 426 401 if (ret != 0) 427 402 goto out; 428 403 429 - ret = orangefs_inode_is_stale(inode, 0, 404 + ret = orangefs_inode_is_stale(inode, 430 405 &new_op->downcall.resp.getattr.attributes, 431 406 new_op->downcall.resp.getattr.link_target); 432 407 out: ··· 467 442 orangefs_inode->getattr_time = jiffies - 1; 468 443 469 444 return ret; 470 - } 471 - 472 - void orangefs_make_bad_inode(struct inode *inode) 473 - { 474 - if (is_root_handle(inode)) { 475 - /* 476 - * if this occurs, the pvfs2-client-core was killed but we 477 - * can't afford to lose the inode operations and such 478 - * associated with the root handle in any case. 479 - */ 480 - gossip_debug(GOSSIP_UTILS_DEBUG, 481 - "*** NOT making bad root inode %pU\n", 482 - get_khandle_from_ino(inode)); 483 - } else { 484 - gossip_debug(GOSSIP_UTILS_DEBUG, 485 - "*** making bad inode %pU\n", 486 - get_khandle_from_ino(inode)); 487 - make_bad_inode(inode); 488 - } 489 445 } 490 446 491 447 /* ··· 543 537 */ 544 538 } else { 545 539 gossip_err("orangefs: orangefs_normalize_to_errno: got error code which is not from ORANGEFS.\n"); 540 + error_code = -EINVAL; 546 541 } 547 542 return error_code; 548 543 }
-15
fs/orangefs/protocol.h
··· 395 395 396 396 /* gossip.h *****************************************************************/ 397 397 398 - #ifdef GOSSIP_DISABLE_DEBUG 399 - #define gossip_debug(mask, fmt, ...) \ 400 - do { \ 401 - if (0) \ 402 - printk(KERN_DEBUG fmt, ##__VA_ARGS__); \ 403 - } while (0) 404 - #else 405 398 extern __u64 orangefs_gossip_debug_mask; 406 399 407 400 /* try to avoid function call overhead by checking masks in macro */ ··· 403 410 if (orangefs_gossip_debug_mask & (mask)) \ 404 411 printk(KERN_DEBUG fmt, ##__VA_ARGS__); \ 405 412 } while (0) 406 - #endif /* GOSSIP_DISABLE_DEBUG */ 407 - 408 - /* do file and line number printouts w/ the GNU preprocessor */ 409 - #define gossip_ldebug(mask, fmt, ...) \ 410 - gossip_debug(mask, "%s: " fmt, __func__, ##__VA_ARGS__) 411 413 412 414 #define gossip_err pr_err 413 - #define gossip_lerr(fmt, ...) \ 414 - gossip_err("%s line %d: " fmt, \ 415 - __FILE__, __LINE__, ##__VA_ARGS__)
+4 -4
fs/orangefs/super.c
··· 335 335 struct orangefs_object_kref refn; 336 336 337 337 if (*max_len < len) { 338 - gossip_lerr("fh buffer is too small for encoding\n"); 338 + gossip_err("fh buffer is too small for encoding\n"); 339 339 *max_len = len; 340 340 type = 255; 341 341 goto out; ··· 383 383 op->upcall.req.fs_umount.id = id; 384 384 op->upcall.req.fs_umount.fs_id = fs_id; 385 385 strncpy(op->upcall.req.fs_umount.orangefs_config_server, 386 - devname, ORANGEFS_MAX_SERVER_ADDR_LEN); 386 + devname, ORANGEFS_MAX_SERVER_ADDR_LEN - 1); 387 387 r = service_operation(op, "orangefs_fs_umount", 0); 388 388 /* Not much to do about an error here. */ 389 389 if (r) ··· 478 478 479 479 strncpy(new_op->upcall.req.fs_mount.orangefs_config_server, 480 480 devname, 481 - ORANGEFS_MAX_SERVER_ADDR_LEN); 481 + ORANGEFS_MAX_SERVER_ADDR_LEN - 1); 482 482 483 483 gossip_debug(GOSSIP_SUPER_DEBUG, 484 484 "Attempting ORANGEFS Mount via host %s\n", ··· 520 520 */ 521 521 strncpy(ORANGEFS_SB(sb)->devname, 522 522 devname, 523 - ORANGEFS_MAX_SERVER_ADDR_LEN); 523 + ORANGEFS_MAX_SERVER_ADDR_LEN - 1); 524 524 525 525 /* mount_pending must be cleared */ 526 526 ORANGEFS_SB(sb)->mount_pending = 0;