Skip to content

Commit a0f7938

Browse files
committed
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
2 parents 8115333 + 74e938c commit a0f7938

File tree

9 files changed

+76
-93
lines changed

9 files changed

+76
-93
lines changed

MAINTAINERS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10331,7 +10331,8 @@ F: fs/ocfs2/
1033110331

1033210332
ORANGEFS FILESYSTEM
1033310333
M: Mike Marshall <[email protected]>
10334-
L: [email protected] (subscribers-only)
10334+
R: Martin Brandenburg <[email protected]>
10335+
1033510336
T: git git://git.kernel.org/pub/scm/linux/kernel/git/hubcap/linux.git
1033610337
S: Supported
1033710338
F: fs/orangefs/

fs/orangefs/dcache.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static int orangefs_revalidate_lookup(struct dentry *dentry)
3333
new_op->upcall.req.lookup.parent_refn = parent->refn;
3434
strncpy(new_op->upcall.req.lookup.d_name,
3535
dentry->d_name.name,
36-
ORANGEFS_NAME_MAX);
36+
ORANGEFS_NAME_MAX - 1);
3737

3838
gossip_debug(GOSSIP_DCACHE_DEBUG,
3939
"%s:%s:%d interrupt flag [%d]\n",
@@ -118,8 +118,12 @@ static int orangefs_d_revalidate(struct dentry *dentry, unsigned int flags)
118118
return 0;
119119

120120
/* 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+
}
123127

124128
/* Now we must perform a getattr to validate the inode contents. */
125129

@@ -129,14 +133,7 @@ static int orangefs_d_revalidate(struct dentry *dentry, unsigned int flags)
129133
__FILE__, __func__, __LINE__);
130134
return 0;
131135
}
132-
if (ret == 0)
133-
return 0;
134-
135-
out:
136-
gossip_debug(GOSSIP_DCACHE_DEBUG,
137-
"%s: negative dentry or positive dentry and inode valid.\n",
138-
__func__);
139-
return 1;
136+
return !ret;
140137
}
141138

142139
const struct dentry_operations orangefs_dentry_operations = {

fs/orangefs/namei.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ static int orangefs_create(struct inode *dir,
4141
ORANGEFS_TYPE_METAFILE, mode);
4242

4343
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);
4545

4646
ret = service_operation(new_op, __func__, get_interruptible_flag(dir));
4747

@@ -142,7 +142,7 @@ static struct dentry *orangefs_lookup(struct inode *dir, struct dentry *dentry,
142142
new_op->upcall.req.lookup.parent_refn = parent->refn;
143143

144144
strncpy(new_op->upcall.req.lookup.d_name, dentry->d_name.name,
145-
ORANGEFS_NAME_MAX);
145+
ORANGEFS_NAME_MAX - 1);
146146

147147
gossip_debug(GOSSIP_NAME_DEBUG,
148148
"%s: doing lookup on %s under %pU,%d\n",
@@ -244,7 +244,7 @@ static int orangefs_unlink(struct inode *dir, struct dentry *dentry)
244244

245245
new_op->upcall.req.remove.parent_refn = parent->refn;
246246
strncpy(new_op->upcall.req.remove.d_name, dentry->d_name.name,
247-
ORANGEFS_NAME_MAX);
247+
ORANGEFS_NAME_MAX - 1);
248248

249249
ret = service_operation(new_op, "orangefs_unlink",
250250
get_interruptible_flag(inode));
@@ -300,8 +300,8 @@ static int orangefs_symlink(struct inode *dir,
300300

301301
strncpy(new_op->upcall.req.sym.entry_name,
302302
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);
305305

306306
ret = service_operation(new_op, __func__, get_interruptible_flag(dir));
307307

@@ -372,7 +372,7 @@ static int orangefs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode
372372
ORANGEFS_TYPE_DIRECTORY, mode);
373373

374374
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);
376376

377377
ret = service_operation(new_op, __func__, get_interruptible_flag(dir));
378378

@@ -453,10 +453,10 @@ static int orangefs_rename(struct inode *old_dir,
453453

454454
strncpy(new_op->upcall.req.rename.d_old_name,
455455
old_dentry->d_name.name,
456-
ORANGEFS_NAME_MAX);
456+
ORANGEFS_NAME_MAX - 1);
457457
strncpy(new_op->upcall.req.rename.d_new_name,
458458
new_dentry->d_name.name,
459-
ORANGEFS_NAME_MAX);
459+
ORANGEFS_NAME_MAX - 1);
460460

