diff options
author | Christoph Hellwig <hch@infradead.org> | 2008-12-09 04:47:33 -0500 |
---|---|---|
committer | Lachlan McIlroy <lachlan@redback.melbourne.sgi.com> | 2008-12-10 21:14:41 -0500 |
commit | 4d4be482a4d78ca906f45e99fd9fdb91e907f5ad (patch) | |
tree | 52974b28fecd3c11fc0596504270ffee976f1b1a /fs/xfs/linux-2.6/xfs_file.c | |
parent | 6d73cf133c5477f7038577bfeda603ce9946f8cb (diff) |
[XFS] add a FMODE flag to make XFS invisible I/O less hacky
XFS has a mode called invisble I/O that doesn't update any of the
timestamps. It's used for HSM-style applications and exposed through
the nasty open by handle ioctl.
Instead of doing directly assignment of file operations that set an
internal flag for it add a new FMODE_NOCMTIME flag that we can check
in the normal file operations.
(addition of the generic VFS flag has been ACKed by Al as an interims
solution)
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Lachlan McIlroy <lachlan@sgi.com>
Diffstat (limited to 'fs/xfs/linux-2.6/xfs_file.c')
-rw-r--r-- | fs/xfs/linux-2.6/xfs_file.c | 145 |
1 files changed, 20 insertions, 125 deletions
diff --git a/fs/xfs/linux-2.6/xfs_file.c b/fs/xfs/linux-2.6/xfs_file.c index f999d20a429c..a0c45cc8a6b8 100644 --- a/fs/xfs/linux-2.6/xfs_file.c +++ b/fs/xfs/linux-2.6/xfs_file.c | |||
@@ -45,81 +45,45 @@ | |||
45 | 45 | ||
46 | static struct vm_operations_struct xfs_file_vm_ops; | 46 | static struct vm_operations_struct xfs_file_vm_ops; |
47 | 47 | ||
48 | STATIC_INLINE ssize_t | 48 | STATIC ssize_t |
49 | __xfs_file_read( | 49 | xfs_file_aio_read( |
50 | struct kiocb *iocb, | 50 | struct kiocb *iocb, |
51 | const struct iovec *iov, | 51 | const struct iovec *iov, |
52 | unsigned long nr_segs, | 52 | unsigned long nr_segs, |
53 | int ioflags, | ||
54 | loff_t pos) | 53 | loff_t pos) |
55 | { | 54 | { |
56 | struct file *file = iocb->ki_filp; | 55 | struct file *file = iocb->ki_filp; |
56 | int ioflags = IO_ISAIO; | ||
57 | 57 | ||
58 | BUG_ON(iocb->ki_pos != pos); | 58 | BUG_ON(iocb->ki_pos != pos); |
59 | if (unlikely(file->f_flags & O_DIRECT)) | 59 | if (unlikely(file->f_flags & O_DIRECT)) |
60 | ioflags |= IO_ISDIRECT; | 60 | ioflags |= IO_ISDIRECT; |
61 | if (file->f_mode & FMODE_NOCMTIME) | ||
62 | ioflags |= IO_INVIS; | ||
61 | return xfs_read(XFS_I(file->f_path.dentry->d_inode), iocb, iov, | 63 | return xfs_read(XFS_I(file->f_path.dentry->d_inode), iocb, iov, |
62 | nr_segs, &iocb->ki_pos, ioflags); | 64 | nr_segs, &iocb->ki_pos, ioflags); |
63 | } | 65 | } |
64 | 66 | ||
65 | STATIC ssize_t | 67 | STATIC ssize_t |
66 | xfs_file_aio_read( | 68 | xfs_file_aio_write( |
67 | struct kiocb *iocb, | ||
68 | const struct iovec *iov, | ||
69 | unsigned long nr_segs, | ||
70 | loff_t pos) | ||
71 | { | ||
72 | return __xfs_file_read(iocb, iov, nr_segs, IO_ISAIO, pos); | ||
73 | } | ||
74 | |||
75 | STATIC ssize_t | ||
76 | xfs_file_aio_read_invis( | ||
77 | struct kiocb *iocb, | ||
78 | const struct iovec *iov, | ||
79 | unsigned long nr_segs, | ||
80 | loff_t pos) | ||
81 | { | ||
82 | return __xfs_file_read(iocb, iov, nr_segs, IO_ISAIO|IO_INVIS, pos); | ||
83 | } | ||
84 | |||
85 | STATIC_INLINE ssize_t | ||
86 | __xfs_file_write( | ||
87 | struct kiocb *iocb, | 69 | struct kiocb *iocb, |
88 | const struct iovec *iov, | 70 | const struct iovec *iov, |
89 | unsigned long nr_segs, | 71 | unsigned long nr_segs, |
90 | int ioflags, | ||
91 | loff_t pos) | 72 | loff_t pos) |
92 | { | 73 | { |
93 | struct file *file = iocb->ki_filp; | 74 | struct file *file = iocb->ki_filp; |
75 | int ioflags = IO_ISAIO; | ||
94 | 76 | ||
95 | BUG_ON(iocb->ki_pos != pos); | 77 | BUG_ON(iocb->ki_pos != pos); |
96 | if (unlikely(file->f_flags & O_DIRECT)) | 78 | if (unlikely(file->f_flags & O_DIRECT)) |
97 | ioflags |= IO_ISDIRECT; | 79 | ioflags |= IO_ISDIRECT; |
80 | if (file->f_mode & FMODE_NOCMTIME) | ||
81 | ioflags |= IO_INVIS; | ||
98 | return xfs_write(XFS_I(file->f_mapping->host), iocb, iov, nr_segs, | 82 | return xfs_write(XFS_I(file->f_mapping->host), iocb, iov, nr_segs, |
99 | &iocb->ki_pos, ioflags); | 83 | &iocb->ki_pos, ioflags); |
100 | } | 84 | } |
101 | 85 | ||
102 | STATIC ssize_t | 86 | STATIC ssize_t |
103 | xfs_file_aio_write( | ||
104 | struct kiocb *iocb, | ||
105 | const struct iovec *iov, | ||
106 | unsigned long nr_segs, | ||
107 | loff_t pos) | ||
108 | { | ||
109 | return __xfs_file_write(iocb, iov, nr_segs, IO_ISAIO, pos); | ||
110 | } | ||
111 | |||
112 | STATIC ssize_t | ||
113 | xfs_file_aio_write_invis( | ||
114 | struct kiocb *iocb, | ||
115 | const struct iovec *iov, | ||
116 | unsigned long nr_segs, | ||
117 | loff_t pos) | ||
118 | { | ||
119 | return __xfs_file_write(iocb, iov, nr_segs, IO_ISAIO|IO_INVIS, pos); | ||
120 | } | ||
121 | |||
122 | STATIC ssize_t | ||
123 | xfs_file_splice_read( | 87 | xfs_file_splice_read( |
124 | struct file *infilp, | 88 | struct file *infilp, |
125 | loff_t *ppos, | 89 | loff_t *ppos, |
@@ -127,20 +91,13 @@ xfs_file_splice_read( | |||
127 | size_t len, | 91 | size_t len, |
128 | unsigned int flags) | 92 | unsigned int flags) |
129 | { | 93 | { |
130 | return xfs_splice_read(XFS_I(infilp->f_path.dentry->d_inode), | 94 | int ioflags = 0; |
131 | infilp, ppos, pipe, len, flags, 0); | 95 | |
132 | } | 96 | if (infilp->f_mode & FMODE_NOCMTIME) |
97 | ioflags |= IO_INVIS; | ||
133 | 98 | ||
134 | STATIC ssize_t | ||
135 | xfs_file_splice_read_invis( | ||
136 | struct file *infilp, | ||
137 | loff_t *ppos, | ||
138 | struct pipe_inode_info *pipe, | ||
139 | size_t len, | ||
140 | unsigned int flags) | ||
141 | { | ||
142 | return xfs_splice_read(XFS_I(infilp->f_path.dentry->d_inode), | 99 | return xfs_splice_read(XFS_I(infilp->f_path.dentry->d_inode), |
143 | infilp, ppos, pipe, len, flags, IO_INVIS); | 100 | infilp, ppos, pipe, len, flags, ioflags); |
144 | } | 101 | } |
145 | 102 | ||
146 | STATIC ssize_t | 103 | STATIC ssize_t |
@@ -151,20 +108,13 @@ xfs_file_splice_write( | |||
151 | size_t len, | 108 | size_t len, |
152 | unsigned int flags) | 109 | unsigned int flags) |
153 | { | 110 | { |
154 | return xfs_splice_write(XFS_I(outfilp->f_path.dentry->d_inode), | 111 | int ioflags = 0; |
155 | pipe, outfilp, ppos, len, flags, 0); | 112 | |
156 | } | 113 | if (outfilp->f_mode & FMODE_NOCMTIME) |
114 | ioflags |= IO_INVIS; | ||
157 | 115 | ||
158 | STATIC ssize_t | ||
159 | xfs_file_splice_write_invis( | ||
160 | struct pipe_inode_info *pipe, | ||
161 | struct file *outfilp, | ||
162 | loff_t *ppos, | ||
163 | size_t len, | ||
164 | unsigned int flags) | ||
165 | { | ||
166 | return xfs_splice_write(XFS_I(outfilp->f_path.dentry->d_inode), | 116 | return xfs_splice_write(XFS_I(outfilp->f_path.dentry->d_inode), |
167 | pipe, outfilp, ppos, len, flags, IO_INVIS); | 117 | pipe, outfilp, ppos, len, flags, ioflags); |
168 | } | 118 | } |
169 | 119 | ||
170 | STATIC int | 120 | STATIC int |
@@ -275,42 +225,6 @@ xfs_file_mmap( | |||
275 | return 0; | 225 | return 0; |
276 | } | 226 | } |
277 | 227 | ||
278 | STATIC long | ||
279 | xfs_file_ioctl( | ||
280 | struct file *filp, | ||
281 | unsigned int cmd, | ||
282 | unsigned long p) | ||
283 | { | ||
284 | struct inode *inode = filp->f_path.dentry->d_inode; | ||
285 | |||
286 | |||
287 | /* NOTE: some of the ioctl's return positive #'s as a | ||
288 | * byte count indicating success, such as | ||
289 | * readlink_by_handle. So we don't "sign flip" | ||
290 | * like most other routines. This means true | ||
291 | * errors need to be returned as a negative value. | ||
292 | */ | ||
293 | return xfs_ioctl(XFS_I(inode), filp, 0, cmd, (void __user *)p); | ||
294 | } | ||
295 | |||
296 | STATIC long | ||
297 | xfs_file_ioctl_invis( | ||
298 | struct file *filp, | ||
299 | unsigned int cmd, | ||
300 | unsigned long p) | ||
301 | { | ||
302 | struct inode *inode = filp->f_path.dentry->d_inode; | ||
303 | |||
304 | |||
305 | /* NOTE: some of the ioctl's return positive #'s as a | ||
306 | * byte count indicating success, such as | ||
307 | * readlink_by_handle. So we don't "sign flip" | ||
308 | * like most other routines. This means true | ||
309 | * errors need to be returned as a negative value. | ||
310 | */ | ||
311 | return xfs_ioctl(XFS_I(inode), filp, IO_INVIS, cmd, (void __user *)p); | ||
312 | } | ||
313 | |||
314 | /* | 228 | /* |
315 | * mmap()d file has taken write protection fault and is being made | 229 | * mmap()d file has taken write protection fault and is being made |
316 | * writable. We can set the page state up correctly for a writable | 230 | * writable. We can set the page state up correctly for a writable |
@@ -346,25 +260,6 @@ const struct file_operations xfs_file_operations = { | |||
346 | #endif | 260 | #endif |
347 | }; | 261 | }; |
348 | 262 | ||
349 | const struct file_operations xfs_invis_file_operations = { | ||
350 | .llseek = generic_file_llseek, | ||
351 | .read = do_sync_read, | ||
352 | .write = do_sync_write, | ||
353 | .aio_read = xfs_file_aio_read_invis, | ||
354 | .aio_write = xfs_file_aio_write_invis, | ||
355 | .splice_read = xfs_file_splice_read_invis, | ||
356 | .splice_write = xfs_file_splice_write_invis, | ||
357 | .unlocked_ioctl = xfs_file_ioctl_invis, | ||
358 | #ifdef CONFIG_COMPAT | ||
359 | .compat_ioctl = xfs_file_compat_invis_ioctl, | ||
360 | #endif | ||
361 | .mmap = xfs_file_mmap, | ||
362 | .open = xfs_file_open, | ||
363 | .release = xfs_file_release, | ||
364 | .fsync = xfs_file_fsync, | ||
365 | }; | ||
366 | |||
367 | |||
368 | const struct file_operations xfs_dir_file_operations = { | 263 | const struct file_operations xfs_dir_file_operations = { |
369 | .open = xfs_dir_open, | 264 | .open = xfs_dir_open, |
370 | .read = generic_read_dir, | 265 | .read = generic_read_dir, |