diff options
Diffstat (limited to 'fs/xfs/xfs_vnodeops.c')
-rw-r--r-- | fs/xfs/xfs_vnodeops.c | 93 |
1 files changed, 39 insertions, 54 deletions
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c index 6558ffd8d140..6f268756bf36 100644 --- a/fs/xfs/xfs_vnodeops.c +++ b/fs/xfs/xfs_vnodeops.c | |||
@@ -70,7 +70,6 @@ xfs_setattr( | |||
70 | uint commit_flags=0; | 70 | uint commit_flags=0; |
71 | uid_t uid=0, iuid=0; | 71 | uid_t uid=0, iuid=0; |
72 | gid_t gid=0, igid=0; | 72 | gid_t gid=0, igid=0; |
73 | int timeflags = 0; | ||
74 | struct xfs_dquot *udqp, *gdqp, *olddquot1, *olddquot2; | 73 | struct xfs_dquot *udqp, *gdqp, *olddquot1, *olddquot2; |
75 | int need_iolock = 1; | 74 | int need_iolock = 1; |
76 | 75 | ||
@@ -135,16 +134,13 @@ xfs_setattr( | |||
135 | if (flags & XFS_ATTR_NOLOCK) | 134 | if (flags & XFS_ATTR_NOLOCK) |
136 | need_iolock = 0; | 135 | need_iolock = 0; |
137 | if (!(mask & ATTR_SIZE)) { | 136 | if (!(mask & ATTR_SIZE)) { |
138 | if ((mask != (ATTR_CTIME|ATTR_ATIME|ATTR_MTIME)) || | 137 | tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE); |
139 | (mp->m_flags & XFS_MOUNT_WSYNC)) { | 138 | commit_flags = 0; |
140 | tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE); | 139 | code = xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), |
141 | commit_flags = 0; | 140 | 0, 0, 0); |
142 | if ((code = xfs_trans_reserve(tp, 0, | 141 | if (code) { |
143 | XFS_ICHANGE_LOG_RES(mp), 0, | 142 | lock_flags = 0; |
144 | 0, 0))) { | 143 | goto error_return; |
145 | lock_flags = 0; | ||
146 | goto error_return; | ||
147 | } | ||
148 | } | 144 | } |
149 | } else { | 145 | } else { |
150 | if (DM_EVENT_ENABLED(ip, DM_EVENT_TRUNCATE) && | 146 | if (DM_EVENT_ENABLED(ip, DM_EVENT_TRUNCATE) && |
@@ -295,15 +291,23 @@ xfs_setattr( | |||
295 | * or we are explicitly asked to change it. This handles | 291 | * or we are explicitly asked to change it. This handles |
296 | * the semantic difference between truncate() and ftruncate() | 292 | * the semantic difference between truncate() and ftruncate() |
297 | * as implemented in the VFS. | 293 | * as implemented in the VFS. |
294 | * | ||
295 | * The regular truncate() case without ATTR_CTIME and ATTR_MTIME | ||
296 | * is a special case where we need to update the times despite | ||
297 | * not having these flags set. For all other operations the | ||
298 | * VFS set these flags explicitly if it wants a timestamp | ||
299 | * update. | ||
298 | */ | 300 | */ |
299 | if (iattr->ia_size != ip->i_size || (mask & ATTR_CTIME)) | 301 | if (iattr->ia_size != ip->i_size && |
300 | timeflags |= XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG; | 302 | (!(mask & (ATTR_CTIME | ATTR_MTIME)))) { |
303 | iattr->ia_ctime = iattr->ia_mtime = | ||
304 | current_fs_time(inode->i_sb); | ||
305 | mask |= ATTR_CTIME | ATTR_MTIME; | ||
306 | } | ||
301 | 307 | ||
302 | if (iattr->ia_size > ip->i_size) { | 308 | if (iattr->ia_size > ip->i_size) { |
303 | ip->i_d.di_size = iattr->ia_size; | 309 | ip->i_d.di_size = iattr->ia_size; |
304 | ip->i_size = iattr->ia_size; | 310 | ip->i_size = iattr->ia_size; |
305 | if (!(flags & XFS_ATTR_DMI)) | ||
306 | xfs_ichgtime(ip, XFS_ICHGTIME_CHG); | ||
307 | xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); | 311 | xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); |
308 | } else if (iattr->ia_size <= ip->i_size || | 312 | } else if (iattr->ia_size <= ip->i_size || |
309 | (iattr->ia_size == 0 && ip->i_d.di_nextents)) { | 313 | (iattr->ia_size == 0 && ip->i_d.di_nextents)) { |
@@ -374,9 +378,6 @@ xfs_setattr( | |||
374 | ip->i_d.di_gid = gid; | 378 | ip->i_d.di_gid = gid; |
375 | inode->i_gid = gid; | 379 | inode->i_gid = gid; |
376 | } | 380 | } |
377 | |||
378 | xfs_trans_log_inode (tp, ip, XFS_ILOG_CORE); | ||
379 | timeflags |= XFS_ICHGTIME_CHG; | ||
380 | } | 381 | } |
381 | 382 | ||
382 | /* | 383 | /* |
@@ -393,51 +394,37 @@ xfs_setattr( | |||
393 | 394 | ||
394 | inode->i_mode &= S_IFMT; | 395 | inode->i_mode &= S_IFMT; |
395 | inode->i_mode |= mode & ~S_IFMT; | 396 | inode->i_mode |= mode & ~S_IFMT; |
396 | |||
397 | xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); | ||
398 | timeflags |= XFS_ICHGTIME_CHG; | ||
399 | } | 397 | } |
400 | 398 | ||
401 | /* | 399 | /* |
402 | * Change file access or modified times. | 400 | * Change file access or modified times. |
403 | */ | 401 | */ |
404 | if (mask & (ATTR_ATIME|ATTR_MTIME)) { | 402 | if (mask & ATTR_ATIME) { |
405 | if (mask & ATTR_ATIME) { | 403 | inode->i_atime = iattr->ia_atime; |
406 | inode->i_atime = iattr->ia_atime; | 404 | ip->i_d.di_atime.t_sec = iattr->ia_atime.tv_sec; |
407 | ip->i_d.di_atime.t_sec = iattr->ia_atime.tv_sec; | 405 | ip->i_d.di_atime.t_nsec = iattr->ia_atime.tv_nsec; |
408 | ip->i_d.di_atime.t_nsec = iattr->ia_atime.tv_nsec; | 406 | ip->i_update_core = 1; |
409 | ip->i_update_core = 1; | ||
410 | } | ||
411 | if (mask & ATTR_MTIME) { | ||
412 | inode->i_mtime = iattr->ia_mtime; | ||
413 | ip->i_d.di_mtime.t_sec = iattr->ia_mtime.tv_sec; | ||
414 | ip->i_d.di_mtime.t_nsec = iattr->ia_mtime.tv_nsec; | ||
415 | timeflags &= ~XFS_ICHGTIME_MOD; | ||
416 | timeflags |= XFS_ICHGTIME_CHG; | ||
417 | } | ||
418 | if (tp && (mask & (ATTR_MTIME_SET|ATTR_ATIME_SET))) | ||
419 | xfs_trans_log_inode (tp, ip, XFS_ILOG_CORE); | ||
420 | } | 407 | } |
421 | 408 | if (mask & ATTR_CTIME) { | |
422 | /* | ||
423 | * Change file inode change time only if ATTR_CTIME set | ||
424 | * AND we have been called by a DMI function. | ||
425 | */ | ||
426 | |||
427 | if ((flags & XFS_ATTR_DMI) && (mask & ATTR_CTIME)) { | ||
428 | inode->i_ctime = iattr->ia_ctime; | 409 | inode->i_ctime = iattr->ia_ctime; |
429 | ip->i_d.di_ctime.t_sec = iattr->ia_ctime.tv_sec; | 410 | ip->i_d.di_ctime.t_sec = iattr->ia_ctime.tv_sec; |
430 | ip->i_d.di_ctime.t_nsec = iattr->ia_ctime.tv_nsec; | 411 | ip->i_d.di_ctime.t_nsec = iattr->ia_ctime.tv_nsec; |
431 | ip->i_update_core = 1; | 412 | ip->i_update_core = 1; |
432 | timeflags &= ~XFS_ICHGTIME_CHG; | 413 | } |
414 | if (mask & ATTR_MTIME) { | ||
415 | inode->i_mtime = iattr->ia_mtime; | ||
416 | ip->i_d.di_mtime.t_sec = iattr->ia_mtime.tv_sec; | ||
417 | ip->i_d.di_mtime.t_nsec = iattr->ia_mtime.tv_nsec; | ||
418 | ip->i_update_core = 1; | ||
433 | } | 419 | } |
434 | 420 | ||
435 | /* | 421 | /* |
436 | * Send out timestamp changes that need to be set to the | 422 | * And finally, log the inode core if any attribute in it |
437 | * current time. Not done when called by a DMI function. | 423 | * has been changed. |
438 | */ | 424 | */ |
439 | if (timeflags && !(flags & XFS_ATTR_DMI)) | 425 | if (mask & (ATTR_UID|ATTR_GID|ATTR_MODE| |
440 | xfs_ichgtime(ip, timeflags); | 426 | ATTR_ATIME|ATTR_CTIME|ATTR_MTIME)) |
427 | xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); | ||
441 | 428 | ||
442 | XFS_STATS_INC(xs_ig_attrchg); | 429 | XFS_STATS_INC(xs_ig_attrchg); |
443 | 430 | ||
@@ -452,12 +439,10 @@ xfs_setattr( | |||
452 | * mix so this probably isn't worth the trouble to optimize. | 439 | * mix so this probably isn't worth the trouble to optimize. |
453 | */ | 440 | */ |
454 | code = 0; | 441 | code = 0; |
455 | if (tp) { | 442 | if (mp->m_flags & XFS_MOUNT_WSYNC) |
456 | if (mp->m_flags & XFS_MOUNT_WSYNC) | 443 | xfs_trans_set_sync(tp); |
457 | xfs_trans_set_sync(tp); | ||
458 | 444 | ||
459 | code = xfs_trans_commit(tp, commit_flags); | 445 | code = xfs_trans_commit(tp, commit_flags); |
460 | } | ||
461 | 446 | ||
462 | xfs_iunlock(ip, lock_flags); | 447 | xfs_iunlock(ip, lock_flags); |
463 | 448 | ||