aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/linux-2.6/xfs_iops.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/linux-2.6/xfs_iops.c')
-rw-r--r--fs/xfs/linux-2.6/xfs_iops.c180
1 files changed, 148 insertions, 32 deletions
diff --git a/fs/xfs/linux-2.6/xfs_iops.c b/fs/xfs/linux-2.6/xfs_iops.c
index 77708a8c9f87..14215a7db59f 100644
--- a/fs/xfs/linux-2.6/xfs_iops.c
+++ b/fs/xfs/linux-2.6/xfs_iops.c
@@ -1,39 +1,25 @@
1/* 1/*
2 * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or
5 * under the terms of version 2 of the GNU General Public License as 6 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
7 * 8 *
8 * This program is distributed in the hope that it would be useful, but 9 * This program is distributed in the hope that it would be useful,
9 * WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
11 * 13 *
12 * Further, this software is distributed without any warranty that it is 14 * You should have received a copy of the GNU General Public License
13 * free of the rightful claim of any third person regarding infringement 15 * along with this program; if not, write the Free Software Foundation,
14 * or the like. Any license provided herein, whether implied or 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22 *
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
25 *
26 * http://www.sgi.com
27 *
28 * For further information regarding this notice, see:
29 *
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31 */ 17 */
32
33#include "xfs.h" 18#include "xfs.h"
34#include "xfs_fs.h" 19#include "xfs_fs.h"
35#include "xfs_inum.h" 20#include "xfs_bit.h"
36#include "xfs_log.h" 21#include "xfs_log.h"
22#include "xfs_inum.h"
37#include "xfs_trans.h" 23#include "xfs_trans.h"
38#include "xfs_sb.h" 24#include "xfs_sb.h"
39#include "xfs_ag.h" 25#include "xfs_ag.h"
@@ -43,18 +29,17 @@
43#include "xfs_dmapi.h" 29#include "xfs_dmapi.h"
44#include "xfs_quota.h" 30#include "xfs_quota.h"
45#include "xfs_mount.h" 31#include "xfs_mount.h"
46#include "xfs_alloc_btree.h"
47#include "xfs_bmap_btree.h" 32#include "xfs_bmap_btree.h"
33#include "xfs_alloc_btree.h"
48#include "xfs_ialloc_btree.h" 34#include "xfs_ialloc_btree.h"
49#include "xfs_btree.h"
50#include "xfs_ialloc.h"
51#include "xfs_attr_sf.h"
52#include "xfs_dir_sf.h" 35#include "xfs_dir_sf.h"
53#include "xfs_dir2_sf.h" 36#include "xfs_dir2_sf.h"
37#include "xfs_attr_sf.h"
54#include "xfs_dinode.h" 38#include "xfs_dinode.h"
55#include "xfs_inode.h" 39#include "xfs_inode.h"
56#include "xfs_bmap.h" 40#include "xfs_bmap.h"
57#include "xfs_bit.h" 41#include "xfs_btree.h"
42#include "xfs_ialloc.h"
58#include "xfs_rtalloc.h" 43#include "xfs_rtalloc.h"
59#include "xfs_error.h" 44#include "xfs_error.h"
60#include "xfs_itable.h" 45#include "xfs_itable.h"
@@ -69,6 +54,137 @@
69#include <linux/xattr.h> 54#include <linux/xattr.h>
70#include <linux/namei.h> 55#include <linux/namei.h>
71 56
57/*
58 * Change the requested timestamp in the given inode.
59 * We don't lock across timestamp updates, and we don't log them but
60 * we do record the fact that there is dirty information in core.
61 *
62 * NOTE -- callers MUST combine XFS_ICHGTIME_MOD or XFS_ICHGTIME_CHG
63 * with XFS_ICHGTIME_ACC to be sure that access time
64 * update will take. Calling first with XFS_ICHGTIME_ACC
65 * and then XFS_ICHGTIME_MOD may fail to modify the access
66 * timestamp if the filesystem is mounted noacctm.
67 */
68void
69xfs_ichgtime(
70 xfs_inode_t *ip,
71 int flags)
72{
73 struct inode *inode = LINVFS_GET_IP(XFS_ITOV(ip));
74 timespec_t tv;
75
76 /*
77 * We're not supposed to change timestamps in readonly-mounted
78 * filesystems. Throw it away if anyone asks us.
79 */
80 if (unlikely(IS_RDONLY(inode)))
81 return;
82
83 /*
84 * Don't update access timestamps on reads if mounted "noatime".
85 * Throw it away if anyone asks us.
86 */
87 if (unlikely(
88 (ip->i_mount->m_flags & XFS_MOUNT_NOATIME || IS_NOATIME(inode)) &&
89 (flags & (XFS_ICHGTIME_ACC|XFS_ICHGTIME_MOD|XFS_ICHGTIME_CHG)) ==
90 XFS_ICHGTIME_ACC))
91 return;
92
93 nanotime(&tv);
94 if (flags & XFS_ICHGTIME_MOD) {
95 inode->i_mtime = tv;
96 ip->i_d.di_mtime.t_sec = (__int32_t)tv.tv_sec;
97 ip->i_d.di_mtime.t_nsec = (__int32_t)tv.tv_nsec;
98 }
99 if (flags & XFS_ICHGTIME_ACC) {
100 inode->i_atime = tv;
101 ip->i_d.di_atime.t_sec = (__int32_t)tv.tv_sec;
102 ip->i_d.di_atime.t_nsec = (__int32_t)tv.tv_nsec;
103 }
104 if (flags & XFS_ICHGTIME_CHG) {
105 inode->i_ctime = tv;
106 ip->i_d.di_ctime.t_sec = (__int32_t)tv.tv_sec;
107 ip->i_d.di_ctime.t_nsec = (__int32_t)tv.tv_nsec;
108 }
109
110 /*
111 * We update the i_update_core field _after_ changing
112 * the timestamps in order to coordinate properly with
113 * xfs_iflush() so that we don't lose timestamp updates.
114 * This keeps us from having to hold the inode lock
115 * while doing this. We use the SYNCHRONIZE macro to
116 * ensure that the compiler does not reorder the update
117 * of i_update_core above the timestamp updates above.
118 */
119 SYNCHRONIZE();
120 ip->i_update_core = 1;
121 if (!(inode->i_state & I_LOCK))
122 mark_inode_dirty_sync(inode);
123}
124
125/*
126 * Variant on the above which avoids querying the system clock
127 * in situations where we know the Linux inode timestamps have
128 * just been updated (and so we can update our inode cheaply).
129 * We also skip the readonly and noatime checks here, they are
130 * also catered for already.
131 */
132void
133xfs_ichgtime_fast(
134 xfs_inode_t *ip,
135 struct inode *inode,
136 int flags)
137{
138 timespec_t *tvp;
139
140 /*
141 * We're not supposed to change timestamps in readonly-mounted
142 * filesystems. Throw it away if anyone asks us.
143 */
144 if (unlikely(IS_RDONLY(inode)))
145 return;
146
147 /*
148 * Don't update access timestamps on reads if mounted "noatime".
149 * Throw it away if anyone asks us.
150 */
151 if (unlikely(
152 (ip->i_mount->m_flags & XFS_MOUNT_NOATIME || IS_NOATIME(inode)) &&
153 ((flags & (XFS_ICHGTIME_ACC|XFS_ICHGTIME_MOD|XFS_ICHGTIME_CHG)) ==
154 XFS_ICHGTIME_ACC)))
155 return;
156
157 if (flags & XFS_ICHGTIME_MOD) {
158 tvp = &inode->i_mtime;
159 ip->i_d.di_mtime.t_sec = (__int32_t)tvp->tv_sec;
160 ip->i_d.di_mtime.t_nsec = (__int32_t)tvp->tv_nsec;
161 }
162 if (flags & XFS_ICHGTIME_ACC) {
163 tvp = &inode->i_atime;
164 ip->i_d.di_atime.t_sec = (__int32_t)tvp->tv_sec;
165 ip->i_d.di_atime.t_nsec = (__int32_t)tvp->tv_nsec;
166 }
167 if (flags & XFS_ICHGTIME_CHG) {
168 tvp = &inode->i_ctime;
169 ip->i_d.di_ctime.t_sec = (__int32_t)tvp->tv_sec;
170 ip->i_d.di_ctime.t_nsec = (__int32_t)tvp->tv_nsec;
171 }
172
173 /*
174 * We update the i_update_core field _after_ changing
175 * the timestamps in order to coordinate properly with
176 * xfs_iflush() so that we don't lose timestamp updates.
177 * This keeps us from having to hold the inode lock
178 * while doing this. We use the SYNCHRONIZE macro to
179 * ensure that the compiler does not reorder the update
180 * of i_update_core above the timestamp updates above.
181 */
182 SYNCHRONIZE();
183 ip->i_update_core = 1;
184 if (!(inode->i_state & I_LOCK))
185 mark_inode_dirty_sync(inode);
186}
187
72 188
73/* 189/*
74 * Pull the link count and size up from the xfs inode to the linux inode 190 * Pull the link count and size up from the xfs inode to the linux inode