]>
Commit | Line | Data |
---|---|---|
b2441318 | 1 | // SPDX-License-Identifier: GPL-2.0 |
5db11c21 MM |
2 | /* |
3 | * (C) 2001 Clemson University and The University of Chicago | |
85ac799c | 4 | * Copyright 2018 Omnibond Systems, L.L.C. |
5db11c21 MM |
5 | * |
6 | * See COPYING in top-level directory. | |
7 | */ | |
8 | ||
9 | /* | |
10 | * Linux VFS file operations. | |
11 | */ | |
12 | ||
13 | #include "protocol.h" | |
575e9461 MM |
14 | #include "orangefs-kernel.h" |
15 | #include "orangefs-bufmap.h" | |
5db11c21 MM |
16 | #include <linux/fs.h> |
17 | #include <linux/pagemap.h> | |
18 | ||
ed1e1587 MB |
19 | static int flush_racache(struct inode *inode) |
20 | { | |
21 | struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode); | |
22 | struct orangefs_kernel_op_s *new_op; | |
23 | int ret; | |
24 | ||
25 | gossip_debug(GOSSIP_UTILS_DEBUG, | |
26 | "%s: %pU: Handle is %pU | fs_id %d\n", __func__, | |
27 | get_khandle_from_ino(inode), &orangefs_inode->refn.khandle, | |
28 | orangefs_inode->refn.fs_id); | |
29 | ||
30 | new_op = op_alloc(ORANGEFS_VFS_OP_RA_FLUSH); | |
31 | if (!new_op) | |
32 | return -ENOMEM; | |
33 | new_op->upcall.req.ra_cache_flush.refn = orangefs_inode->refn; | |
34 | ||
35 | ret = service_operation(new_op, "orangefs_flush_racache", | |
36 | get_interruptible_flag(inode)); | |
37 | ||
38 | gossip_debug(GOSSIP_UTILS_DEBUG, "%s: got return value of %d\n", | |
39 | __func__, ret); | |
40 | ||
41 | op_release(new_op); | |
42 | return ret; | |
43 | } | |
44 | ||
5db11c21 MM |
45 | /* |
46 | * Post and wait for the I/O upcall to finish | |
47 | */ | |
c453dcfc | 48 | ssize_t wait_for_direct_io(enum ORANGEFS_io_type type, struct inode *inode, |
52e2d0a3 MB |
49 | loff_t *offset, struct iov_iter *iter, size_t total_size, |
50 | loff_t readahead_size, struct orangefs_write_range *wr) | |
5db11c21 | 51 | { |
8bb8aefd YL |
52 | struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode); |
53 | struct orangefs_khandle *handle = &orangefs_inode->refn.khandle; | |
8bb8aefd | 54 | struct orangefs_kernel_op_s *new_op = NULL; |
5db11c21 MM |
55 | int buffer_index = -1; |
56 | ssize_t ret; | |
57 | ||
8bb8aefd | 58 | new_op = op_alloc(ORANGEFS_VFS_OP_FILE_IO); |
ed42fe05 AV |
59 | if (!new_op) |
60 | return -ENOMEM; | |
61 | ||
5db11c21 | 62 | /* synchronous I/O */ |
5db11c21 MM |
63 | new_op->upcall.req.io.readahead_size = readahead_size; |
64 | new_op->upcall.req.io.io_type = type; | |
8bb8aefd | 65 | new_op->upcall.req.io.refn = orangefs_inode->refn; |
5db11c21 MM |
66 | |
67 | populate_shared_memory: | |
68 | /* get a shared buffer index */ | |
b8a99a8f AV |
69 | buffer_index = orangefs_bufmap_get(); |
70 | if (buffer_index < 0) { | |
71 | ret = buffer_index; | |
5db11c21 | 72 | gossip_debug(GOSSIP_FILE_DEBUG, |
b8a99a8f AV |
73 | "%s: orangefs_bufmap_get failure (%zd)\n", |
74 | __func__, ret); | |
5db11c21 MM |
75 | goto out; |
76 | } | |
77 | gossip_debug(GOSSIP_FILE_DEBUG, | |
78 | "%s(%pU): GET op %p -> buffer_index %d\n", | |
79 | __func__, | |
80 | handle, | |
81 | new_op, | |
82 | buffer_index); | |
83 | ||
84 | new_op->uses_shared_memory = 1; | |
85 | new_op->upcall.req.io.buf_index = buffer_index; | |
86 | new_op->upcall.req.io.count = total_size; | |
87 | new_op->upcall.req.io.offset = *offset; | |
52e2d0a3 MB |
88 | if (type == ORANGEFS_IO_WRITE && wr) { |
89 | new_op->upcall.uid = from_kuid(&init_user_ns, wr->uid); | |
90 | new_op->upcall.gid = from_kgid(&init_user_ns, wr->gid); | |
91 | } | |
5db11c21 MM |
92 | |
93 | gossip_debug(GOSSIP_FILE_DEBUG, | |
3c2fcfcb | 94 | "%s(%pU): offset: %llu total_size: %zd\n", |
5db11c21 MM |
95 | __func__, |
96 | handle, | |
5db11c21 MM |
97 | llu(*offset), |
98 | total_size); | |
99 | /* | |
100 | * Stage 1: copy the buffers into client-core's address space | |
5db11c21 | 101 | */ |
dbcb5e7f MB |
102 | if (type == ORANGEFS_IO_WRITE && total_size) { |
103 | ret = orangefs_bufmap_copy_from_iovec(iter, buffer_index, | |
104 | total_size); | |
105 | if (ret < 0) { | |
106 | gossip_err("%s: Failed to copy-in buffers. Please make sure that the pvfs2-client is running. %ld\n", | |
107 | __func__, (long)ret); | |
5db11c21 | 108 | goto out; |
dbcb5e7f | 109 | } |
5db11c21 MM |
110 | } |
111 | ||
112 | gossip_debug(GOSSIP_FILE_DEBUG, | |
113 | "%s(%pU): Calling post_io_request with tag (%llu)\n", | |
114 | __func__, | |
115 | handle, | |
116 | llu(new_op->tag)); | |
117 | ||
118 | /* Stage 2: Service the I/O operation */ | |
119 | ret = service_operation(new_op, | |
8bb8aefd | 120 | type == ORANGEFS_IO_WRITE ? |
5db11c21 MM |
121 | "file_write" : |
122 | "file_read", | |
123 | get_interruptible_flag(inode)); | |
124 | ||
125 | /* | |
126 | * If service_operation() returns -EAGAIN #and# the operation was | |
8bb8aefd | 127 | * purged from orangefs_request_list or htable_ops_in_progress, then |
5db11c21 MM |
128 | * we know that the client was restarted, causing the shared memory |
129 | * area to be wiped clean. To restart a write operation in this | |
130 | * case, we must re-copy the data from the user's iovec to a NEW | |
131 | * shared memory location. To restart a read operation, we must get | |
132 | * a new shared memory location. | |
133 | */ | |
134 | if (ret == -EAGAIN && op_state_purged(new_op)) { | |
1357d06d | 135 | orangefs_bufmap_put(buffer_index); |
e17be9fd | 136 | buffer_index = -1; |
7b9761af | 137 | if (type == ORANGEFS_IO_WRITE) |
c63ed807 | 138 | iov_iter_revert(iter, total_size); |
5db11c21 MM |
139 | gossip_debug(GOSSIP_FILE_DEBUG, |
140 | "%s:going to repopulate_shared_memory.\n", | |
141 | __func__); | |
142 | goto populate_shared_memory; | |
143 | } | |
144 | ||
145 | if (ret < 0) { | |
162ada77 MM |
146 | if (ret == -EINTR) { |
147 | /* | |
148 | * We can't return EINTR if any data was written, | |
149 | * it's not POSIX. It is minimally acceptable | |
150 | * to give a partial write, the way NFS does. | |
151 | * | |
152 | * It would be optimal to return all or nothing, | |
153 | * but if a userspace write is bigger than | |
154 | * an IO buffer, and the interrupt occurs | |
155 | * between buffer writes, that would not be | |
156 | * possible. | |
157 | */ | |
158 | switch (new_op->op_state - OP_VFS_STATE_GIVEN_UP) { | |
159 | /* | |
160 | * If the op was waiting when the interrupt | |
161 | * occurred, then the client-core did not | |
162 | * trigger the write. | |
163 | */ | |
164 | case OP_VFS_STATE_WAITING: | |
165 | if (*offset == 0) | |
166 | ret = -EINTR; | |
167 | else | |
168 | ret = 0; | |
169 | break; | |
95f5f88f | 170 | /* |
162ada77 MM |
171 | * If the op was in progress when the interrupt |
172 | * occurred, then the client-core was able to | |
173 | * trigger the write. | |
174 | */ | |
175 | case OP_VFS_STATE_INPROGR: | |
43f34576 MB |
176 | if (type == ORANGEFS_IO_READ) |
177 | ret = -EINTR; | |
178 | else | |
179 | ret = total_size; | |
162ada77 MM |
180 | break; |
181 | default: | |
182 | gossip_err("%s: unexpected op state :%d:.\n", | |
183 | __func__, | |
184 | new_op->op_state); | |
185 | ret = 0; | |
186 | break; | |
187 | } | |
5db11c21 | 188 | gossip_debug(GOSSIP_FILE_DEBUG, |
162ada77 MM |
189 | "%s: got EINTR, state:%d: %p\n", |
190 | __func__, | |
191 | new_op->op_state, | |
192 | new_op); | |
193 | } else { | |
5db11c21 MM |
194 | gossip_err("%s: error in %s handle %pU, returning %zd\n", |
195 | __func__, | |
8bb8aefd | 196 | type == ORANGEFS_IO_READ ? |
5db11c21 MM |
197 | "read from" : "write to", |
198 | handle, ret); | |
162ada77 | 199 | } |
78699e29 AV |
200 | if (orangefs_cancel_op_in_progress(new_op)) |
201 | return ret; | |
202 | ||
897c5df6 | 203 | goto out; |
5db11c21 MM |
204 | } |
205 | ||
206 | /* | |
207 | * Stage 3: Post copy buffers from client-core's address space | |
5db11c21 | 208 | */ |
dbcb5e7f MB |
209 | if (type == ORANGEFS_IO_READ && new_op->downcall.resp.io.amt_complete) { |
210 | /* | |
211 | * NOTE: the iovector can either contain addresses which | |
212 | * can futher be kernel-space or user-space addresses. | |
213 | * or it can pointers to struct page's | |
214 | */ | |
215 | ret = orangefs_bufmap_copy_to_iovec(iter, buffer_index, | |
216 | new_op->downcall.resp.io.amt_complete); | |
217 | if (ret < 0) { | |
218 | gossip_err("%s: Failed to copy-out buffers. Please make sure that the pvfs2-client is running (%ld)\n", | |
219 | __func__, (long)ret); | |
897c5df6 | 220 | goto out; |
dbcb5e7f | 221 | } |
5db11c21 MM |
222 | } |
223 | gossip_debug(GOSSIP_FILE_DEBUG, | |
9d9e7ba9 | 224 | "%s(%pU): Amount %s, returned by the sys-io call:%d\n", |
5db11c21 MM |
225 | __func__, |
226 | handle, | |
9d9e7ba9 | 227 | type == ORANGEFS_IO_READ ? "read" : "written", |
5db11c21 MM |
228 | (int)new_op->downcall.resp.io.amt_complete); |
229 | ||
230 | ret = new_op->downcall.resp.io.amt_complete; | |
231 | ||
5db11c21 MM |
232 | out: |
233 | if (buffer_index >= 0) { | |
1357d06d | 234 | orangefs_bufmap_put(buffer_index); |
5db11c21 MM |
235 | gossip_debug(GOSSIP_FILE_DEBUG, |
236 | "%s(%pU): PUT buffer_index %d\n", | |
237 | __func__, handle, buffer_index); | |
238 | buffer_index = -1; | |
239 | } | |
ed42fe05 | 240 | op_release(new_op); |
5db11c21 MM |
241 | return ret; |
242 | } | |
243 | ||
c453dcfc MB |
244 | static ssize_t orangefs_file_read_iter(struct kiocb *iocb, |
245 | struct iov_iter *iter) | |
5db11c21 | 246 | { |
889d5f1b | 247 | orangefs_stats.reads++; |
c453dcfc | 248 | return generic_file_read_iter(iocb, iter); |
5db11c21 MM |
249 | } |
250 | ||
85ac799c MB |
251 | static ssize_t orangefs_file_write_iter(struct kiocb *iocb, |
252 | struct iov_iter *iter) | |
5db11c21 | 253 | { |
889d5f1b | 254 | orangefs_stats.writes++; |
85ac799c | 255 | return generic_file_write_iter(iocb, iter); |
5db11c21 MM |
256 | } |
257 | ||
258 | /* | |
259 | * Perform a miscellaneous operation on a file. | |
260 | */ | |
8bb8aefd | 261 | static long orangefs_ioctl(struct file *file, unsigned int cmd, unsigned long arg) |
5db11c21 MM |
262 | { |
263 | int ret = -ENOTTY; | |
264 | __u64 val = 0; | |
265 | unsigned long uval; | |
266 | ||
267 | gossip_debug(GOSSIP_FILE_DEBUG, | |
8bb8aefd | 268 | "orangefs_ioctl: called with cmd %d\n", |
5db11c21 MM |
269 | cmd); |
270 | ||
271 | /* | |
272 | * we understand some general ioctls on files, such as the immutable | |
273 | * and append flags | |
274 | */ | |
275 | if (cmd == FS_IOC_GETFLAGS) { | |
276 | val = 0; | |
8bb8aefd | 277 | ret = orangefs_inode_getxattr(file_inode(file), |
8bb8aefd YL |
278 | "user.pvfs2.meta_hint", |
279 | &val, sizeof(val)); | |
5db11c21 MM |
280 | if (ret < 0 && ret != -ENODATA) |
281 | return ret; | |
282 | else if (ret == -ENODATA) | |
283 | val = 0; | |
284 | uval = val; | |
285 | gossip_debug(GOSSIP_FILE_DEBUG, | |
8bb8aefd | 286 | "orangefs_ioctl: FS_IOC_GETFLAGS: %llu\n", |
5db11c21 MM |
287 | (unsigned long long)uval); |
288 | return put_user(uval, (int __user *)arg); | |
289 | } else if (cmd == FS_IOC_SETFLAGS) { | |
290 | ret = 0; | |
291 | if (get_user(uval, (int __user *)arg)) | |
292 | return -EFAULT; | |
293 | /* | |
8bb8aefd | 294 | * ORANGEFS_MIRROR_FL is set internally when the mirroring mode |
5db11c21 MM |
295 | * is turned on for a file. The user is not allowed to turn |
296 | * on this bit, but the bit is present if the user first gets | |
297 | * the flags and then updates the flags with some new | |
298 | * settings. So, we ignore it in the following edit. bligon. | |
299 | */ | |
8bb8aefd | 300 | if ((uval & ~ORANGEFS_MIRROR_FL) & |
5db11c21 | 301 | (~(FS_IMMUTABLE_FL | FS_APPEND_FL | FS_NOATIME_FL))) { |
8bb8aefd | 302 | gossip_err("orangefs_ioctl: the FS_IOC_SETFLAGS only supports setting one of FS_IMMUTABLE_FL|FS_APPEND_FL|FS_NOATIME_FL\n"); |
5db11c21 MM |
303 | return -EINVAL; |
304 | } | |
305 | val = uval; | |
306 | gossip_debug(GOSSIP_FILE_DEBUG, | |
8bb8aefd | 307 | "orangefs_ioctl: FS_IOC_SETFLAGS: %llu\n", |
5db11c21 | 308 | (unsigned long long)val); |
8bb8aefd | 309 | ret = orangefs_inode_setxattr(file_inode(file), |
8bb8aefd YL |
310 | "user.pvfs2.meta_hint", |
311 | &val, sizeof(val), 0); | |
5db11c21 MM |
312 | } |
313 | ||
314 | return ret; | |
315 | } | |
316 | ||
8bf782f6 | 317 | static vm_fault_t orangefs_fault(struct vm_fault *vmf) |
a5135eea MB |
318 | { |
319 | struct file *file = vmf->vma->vm_file; | |
8bf782f6 | 320 | int ret; |
8b60785c MB |
321 | ret = orangefs_inode_getattr(file->f_mapping->host, |
322 | ORANGEFS_GETATTR_SIZE); | |
8bf782f6 SJ |
323 | if (ret == -ESTALE) |
324 | ret = -EIO; | |
325 | if (ret) { | |
8b60785c MB |
326 | gossip_err("%s: orangefs_inode_getattr failed, " |
327 | "ret:%d:.\n", __func__, ret); | |
8bf782f6 | 328 | return VM_FAULT_SIGBUS; |
a5135eea MB |
329 | } |
330 | return filemap_fault(vmf); | |
331 | } | |
332 | ||
ec62e95a | 333 | static const struct vm_operations_struct orangefs_file_vm_ops = { |
a5135eea MB |
334 | .fault = orangefs_fault, |
335 | .map_pages = filemap_map_pages, | |
52e2d0a3 | 336 | .page_mkwrite = orangefs_page_mkwrite, |
a5135eea MB |
337 | }; |
338 | ||
5db11c21 MM |
339 | /* |
340 | * Memory map a region of a file. | |
341 | */ | |
8bb8aefd | 342 | static int orangefs_file_mmap(struct file *file, struct vm_area_struct *vma) |
5db11c21 MM |
343 | { |
344 | gossip_debug(GOSSIP_FILE_DEBUG, | |
8bb8aefd | 345 | "orangefs_file_mmap: called on %s\n", |
5db11c21 MM |
346 | (file ? |
347 | (char *)file->f_path.dentry->d_name.name : | |
348 | (char *)"Unknown")); | |
349 | ||
350 | /* set the sequential readahead hint */ | |
351 | vma->vm_flags |= VM_SEQ_READ; | |
352 | vma->vm_flags &= ~VM_RAND_READ; | |
35390803 | 353 | |
a5135eea MB |
354 | file_accessed(file); |
355 | vma->vm_ops = &orangefs_file_vm_ops; | |
356 | return 0; | |
5db11c21 MM |
357 | } |
358 | ||
359 | #define mapping_nrpages(idata) ((idata)->nrpages) | |
360 | ||
361 | /* | |
362 | * Called to notify the module that there are no more references to | |
363 | * this file (i.e. no processes have it open). | |
364 | * | |
365 | * \note Not called when each file is closed. | |
366 | */ | |
8bb8aefd | 367 | static int orangefs_file_release(struct inode *inode, struct file *file) |
5db11c21 MM |
368 | { |
369 | gossip_debug(GOSSIP_FILE_DEBUG, | |
f66debf1 AV |
370 | "orangefs_file_release: called on %pD\n", |
371 | file); | |
5db11c21 | 372 | |
5db11c21 | 373 | /* |
6eaff8c7 | 374 | * remove all associated inode pages from the page cache and |
54804949 MM |
375 | * readahead cache (if any); this forces an expensive refresh of |
376 | * data for the next caller of mmap (or 'get_block' accesses) | |
5db11c21 | 377 | */ |
d62a9025 AG |
378 | if (file_inode(file) && |
379 | file_inode(file)->i_mapping && | |
380 | mapping_nrpages(&file_inode(file)->i_data)) { | |
c51e0129 MB |
381 | if (orangefs_features & ORANGEFS_FEATURE_READAHEAD) { |
382 | gossip_debug(GOSSIP_INODE_DEBUG, | |
383 | "calling flush_racache on %pU\n", | |
384 | get_khandle_from_ino(inode)); | |
385 | flush_racache(inode); | |
386 | gossip_debug(GOSSIP_INODE_DEBUG, | |
387 | "flush_racache finished\n"); | |
388 | } | |
ed1e1587 | 389 | } |
5db11c21 MM |
390 | return 0; |
391 | } | |
392 | ||
393 | /* | |
394 | * Push all data for a specific file onto permanent storage. | |
395 | */ | |
8bb8aefd | 396 | static int orangefs_fsync(struct file *file, |
84d02150 MM |
397 | loff_t start, |
398 | loff_t end, | |
399 | int datasync) | |
5db11c21 | 400 | { |
49e55713 | 401 | int ret; |
8bb8aefd | 402 | struct orangefs_inode_s *orangefs_inode = |
d62a9025 | 403 | ORANGEFS_I(file_inode(file)); |
8bb8aefd | 404 | struct orangefs_kernel_op_s *new_op = NULL; |
5db11c21 | 405 | |
85ac799c MB |
406 | ret = filemap_write_and_wait_range(file_inode(file)->i_mapping, |
407 | start, end); | |
408 | if (ret < 0) | |
409 | return ret; | |
410 | ||
8bb8aefd | 411 | new_op = op_alloc(ORANGEFS_VFS_OP_FSYNC); |
5db11c21 MM |
412 | if (!new_op) |
413 | return -ENOMEM; | |
8bb8aefd | 414 | new_op->upcall.req.fsync.refn = orangefs_inode->refn; |
5db11c21 MM |
415 | |
416 | ret = service_operation(new_op, | |
8bb8aefd | 417 | "orangefs_fsync", |
d62a9025 | 418 | get_interruptible_flag(file_inode(file))); |
5db11c21 MM |
419 | |
420 | gossip_debug(GOSSIP_FILE_DEBUG, | |
8bb8aefd | 421 | "orangefs_fsync got return value of %d\n", |
5db11c21 MM |
422 | ret); |
423 | ||
424 | op_release(new_op); | |
5db11c21 MM |
425 | return ret; |
426 | } | |
427 | ||
428 | /* | |
429 | * Change the file pointer position for an instance of an open file. | |
430 | * | |
431 | * \note If .llseek is overriden, we must acquire lock as described in | |
432 | * Documentation/filesystems/Locking. | |
433 | * | |
434 | * Future upgrade could support SEEK_DATA and SEEK_HOLE but would | |
435 | * require much changes to the FS | |
436 | */ | |
8bb8aefd | 437 | static loff_t orangefs_file_llseek(struct file *file, loff_t offset, int origin) |
5db11c21 MM |
438 | { |
439 | int ret = -EINVAL; | |
177f8fc4 | 440 | struct inode *inode = file_inode(file); |
5db11c21 | 441 | |
177f8fc4 | 442 | if (origin == SEEK_END) { |
5db11c21 MM |
443 | /* |
444 | * revalidate the inode's file size. | |
445 | * NOTE: We are only interested in file size here, | |
446 | * so we set mask accordingly. | |
447 | */ | |
8b60785c MB |
448 | ret = orangefs_inode_getattr(file->f_mapping->host, |
449 | ORANGEFS_GETATTR_SIZE); | |
e2f7f0d7 MB |
450 | if (ret == -ESTALE) |
451 | ret = -EIO; | |
5db11c21 MM |
452 | if (ret) { |
453 | gossip_debug(GOSSIP_FILE_DEBUG, | |
454 | "%s:%s:%d calling make bad inode\n", | |
455 | __FILE__, | |
456 | __func__, | |
457 | __LINE__); | |
5db11c21 MM |
458 | return ret; |
459 | } | |
460 | } | |
461 | ||
462 | gossip_debug(GOSSIP_FILE_DEBUG, | |
8bb8aefd | 463 | "orangefs_file_llseek: offset is %ld | origin is %d" |
54804949 | 464 | " | inode size is %lu\n", |
5db11c21 MM |
465 | (long)offset, |
466 | origin, | |
177f8fc4 | 467 | (unsigned long)i_size_read(inode)); |
5db11c21 MM |
468 | |
469 | return generic_file_llseek(file, offset, origin); | |
470 | } | |
471 | ||
472 | /* | |
473 | * Support local locks (locks that only this kernel knows about) | |
474 | * if Orangefs was mounted -o local_lock. | |
475 | */ | |
8bb8aefd | 476 | static int orangefs_lock(struct file *filp, int cmd, struct file_lock *fl) |
5db11c21 | 477 | { |
f957ae2d | 478 | int rc = -EINVAL; |
5db11c21 | 479 | |
45063097 | 480 | if (ORANGEFS_SB(file_inode(filp)->i_sb)->flags & ORANGEFS_OPT_LOCAL_LOCK) { |
5db11c21 MM |
481 | if (cmd == F_GETLK) { |
482 | rc = 0; | |
483 | posix_test_lock(filp, fl); | |
484 | } else { | |
485 | rc = posix_lock_file(filp, fl, NULL); | |
486 | } | |
487 | } | |
488 | ||
489 | return rc; | |
490 | } | |
491 | ||
85ac799c MB |
492 | static int orangefs_flush(struct file *file, fl_owner_t id) |
493 | { | |
90fc0706 MB |
494 | /* |
495 | * This is vfs_fsync_range(file, 0, LLONG_MAX, 0) without the | |
496 | * service_operation in orangefs_fsync. | |
497 | * | |
498 | * Do not send fsync to OrangeFS server on a close. Do send fsync | |
499 | * on an explicit fsync call. This duplicates historical OrangeFS | |
500 | * behavior. | |
501 | */ | |
502 | struct inode *inode = file->f_mapping->host; | |
503 | int r; | |
504 | ||
505 | if (inode->i_state & I_DIRTY_TIME) { | |
506 | spin_lock(&inode->i_lock); | |
507 | inode->i_state &= ~I_DIRTY_TIME; | |
508 | spin_unlock(&inode->i_lock); | |
509 | mark_inode_dirty_sync(inode); | |
510 | } | |
511 | ||
512 | r = filemap_write_and_wait_range(file->f_mapping, 0, LLONG_MAX); | |
513 | if (r > 0) | |
514 | return 0; | |
515 | else | |
516 | return r; | |
85ac799c MB |
517 | } |
518 | ||
8bb8aefd YL |
519 | /** ORANGEFS implementation of VFS file operations */ |
520 | const struct file_operations orangefs_file_operations = { | |
521 | .llseek = orangefs_file_llseek, | |
522 | .read_iter = orangefs_file_read_iter, | |
523 | .write_iter = orangefs_file_write_iter, | |
524 | .lock = orangefs_lock, | |
525 | .unlocked_ioctl = orangefs_ioctl, | |
526 | .mmap = orangefs_file_mmap, | |
5db11c21 | 527 | .open = generic_file_open, |
85ac799c | 528 | .flush = orangefs_flush, |
8bb8aefd YL |
529 | .release = orangefs_file_release, |
530 | .fsync = orangefs_fsync, | |
5db11c21 | 531 | }; |