461461
ret = service_operation(new_op,
462462
"orangefs_rename",

fs/orangefs/orangefs-debugfs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ static int help_show(struct seq_file *m, void *v)
328328
/*
329329
* initialize the client-debug file.
330330
*/
331-
int orangefs_client_debug_init(void)
331+
static int orangefs_client_debug_init(void)
332332
{
333333

334334
int rc = -ENOMEM;
@@ -1056,7 +1056,7 @@ int orangefs_debugfs_new_debug(void __user *arg)
10561056
client_debug_string,
10571057
llu(mask_info.mask_value));
10581058
} else {
1059-
gossip_lerr("Invalid mask type....\n");
1059+
gossip_err("Invalid mask type....\n");
10601060
return -EINVAL;
10611061
}
10621062

fs/orangefs/orangefs-debugfs.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/* SPDX-License-Identifier: GPL-2.0 */
22
int orangefs_debugfs_init(int);
33
void orangefs_debugfs_cleanup(void);
4-
int orangefs_client_debug_init(void);
54
int orangefs_prepare_debugfs_help_string(int);
65
int orangefs_debugfs_new_client_mask(void __user *);
76
int orangefs_debugfs_new_client_string(void __user *);

fs/orangefs/orangefs-kernel.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,7 @@
5656

5757
#include "orangefs-dev-proto.h"
5858

59-
#ifdef ORANGEFS_KERNEL_DEBUG
60-
#define ORANGEFS_DEFAULT_OP_TIMEOUT_SECS 10
61-
#else
6259
#define ORANGEFS_DEFAULT_OP_TIMEOUT_SECS 20
63-
#endif
6460

6561
#define ORANGEFS_BUFMAP_WAIT_TIMEOUT_SECS 30
6662

