diff options
Diffstat (limited to 'include/linux/fs.h')
-rw-r--r-- | include/linux/fs.h | 106 |
1 files changed, 93 insertions, 13 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h index 16421f662a7a..f70d52c46617 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -381,7 +381,7 @@ struct iattr { | |||
381 | * trying again. The aop will be taking reasonable | 381 | * trying again. The aop will be taking reasonable |
382 | * precautions not to livelock. If the caller held a page | 382 | * precautions not to livelock. If the caller held a page |
383 | * reference, it should drop it before retrying. Returned | 383 | * reference, it should drop it before retrying. Returned |
384 | * by readpage(), prepare_write(), and commit_write(). | 384 | * by readpage(). |
385 | * | 385 | * |
386 | * address_space_operation functions return these large constants to indicate | 386 | * address_space_operation functions return these large constants to indicate |
387 | * special semantics to the caller. These are much larger than the bytes in a | 387 | * special semantics to the caller. These are much larger than the bytes in a |
@@ -394,6 +394,9 @@ enum positive_aop_returns { | |||
394 | AOP_TRUNCATED_PAGE = 0x80001, | 394 | AOP_TRUNCATED_PAGE = 0x80001, |
395 | }; | 395 | }; |
396 | 396 | ||
397 | #define AOP_FLAG_UNINTERRUPTIBLE 0x0001 /* will not do a short write */ | ||
398 | #define AOP_FLAG_CONT_EXPAND 0x0002 /* called from cont_expand */ | ||
399 | |||
397 | /* | 400 | /* |
398 | * oh the beauties of C type declarations. | 401 | * oh the beauties of C type declarations. |
399 | */ | 402 | */ |
@@ -401,6 +404,39 @@ struct page; | |||
401 | struct address_space; | 404 | struct address_space; |
402 | struct writeback_control; | 405 | struct writeback_control; |
403 | 406 | ||
407 | struct iov_iter { | ||
408 | const struct iovec *iov; | ||
409 | unsigned long nr_segs; | ||
410 | size_t iov_offset; | ||
411 | size_t count; | ||
412 | }; | ||
413 | |||
414 | size_t iov_iter_copy_from_user_atomic(struct page *page, | ||
415 | struct iov_iter *i, unsigned long offset, size_t bytes); | ||
416 | size_t iov_iter_copy_from_user(struct page *page, | ||
417 | struct iov_iter *i, unsigned long offset, size_t bytes); | ||
418 | void iov_iter_advance(struct iov_iter *i, size_t bytes); | ||
419 | int iov_iter_fault_in_readable(struct iov_iter *i, size_t bytes); | ||
420 | size_t iov_iter_single_seg_count(struct iov_iter *i); | ||
421 | |||
422 | static inline void iov_iter_init(struct iov_iter *i, | ||
423 | const struct iovec *iov, unsigned long nr_segs, | ||
424 | size_t count, size_t written) | ||
425 | { | ||
426 | i->iov = iov; | ||
427 | i->nr_segs = nr_segs; | ||
428 | i->iov_offset = 0; | ||
429 | i->count = count + written; | ||
430 | |||
431 | iov_iter_advance(i, written); | ||
432 | } | ||
433 | |||
434 | static inline size_t iov_iter_count(struct iov_iter *i) | ||
435 | { | ||
436 | return i->count; | ||
437 | } | ||
438 | |||
439 | |||
404 | struct address_space_operations { | 440 | struct address_space_operations { |
405 | int (*writepage)(struct page *page, struct writeback_control *wbc); | 441 | int (*writepage)(struct page *page, struct writeback_control *wbc); |
406 | int (*readpage)(struct file *, struct page *); | 442 | int (*readpage)(struct file *, struct page *); |
@@ -421,6 +457,14 @@ struct address_space_operations { | |||
421 | */ | 457 | */ |
422 | int (*prepare_write)(struct file *, struct page *, unsigned, unsigned); | 458 | int (*prepare_write)(struct file *, struct page *, unsigned, unsigned); |
423 | int (*commit_write)(struct file *, struct page *, unsigned, unsigned); | 459 | int (*commit_write)(struct file *, struct page *, unsigned, unsigned); |
460 | |||
461 | int (*write_begin)(struct file *, struct address_space *mapping, | ||
462 | loff_t pos, unsigned len, unsigned flags, | ||
463 | struct page **pagep, void **fsdata); | ||
464 | int (*write_end)(struct file *, struct address_space *mapping, | ||
465 | loff_t pos, unsigned len, unsigned copied, | ||
466 | struct page *page, void *fsdata); | ||
467 | |||
424 | /* Unfortunately this kludge is needed for FIBMAP. Don't use it */ | 468 | /* Unfortunately this kludge is needed for FIBMAP. Don't use it */ |
425 | sector_t (*bmap)(struct address_space *, sector_t); | 469 | sector_t (*bmap)(struct address_space *, sector_t); |
426 | void (*invalidatepage) (struct page *, unsigned long); | 470 | void (*invalidatepage) (struct page *, unsigned long); |
@@ -435,6 +479,18 @@ struct address_space_operations { | |||
435 | int (*launder_page) (struct page *); | 479 | int (*launder_page) (struct page *); |
436 | }; | 480 | }; |
437 | 481 | ||
482 | /* | ||
483 | * pagecache_write_begin/pagecache_write_end must be used by general code | ||
484 | * to write into the pagecache. | ||
485 | */ | ||
486 | int pagecache_write_begin(struct file *, struct address_space *mapping, | ||
487 | loff_t pos, unsigned len, unsigned flags, | ||
488 | struct page **pagep, void **fsdata); | ||
489 | |||
490 | int pagecache_write_end(struct file *, struct address_space *mapping, | ||
491 | loff_t pos, unsigned len, unsigned copied, | ||
492 | struct page *page, void *fsdata); | ||
493 | |||
438 | struct backing_dev_info; | 494 | struct backing_dev_info; |
439 | struct address_space { | 495 | struct address_space { |
440 | struct inode *host; /* owner: inode, block_device */ | 496 | struct inode *host; /* owner: inode, block_device */ |
@@ -697,16 +753,14 @@ struct fown_struct { | |||
697 | * Track a single file's readahead state | 753 | * Track a single file's readahead state |
698 | */ | 754 | */ |
699 | struct file_ra_state { | 755 | struct file_ra_state { |
700 | pgoff_t start; /* where readahead started */ | 756 | pgoff_t start; /* where readahead started */ |
701 | unsigned long size; /* # of readahead pages */ | 757 | unsigned int size; /* # of readahead pages */ |
702 | unsigned long async_size; /* do asynchronous readahead when | 758 | unsigned int async_size; /* do asynchronous readahead when |
703 | there are only # of pages ahead */ | 759 | there are only # of pages ahead */ |
704 | 760 | ||
705 | unsigned long ra_pages; /* Maximum readahead window */ | 761 | unsigned int ra_pages; /* Maximum readahead window */ |
706 | unsigned long mmap_hit; /* Cache hit stat for mmap accesses */ | 762 | int mmap_miss; /* Cache miss stat for mmap accesses */ |
707 | unsigned long mmap_miss; /* Cache miss stat for mmap accesses */ | 763 | loff_t prev_pos; /* Cache last read() position */ |
708 | unsigned long prev_index; /* Cache last read() position */ | ||
709 | unsigned int prev_offset; /* Offset where last read() ended in a page */ | ||
710 | }; | 764 | }; |
711 | 765 | ||
712 | /* | 766 | /* |
@@ -883,6 +937,7 @@ extern int vfs_setlease(struct file *, long, struct file_lock **); | |||
883 | extern int lease_modify(struct file_lock **, int); | 937 | extern int lease_modify(struct file_lock **, int); |
884 | extern int lock_may_read(struct inode *, loff_t start, unsigned long count); | 938 | extern int lock_may_read(struct inode *, loff_t start, unsigned long count); |
885 | extern int lock_may_write(struct inode *, loff_t start, unsigned long count); | 939 | extern int lock_may_write(struct inode *, loff_t start, unsigned long count); |
940 | extern struct seq_operations locks_seq_operations; | ||
886 | 941 | ||
887 | struct fasync_struct { | 942 | struct fasync_struct { |
888 | int magic; | 943 | int magic; |
@@ -1302,8 +1357,14 @@ struct file_system_type { | |||
1302 | struct module *owner; | 1357 | struct module *owner; |
1303 | struct file_system_type * next; | 1358 | struct file_system_type * next; |
1304 | struct list_head fs_supers; | 1359 | struct list_head fs_supers; |
1360 | |||
1305 | struct lock_class_key s_lock_key; | 1361 | struct lock_class_key s_lock_key; |
1306 | struct lock_class_key s_umount_key; | 1362 | struct lock_class_key s_umount_key; |
1363 | |||
1364 | struct lock_class_key i_lock_key; | ||
1365 | struct lock_class_key i_mutex_key; | ||
1366 | struct lock_class_key i_mutex_dir_key; | ||
1367 | struct lock_class_key i_alloc_sem_key; | ||
1307 | }; | 1368 | }; |
1308 | 1369 | ||
1309 | extern int get_sb_bdev(struct file_system_type *fs_type, | 1370 | extern int get_sb_bdev(struct file_system_type *fs_type, |
@@ -1369,12 +1430,25 @@ extern int locks_mandatory_area(int, struct inode *, struct file *, loff_t, size | |||
1369 | * Candidates for mandatory locking have the setgid bit set | 1430 | * Candidates for mandatory locking have the setgid bit set |
1370 | * but no group execute bit - an otherwise meaningless combination. | 1431 | * but no group execute bit - an otherwise meaningless combination. |
1371 | */ | 1432 | */ |
1372 | #define MANDATORY_LOCK(inode) \ | 1433 | |
1373 | (IS_MANDLOCK(inode) && ((inode)->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID) | 1434 | static inline int __mandatory_lock(struct inode *ino) |
1435 | { | ||
1436 | return (ino->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID; | ||
1437 | } | ||
1438 | |||
1439 | /* | ||
1440 | * ... and these candidates should be on MS_MANDLOCK mounted fs, | ||
1441 | * otherwise these will be advisory locks | ||
1442 | */ | ||
1443 | |||
1444 | static inline int mandatory_lock(struct inode *ino) | ||
1445 | { | ||
1446 | return IS_MANDLOCK(ino) && __mandatory_lock(ino); | ||
1447 | } | ||
1374 | 1448 | ||
1375 | static inline int locks_verify_locked(struct inode *inode) | 1449 | static inline int locks_verify_locked(struct inode *inode) |
1376 | { | 1450 | { |
1377 | if (MANDATORY_LOCK(inode)) | 1451 | if (mandatory_lock(inode)) |
1378 | return locks_mandatory_locked(inode); | 1452 | return locks_mandatory_locked(inode); |
1379 | return 0; | 1453 | return 0; |
1380 | } | 1454 | } |
@@ -1385,7 +1459,7 @@ static inline int locks_verify_truncate(struct inode *inode, | |||
1385 | struct file *filp, | 1459 | struct file *filp, |
1386 | loff_t size) | 1460 | loff_t size) |
1387 | { | 1461 | { |
1388 | if (inode->i_flock && MANDATORY_LOCK(inode)) | 1462 | if (inode->i_flock && mandatory_lock(inode)) |
1389 | return locks_mandatory_area( | 1463 | return locks_mandatory_area( |
1390 | FLOCK_VERIFY_WRITE, inode, filp, | 1464 | FLOCK_VERIFY_WRITE, inode, filp, |
1391 | size < inode->i_size ? size : inode->i_size, | 1465 | size < inode->i_size ? size : inode->i_size, |
@@ -1815,6 +1889,12 @@ extern int simple_prepare_write(struct file *file, struct page *page, | |||
1815 | unsigned offset, unsigned to); | 1889 | unsigned offset, unsigned to); |
1816 | extern int simple_commit_write(struct file *file, struct page *page, | 1890 | extern int simple_commit_write(struct file *file, struct page *page, |
1817 | unsigned offset, unsigned to); | 1891 | unsigned offset, unsigned to); |
1892 | extern int simple_write_begin(struct file *file, struct address_space *mapping, | ||
1893 | loff_t pos, unsigned len, unsigned flags, | ||
1894 | struct page **pagep, void **fsdata); | ||
1895 | extern int simple_write_end(struct file *file, struct address_space *mapping, | ||
1896 | loff_t pos, unsigned len, unsigned copied, | ||
1897 | struct page *page, void *fsdata); | ||
1818 | 1898 | ||
1819 | extern struct dentry *simple_lookup(struct inode *, struct dentry *, struct nameidata *); | 1899 | extern struct dentry *simple_lookup(struct inode *, struct dentry *, struct nameidata *); |
1820 | extern ssize_t generic_read_dir(struct file *, char __user *, size_t, loff_t *); | 1900 | extern ssize_t generic_read_dir(struct file *, char __user *, size_t, loff_t *); |