Blame view
fs/xfs/xfs_trans_inode.c
3.95 KB
1da177e4c Linux-2.6.12-rc2 |
1 |
/* |
7b7187698 [XFS] Update lice... |
2 3 |
* Copyright (c) 2000,2005 Silicon Graphics, Inc. * All Rights Reserved. |
1da177e4c Linux-2.6.12-rc2 |
4 |
* |
7b7187698 [XFS] Update lice... |
5 6 |
* This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as |
1da177e4c Linux-2.6.12-rc2 |
7 8 |
* published by the Free Software Foundation. * |
7b7187698 [XFS] Update lice... |
9 10 11 12 |
* This program is distributed in the hope that it would be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. |
1da177e4c Linux-2.6.12-rc2 |
13 |
* |
7b7187698 [XFS] Update lice... |
14 15 16 |
* You should have received a copy of the GNU General Public License * along with this program; if not, write the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
1da177e4c Linux-2.6.12-rc2 |
17 |
*/ |
1da177e4c Linux-2.6.12-rc2 |
18 |
#include "xfs.h" |
a844f4510 [XFS] Remove xfs_... |
19 |
#include "xfs_fs.h" |
70a9883c5 xfs: create a sha... |
20 |
#include "xfs_shared.h" |
a4fbe6ab1 xfs: decouple ino... |
21 |
#include "xfs_format.h" |
239880ef6 xfs: decouple log... |
22 23 |
#include "xfs_log_format.h" #include "xfs_trans_resv.h" |
1da177e4c Linux-2.6.12-rc2 |
24 |
#include "xfs_mount.h" |
1da177e4c Linux-2.6.12-rc2 |
25 |
#include "xfs_inode.h" |
239880ef6 xfs: decouple log... |
26 |
#include "xfs_trans.h" |
a844f4510 [XFS] Remove xfs_... |
27 28 |
#include "xfs_trans_priv.h" #include "xfs_inode_item.h" |
898621d5a xfs: simplify ino... |
29 |
#include "xfs_trace.h" |
1da177e4c Linux-2.6.12-rc2 |
30 |
|
1da177e4c Linux-2.6.12-rc2 |
31 |
/* |
898621d5a xfs: simplify ino... |
32 33 34 |
* Add a locked inode to the transaction. * * The inode must be locked, and it cannot be associated with any transaction. |
ddc3415ab xfs: simplify xfs... |
35 |
* If lock_flags is non-zero the inode will be unlocked on transaction commit. |
1da177e4c Linux-2.6.12-rc2 |
36 37 38 |
*/ void xfs_trans_ijoin( |
898621d5a xfs: simplify ino... |
39 |
struct xfs_trans *tp, |
ddc3415ab xfs: simplify xfs... |
40 41 |
struct xfs_inode *ip, uint lock_flags) |
1da177e4c Linux-2.6.12-rc2 |
42 43 |
{ xfs_inode_log_item_t *iip; |
579aa9caf [XFS] shrink mrlo... |
44 |
ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); |
1da177e4c Linux-2.6.12-rc2 |
45 46 47 |
if (ip->i_itemp == NULL) xfs_inode_item_init(ip, ip->i_mount); iip = ip->i_itemp; |
ddc3415ab xfs: simplify xfs... |
48 |
|
898621d5a xfs: simplify ino... |
49 |
ASSERT(iip->ili_lock_flags == 0); |
ddc3415ab xfs: simplify xfs... |
50 |
iip->ili_lock_flags = lock_flags; |
1da177e4c Linux-2.6.12-rc2 |
51 52 53 54 |
/* * Get a log_item_desc to point at the new item. */ |
e98c414f9 xfs: simplify log... |
55 |
xfs_trans_add_item(tp, &iip->ili_item); |
1da177e4c Linux-2.6.12-rc2 |
56 |
} |
1da177e4c Linux-2.6.12-rc2 |
57 |
/* |
dcd79a142 xfs: don't use vf... |
58 59 60 61 62 63 64 65 66 67 68 |
* Transactional inode timestamp update. Requires the inode to be locked and * joined to the transaction supplied. Relies on the transaction subsystem to * track dirty state and update/writeback the inode accordingly. */ void xfs_trans_ichgtime( struct xfs_trans *tp, struct xfs_inode *ip, int flags) { struct inode *inode = VFS_I(ip); |
e076b0f3a xfs: kill time.h |
69 |
struct timespec tv; |
dcd79a142 xfs: don't use vf... |
70 71 72 |
ASSERT(tp); ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); |
dcd79a142 xfs: don't use vf... |
73 |
|
c2050a454 fs: Replace curre... |
74 |
tv = current_time(inode); |
dcd79a142 xfs: don't use vf... |
75 |
|
3987848c7 xfs: remove times... |
76 |
if (flags & XFS_ICHGTIME_MOD) |
dcd79a142 xfs: don't use vf... |
77 |
inode->i_mtime = tv; |
3987848c7 xfs: remove times... |
78 |
if (flags & XFS_ICHGTIME_CHG) |
dcd79a142 xfs: don't use vf... |
79 |
inode->i_ctime = tv; |
dcd79a142 xfs: don't use vf... |
80 81 82 |
} /* |
1da177e4c Linux-2.6.12-rc2 |
83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
* This is called to mark the fields indicated in fieldmask as needing * to be logged when the transaction is committed. The inode must * already be associated with the given transaction. * * The values for fieldmask are defined in xfs_inode_item.h. We always * log all of the core inode if any of it has changed, and we always log * all of the inline data/extents/b-tree root if any of them has changed. */ void xfs_trans_log_inode( xfs_trans_t *tp, xfs_inode_t *ip, uint flags) { |
1da177e4c Linux-2.6.12-rc2 |
97 |
ASSERT(ip->i_itemp != NULL); |
579aa9caf [XFS] shrink mrlo... |
98 |
ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); |
1da177e4c Linux-2.6.12-rc2 |
99 |
|
dc037ad7d xfs: implement in... |
100 |
/* |
fc0561cef xfs: optimise awa... |
101 102 103 104 105 106 107 108 109 |
* Record the specific change for fdatasync optimisation. This * allows fdatasync to skip log forces for inodes that are only * timestamp dirty. We do this before the change count so that * the core being logged in this case does not impact on fdatasync * behaviour. */ ip->i_itemp->ili_fsync_fields |= flags; /* |
dc037ad7d xfs: implement in... |
110 |
* First time we log the inode in a transaction, bump the inode change |
2fe8c1c08 xfs: open code in... |
111 112 113 114 |
* counter if it is configured for this to occur. We don't use * inode_inc_version() because there is no need for extra locking around * i_version as we already hold the inode locked exclusively for * metadata modification. |
dc037ad7d xfs: implement in... |
115 116 117 |
*/ if (!(ip->i_itemp->ili_item.li_desc->lid_flags & XFS_LID_DIRTY) && IS_I_VERSION(VFS_I(ip))) { |
83e06f21b xfs: move di_chan... |
118 |
VFS_I(ip)->i_version++; |
dc037ad7d xfs: implement in... |
119 120 |
flags |= XFS_ILOG_CORE; } |
1da177e4c Linux-2.6.12-rc2 |
121 |
tp->t_flags |= XFS_TRANS_DIRTY; |
e98c414f9 xfs: simplify log... |
122 |
ip->i_itemp->ili_item.li_desc->lid_flags |= XFS_LID_DIRTY; |
1da177e4c Linux-2.6.12-rc2 |
123 124 125 126 |
/* * Always OR in the bits from the ili_last_fields field. * This is to coordinate with the xfs_iflush() and xfs_iflush_done() |
f5d8d5c4b xfs: split in-cor... |
127 |
* routines in the eventual clearing of the ili_fields bits. |
1da177e4c Linux-2.6.12-rc2 |
128 |
* See the big comment in xfs_iflush() for an explanation of |
c41564b5a [XFS] We really s... |
129 |
* this coordination mechanism. |
1da177e4c Linux-2.6.12-rc2 |
130 131 |
*/ flags |= ip->i_itemp->ili_last_fields; |
f5d8d5c4b xfs: split in-cor... |
132 |
ip->i_itemp->ili_fields |= flags; |
1da177e4c Linux-2.6.12-rc2 |
133 |
} |