@@ -104,11 +100,11 @@ enum orangefs_vfs_op_states {
104100
* orangefs kernel memory related flags
105101
*/
106102

107-
#if ((defined ORANGEFS_KERNEL_DEBUG) && (defined CONFIG_DEBUG_SLAB))
103+
#if (defined CONFIG_DEBUG_SLAB)
108104
#define ORANGEFS_CACHE_CREATE_FLAGS SLAB_RED_ZONE
109105
#else
110106
#define ORANGEFS_CACHE_CREATE_FLAGS 0
111-
#endif /* ((defined ORANGEFS_KERNEL_DEBUG) && (defined CONFIG_DEBUG_SLAB)) */
107+
#endif
112108

113109
extern int orangefs_init_acl(struct inode *inode, struct inode *dir);
114110
extern const struct xattr_handler *orangefs_xattr_handlers[];
@@ -471,8 +467,6 @@ int orangefs_inode_check_changed(struct inode *inode);
471467

472468
int orangefs_inode_setattr(struct inode *inode, struct iattr *iattr);
473469

474-
void orangefs_make_bad_inode(struct inode *inode);
475-
476470
int orangefs_unmount_sb(struct super_block *sb);
477471

478472
bool orangefs_cancel_op_in_progress(struct orangefs_kernel_op_s *op);

fs/orangefs/orangefs-utils.c

Lines changed: 50 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -230,25 +230,42 @@ static int orangefs_inode_type(enum orangefs_ds_type objtype)
230230
return -1;
231231
}
232232

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,
234253
struct ORANGEFS_sys_attr_s *attrs, char *link_target)
235254
{
236255
struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode);
237256
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;
252269
}
253270
return 0;
254271
}
@@ -294,16 +311,18 @@ int orangefs_inode_getattr(struct inode *inode, int new, int bypass,
294311
if (ret != 0)
295312
goto out;
296313

297-
type = orangefs_inode_type(new_op->
298-
downcall.resp.getattr.attributes.objtype);
299-
ret = orangefs_inode_is_stale(inode, new,
300-
&new_op->downcall.resp.getattr.attributes,
301-
new_op->downcall.resp.getattr.link_target);
302-
if (ret) {
303-
ret = -ESTALE;
304-
goto out;
314+
if (!new) {
315+
ret = orangefs_inode_is_stale(inode,
316+
&new_op->downcall.resp.getattr.attributes,
317+
new_op->downcall.resp.getattr.link_target);
318+
if (ret) {
319+
ret = -ESTALE;
320+
goto out;
321+
}
305322
}
306323

324+
type = orangefs_inode_type(new_op->
325+
downcall.resp.getattr.attributes.objtype);
307326
switch (type) {
308327
case S_IFREG:
309328
inode->i_flags = orangefs_inode_flags(&new_op->
@@ -348,6 +367,12 @@ int orangefs_inode_getattr(struct inode *inode, int new, int bypass,
348367
inode->i_link = orangefs_inode->link_target;
349368
}
350369
break;
370+
/* i.e. -1 */
371+
default:
372+
/* XXX: ESTALE? This is what is done if it is not new. */
373+
orangefs_make_bad_inode(inode);
374+
ret = -ESTALE;
375+
goto out;
351376
}
352377

353378
inode->i_uid = make_kuid(&init_user_ns, new_op->
@@ -401,7 +426,7 @@ int orangefs_inode_check_changed(struct inode *inode)
401426
if (ret != 0)
402427
goto out;
403428

404-
ret = orangefs_inode_is_stale(inode, 0,
429+
ret = orangefs_inode_is_stale(inode,
405430
&new_op->downcall.resp.getattr.attributes,
406431
new_op->downcall.resp.getattr.link_target);
407432
out:
@@ -444,25 +469,6 @@ int orangefs_inode_setattr(struct inode *inode, struct iattr *iattr)
444469
return ret;
445470
}
446471

447-
void orangefs_make_bad_inode(struct inode *inode)
448-
{
449-
if (is_root_handle(inode)) {
450-
/*
451-
* if this occurs, the pvfs2-client-core was killed but we
452-
* can't afford to lose the inode operations and such
453-
* associated with the root handle in any case.
454-
*/
455-
gossip_debug(GOSSIP_UTILS_DEBUG,
456-
"*** NOT making bad root inode %pU\n",
457-
get_khandle_from_ino(inode));
458-
} else {
459-
gossip_debug(GOSSIP_UTILS_DEBUG,
460-
"*** making bad inode %pU\n",
461-
get_khandle_from_ino(inode));
462-
make_bad_inode(inode);
463-
}
464-
}
465-
466472
/*
467473
* The following is a very dirty hack that is now a permanent part of the
468474
* ORANGEFS protocol. See protocol.h for more error definitions.
@@ -537,6 +543,7 @@ int orangefs_normalize_to_errno(__s32 error_code)
537543
*/
538544
} else {
539545
gossip_err("orangefs: orangefs_normalize_to_errno: got error code which is not from ORANGEFS.\n");
546+
error_code = -EINVAL;
540547
}
541548
return error_code;
542549
}

fs/orangefs/protocol.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -395,13 +395,6 @@ struct ORANGEFS_dev_map_desc {
395395

396396
/* gossip.h *****************************************************************/
397397

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
405398
extern __u64 orangefs_gossip_debug_mask;
406399

407400
/* try to avoid function call overhead by checking masks in macro */
@@ -410,13 +403,5 @@ do { \
410403
if (orangefs_gossip_debug_mask & (mask)) \
411404
printk(KERN_DEBUG fmt, ##__VA_ARGS__); \
412405
} while (0)
413-
#endif /* GOSSIP_DISABLE_DEBUG */
414-
415-
/* do file and line number printouts w/ the GNU preprocessor */
416-
#define gossip_ldebug(mask, fmt, ...) \
417-
gossip_debug(mask, "%s: " fmt, __func__, ##__VA_ARGS__)
418406

419407
#define gossip_err pr_err
420-
#define gossip_lerr(fmt, ...) \
421-
gossip_err("%s line %d: " fmt, \
422-
__FILE__, __LINE__, ##__VA_ARGS__)

fs/orangefs/super.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ static int orangefs_encode_fh(struct inode *inode,
335335
struct orangefs_object_kref refn;
336336

337337
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");
339339
*max_len = len;
340340
type = 255;
341341
goto out;
@@ -383,7 +383,7 @@ static int orangefs_unmount(int id, __s32 fs_id, const char *devname)
383383
op->upcall.req.fs_umount.id = id;
384384
op->upcall.req.fs_umount.fs_id = fs_id;
385385
strncpy(op->upcall.req.fs_umount.orangefs_config_server,
386-
devname, ORANGEFS_MAX_SERVER_ADDR_LEN);
386+
devname, ORANGEFS_MAX_SERVER_ADDR_LEN - 1);
387387
r = service_operation(op, "orangefs_fs_umount", 0);
388388
/* Not much to do about an error here. */
389389
if (r)
@@ -478,7 +478,7 @@ struct dentry *orangefs_mount(struct file_system_type *fst,
478478

479479
strncpy(new_op->upcall.req.fs_mount.orangefs_config_server,
480480
devname,
481-
ORANGEFS_MAX_SERVER_ADDR_LEN);
481+
ORANGEFS_MAX_SERVER_ADDR_LEN - 1);
482482

483483
gossip_debug(GOSSIP_SUPER_DEBUG,
484484
"Attempting ORANGEFS Mount via host %s\n",
@@ -520,7 +520,7 @@ struct dentry *orangefs_mount(struct file_system_type *fst,
520520
*/
521521
strncpy(ORANGEFS_SB(sb)->devname,
522522
devname,
523-
ORANGEFS_MAX_SERVER_ADDR_LEN);
523+
ORANGEFS_MAX_SERVER_ADDR_LEN - 1);
524524

525525
/* mount_pending must be cleared */
526526
ORANGEFS_SB(sb)->mount_pending = 0;

0 commit comments

Comments
 (0)