aboutsummaryrefslogtreecommitdiffstats
path: root/fs/orangefs
diff options
context:
space:
mode:
authorMartin Brandenburg <martin@omnibond.com>2016-01-30 13:46:11 -0500
committerMike Marshall <hubcap@omnibond.com>2016-02-04 14:12:17 -0500
commitfe88adc3661ff9eb2a9777277f9c3abf5909449f (patch)
treeb3eb699804cad625a3a53a6cc402376f60278841 /fs/orangefs
parent2d4cae0d175acae2ea2efbc17b52b71d4ffd886d (diff)
orangefs: Only compare attributes specified in orangefs_inode_getattr.
Signed-off-by: Martin Brandenburg <martin@omnibond.com> Signed-off-by: Mike Marshall <hubcap@omnibond.com>
Diffstat (limited to 'fs/orangefs')
-rw-r--r--fs/orangefs/orangefs-utils.c62
1 files changed, 43 insertions, 19 deletions
diff --git a/fs/orangefs/orangefs-utils.c b/fs/orangefs/orangefs-utils.c
index 6cf29a439211..fa3ed8ad35be 100644
--- a/fs/orangefs/orangefs-utils.c
+++ b/fs/orangefs/orangefs-utils.c
@@ -355,26 +355,37 @@ static inline int copy_attributes_from_inode(struct inode *inode,
355 355
356static int compare_attributes_to_inode(struct inode *inode, 356static int compare_attributes_to_inode(struct inode *inode,
357 struct ORANGEFS_sys_attr_s *attrs, 357 struct ORANGEFS_sys_attr_s *attrs,
358 char *symname) 358 char *symname,
359 int mask)
359{ 360{
360 struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode); 361 struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode);
361 loff_t inode_size, rounded_up_size; 362 loff_t inode_size, rounded_up_size;
362 363
364 /* Much of what happens below relies on the type being around. */
365 if (!(mask & ORANGEFS_ATTR_SYS_TYPE))
366 return 0;
367
368 if (attrs->objtype == ORANGEFS_TYPE_METAFILE &&
369 inode->i_flags != orangefs_inode_flags(attrs))
370 return 0;
371
363 /* Compare file size. */ 372 /* Compare file size. */
364 373
365 switch (attrs->objtype) { 374 switch (attrs->objtype) {
366 case ORANGEFS_TYPE_METAFILE: 375 case ORANGEFS_TYPE_METAFILE:
367 if(inode->i_flags != orangefs_inode_flags(attrs)) 376 if (mask & ORANGEFS_ATTR_SYS_SIZE) {
368 return 0; 377 inode_size = attrs->size;
369 inode_size = attrs->size; 378 rounded_up_size = inode_size +
370 rounded_up_size = inode_size + (4096 - (inode_size % 4096)); 379 (4096 - (inode_size % 4096));
371 if (inode->i_bytes != inode_size || 380 if (inode->i_bytes != inode_size ||
372 inode->i_blocks != rounded_up_size/512) 381 inode->i_blocks != rounded_up_size/512)
373 return 0; 382 return 0;
383 }
374 break; 384 break;
375 case ORANGEFS_TYPE_SYMLINK: 385 case ORANGEFS_TYPE_SYMLINK:
376 if (symname && strlen(symname) != inode->i_size) 386 if (mask & ORANGEFS_ATTR_SYS_SIZE)
377 return 0; 387 if (symname && strlen(symname) != inode->i_size)
388 return 0;
378 break; 389 break;
379 default: 390 default:
380 if (inode->i_size != PAGE_CACHE_SIZE && 391 if (inode->i_size != PAGE_CACHE_SIZE &&
@@ -384,17 +395,28 @@ static int compare_attributes_to_inode(struct inode *inode,
384 395
385 /* Compare general attributes. */ 396 /* Compare general attributes. */
386 397
387 if (!uid_eq(inode->i_uid, make_kuid(&init_user_ns, attrs->owner)) || 398 if (mask & ORANGEFS_ATTR_SYS_UID &&
388 !gid_eq(inode->i_gid, make_kgid(&init_user_ns, attrs->group)) || 399 !uid_eq(inode->i_uid, make_kuid(&init_user_ns, attrs->owner)))
389 inode->i_atime.tv_sec != attrs->atime || 400 return 0;
390 inode->i_mtime.tv_sec != attrs->mtime || 401 if (mask & ORANGEFS_ATTR_SYS_GID &&
391 inode->i_ctime.tv_sec != attrs->ctime || 402 !gid_eq(inode->i_gid, make_kgid(&init_user_ns, attrs->group)))
392 inode->i_atime.tv_nsec != 0 || 403 return 0;
404 if (mask & ORANGEFS_ATTR_SYS_ATIME &&
405 inode->i_atime.tv_sec != attrs->atime)
406 return 0;
407 if (mask & ORANGEFS_ATTR_SYS_MTIME &&
408 inode->i_atime.tv_sec != attrs->mtime)
409 return 0;
410 if (mask & ORANGEFS_ATTR_SYS_CTIME &&
411 inode->i_atime.tv_sec != attrs->ctime)
412 return 0;
413 if (inode->i_atime.tv_nsec != 0 ||
393 inode->i_mtime.tv_nsec != 0 || 414 inode->i_mtime.tv_nsec != 0 ||
394 inode->i_ctime.tv_nsec != 0) 415 inode->i_ctime.tv_nsec != 0)
395 return 0; 416 return 0;
396 417
397 if ((inode->i_mode & ~(S_ISVTX|S_IFREG|S_IFDIR|S_IFLNK)) != 418 if (mask & ORANGEFS_ATTR_SYS_PERM &&
419 (inode->i_mode & ~(S_ISVTX|S_IFREG|S_IFDIR|S_IFLNK)) !=
398 orangefs_inode_perms(attrs)) 420 orangefs_inode_perms(attrs))
399 return 0; 421 return 0;
400 422
@@ -418,7 +440,8 @@ static int compare_attributes_to_inode(struct inode *inode,
418 case ORANGEFS_TYPE_SYMLINK: 440 case ORANGEFS_TYPE_SYMLINK:
419 if (!(inode->i_mode & S_IFLNK)) 441 if (!(inode->i_mode & S_IFLNK))
420 return 0; 442 return 0;
421 if (orangefs_inode && symname) 443 if (orangefs_inode && symname &&
444 mask & ORANGEFS_ATTR_SYS_LNK_TARGET)
422 if (strcmp(orangefs_inode->link_target, symname)) 445 if (strcmp(orangefs_inode->link_target, symname))
423 return 0; 446 return 0;
424 break; 447 break;
@@ -462,7 +485,8 @@ int orangefs_inode_getattr(struct inode *inode, __u32 getattr_mask, int check)
462 if (check) { 485 if (check) {
463 ret = compare_attributes_to_inode(inode, 486 ret = compare_attributes_to_inode(inode,
464 &new_op->downcall.resp.getattr.attributes, 487 &new_op->downcall.resp.getattr.attributes,
465 new_op->downcall.resp.getattr.link_target); 488 new_op->downcall.resp.getattr.link_target,
489 getattr_mask);
466 490
467 if (new_op->downcall.resp.getattr.attributes.objtype == 491 if (new_op->downcall.resp.getattr.attributes.objtype ==
468 ORANGEFS_TYPE_METAFILE) { 492 ORANGEFS_TYPE_METAFILE) {