fs.h (8c57a5e7b2820f349c95b8c8393fec1e0f4070d2) fs.h (70246286e94c335b5bea0cbc68a17a96dd620281)
1#ifndef _LINUX_FS_H
2#define _LINUX_FS_H
3
4#include <linux/linkage.h>
5#include <linux/wait.h>
6#include <linux/kdev_t.h>
7#include <linux/dcache.h>
8#include <linux/path.h>

--- 60 unchanged lines hidden (view full) ---

69extern int sysctl_protected_symlinks;
70extern int sysctl_protected_hardlinks;
71
72struct buffer_head;
73typedef int (get_block_t)(struct inode *inode, sector_t iblock,
74 struct buffer_head *bh_result, int create);
75typedef int (dio_iodone_t)(struct kiocb *iocb, loff_t offset,
76 ssize_t bytes, void *private);
1#ifndef _LINUX_FS_H
2#define _LINUX_FS_H
3
4#include <linux/linkage.h>
5#include <linux/wait.h>
6#include <linux/kdev_t.h>
7#include <linux/dcache.h>
8#include <linux/path.h>

--- 60 unchanged lines hidden (view full) ---

69extern int sysctl_protected_symlinks;
70extern int sysctl_protected_hardlinks;
71
72struct buffer_head;
73typedef int (get_block_t)(struct inode *inode, sector_t iblock,
74 struct buffer_head *bh_result, int create);
75typedef int (dio_iodone_t)(struct kiocb *iocb, loff_t offset,
76 ssize_t bytes, void *private);
77typedef void (dax_iodone_t)(struct buffer_head *bh_map, int uptodate);
78
79#define MAY_EXEC 0x00000001
80#define MAY_WRITE 0x00000002
81#define MAY_READ 0x00000004
82#define MAY_APPEND 0x00000008
83#define MAY_ACCESS 0x00000010
84#define MAY_OPEN 0x00000020
85#define MAY_CHDIR 0x00000040

--- 62 unchanged lines hidden (view full) ---

148 * Flag for rw_copy_check_uvector and compat_rw_copy_check_uvector
149 * that indicates that they should check the contents of the iovec are
150 * valid, but not check the memory that the iovec elements
151 * points too.
152 */
153#define CHECK_IOVEC_ONLY -1
154
155/*
77
78#define MAY_EXEC 0x00000001
79#define MAY_WRITE 0x00000002
80#define MAY_READ 0x00000004
81#define MAY_APPEND 0x00000008
82#define MAY_ACCESS 0x00000010
83#define MAY_OPEN 0x00000020
84#define MAY_CHDIR 0x00000040

--- 62 unchanged lines hidden (view full) ---

147 * Flag for rw_copy_check_uvector and compat_rw_copy_check_uvector
148 * that indicates that they should check the contents of the iovec are
149 * valid, but not check the memory that the iovec elements
150 * points too.
151 */
152#define CHECK_IOVEC_ONLY -1
153
154/*
156 * The below are the various read and write types that we support. Some of
155 * The below are the various read and write flags that we support. Some of
157 * them include behavioral modifiers that send information down to the
156 * them include behavioral modifiers that send information down to the
158 * block layer and IO scheduler. Terminology:
157 * block layer and IO scheduler. They should be used along with a req_op.
158 * Terminology:
159 *
160 * The block layer uses device plugging to defer IO a little bit, in
161 * the hope that we will see more IO very shortly. This increases
162 * coalescing of adjacent IO and thus reduces the number of IOs we
163 * have to send to the device. It also allows for better queuing,
164 * if the IO isn't mergeable. If the caller is going to be waiting
165 * for the IO, then he must ensure that the device is unplugged so
166 * that the IO is dispatched to the driver.

--- 6 unchanged lines hidden (view full) ---

173 * is referencing this priority hint.
174 *
175 * With that in mind, the available types are:
176 *
177 * READ A normal read operation. Device will be plugged.
178 * READ_SYNC A synchronous read. Device is not plugged, caller can
179 * immediately wait on this read without caring about
180 * unplugging.
159 *
160 * The block layer uses device plugging to defer IO a little bit, in
161 * the hope that we will see more IO very shortly. This increases
162 * coalescing of adjacent IO and thus reduces the number of IOs we
163 * have to send to the device. It also allows for better queuing,
164 * if the IO isn't mergeable. If the caller is going to be waiting
165 * for the IO, then he must ensure that the device is unplugged so
166 * that the IO is dispatched to the driver.

--- 6 unchanged lines hidden (view full) ---

173 * is referencing this priority hint.
174 *
175 * With that in mind, the available types are:
176 *
177 * READ A normal read operation. Device will be plugged.
178 * READ_SYNC A synchronous read. Device is not plugged, caller can
179 * immediately wait on this read without caring about
180 * unplugging.
181 * READA Used for read-ahead operations. Lower priority, and the
182 * block layer could (in theory) choose to ignore this
183 * request if it runs into resource problems.
184 * WRITE A normal async write. Device will be plugged.
185 * WRITE_SYNC Synchronous write. Identical to WRITE, but passes down
186 * the hint that someone will be waiting on this IO
187 * shortly. The write equivalent of READ_SYNC.
188 * WRITE_ODIRECT Special case write for O_DIRECT only.
189 * WRITE_FLUSH Like WRITE_SYNC but with preceding cache flush.
190 * WRITE_FUA Like WRITE_SYNC but data is guaranteed to be on
191 * non-volatile media on completion.
192 * WRITE_FLUSH_FUA Combination of WRITE_FLUSH and FUA. The IO is preceded
193 * by a cache flush and data is guaranteed to be on
194 * non-volatile media on completion.
195 *
196 */
181 * WRITE A normal async write. Device will be plugged.
182 * WRITE_SYNC Synchronous write. Identical to WRITE, but passes down
183 * the hint that someone will be waiting on this IO
184 * shortly. The write equivalent of READ_SYNC.
185 * WRITE_ODIRECT Special case write for O_DIRECT only.
186 * WRITE_FLUSH Like WRITE_SYNC but with preceding cache flush.
187 * WRITE_FUA Like WRITE_SYNC but data is guaranteed to be on
188 * non-volatile media on completion.
189 * WRITE_FLUSH_FUA Combination of WRITE_FLUSH and FUA. The IO is preceded
190 * by a cache flush and data is guaranteed to be on
191 * non-volatile media on completion.
192 *
193 */
197#define RW_MASK REQ_WRITE
198#define RWA_MASK REQ_RAHEAD
194#define RW_MASK REQ_OP_WRITE
199
195
200#define READ 0
201#define WRITE RW_MASK
202#define READA RWA_MASK
196#define READ REQ_OP_READ
197#define WRITE REQ_OP_WRITE
203
198
204#define READ_SYNC (READ | REQ_SYNC)
205#define WRITE_SYNC (WRITE | REQ_SYNC | REQ_NOIDLE)
206#define WRITE_ODIRECT (WRITE | REQ_SYNC)
207#define WRITE_FLUSH (WRITE | REQ_SYNC | REQ_NOIDLE | REQ_FLUSH)
208#define WRITE_FUA (WRITE | REQ_SYNC | REQ_NOIDLE | REQ_FUA)
209#define WRITE_FLUSH_FUA (WRITE | REQ_SYNC | REQ_NOIDLE | REQ_FLUSH | REQ_FUA)
199#define READ_SYNC REQ_SYNC
200#define WRITE_SYNC (REQ_SYNC | REQ_NOIDLE)
201#define WRITE_ODIRECT REQ_SYNC
202#define WRITE_FLUSH (REQ_SYNC | REQ_NOIDLE | REQ_PREFLUSH)
203#define WRITE_FUA (REQ_SYNC | REQ_NOIDLE | REQ_FUA)
204#define WRITE_FLUSH_FUA (REQ_SYNC | REQ_NOIDLE | REQ_PREFLUSH | REQ_FUA)
210
211/*
212 * Attribute flags. These should be or-ed together to figure out what
213 * has been changed!
214 */
215#define ATTR_MODE (1 << 0)
216#define ATTR_UID (1 << 1)
217#define ATTR_GID (1 << 2)

--- 100 unchanged lines hidden (view full) ---

318struct page;
319struct address_space;
320struct writeback_control;
321
322#define IOCB_EVENTFD (1 << 0)
323#define IOCB_APPEND (1 << 1)
324#define IOCB_DIRECT (1 << 2)
325#define IOCB_HIPRI (1 << 3)
205
206/*
207 * Attribute flags. These should be or-ed together to figure out what
208 * has been changed!
209 */
210#define ATTR_MODE (1 << 0)
211#define ATTR_UID (1 << 1)
212#define ATTR_GID (1 << 2)

--- 100 unchanged lines hidden (view full) ---

313struct page;
314struct address_space;
315struct writeback_control;
316
317#define IOCB_EVENTFD (1 << 0)
318#define IOCB_APPEND (1 << 1)
319#define IOCB_DIRECT (1 << 2)
320#define IOCB_HIPRI (1 << 3)
321#define IOCB_DSYNC (1 << 4)
322#define IOCB_SYNC (1 << 5)
326
327struct kiocb {
328 struct file *ki_filp;
329 loff_t ki_pos;
330 void (*ki_complete)(struct kiocb *iocb, long ret, long ret2);
331 void *private;
332 int ki_flags;
333};

--- 55 unchanged lines hidden (view full) ---

389 loff_t pos, unsigned len, unsigned copied,
390 struct page *page, void *fsdata);
391
392 /* Unfortunately this kludge is needed for FIBMAP. Don't use it */
393 sector_t (*bmap)(struct address_space *, sector_t);
394 void (*invalidatepage) (struct page *, unsigned int, unsigned int);
395 int (*releasepage) (struct page *, gfp_t);
396 void (*freepage)(struct page *);
323
324struct kiocb {
325 struct file *ki_filp;
326 loff_t ki_pos;
327 void (*ki_complete)(struct kiocb *iocb, long ret, long ret2);
328 void *private;
329 int ki_flags;
330};

--- 55 unchanged lines hidden (view full) ---

386 loff_t pos, unsigned len, unsigned copied,
387 struct page *page, void *fsdata);
388
389 /* Unfortunately this kludge is needed for FIBMAP. Don't use it */
390 sector_t (*bmap)(struct address_space *, sector_t);
391 void (*invalidatepage) (struct page *, unsigned int, unsigned int);
392 int (*releasepage) (struct page *, gfp_t);
393 void (*freepage)(struct page *);
397 ssize_t (*direct_IO)(struct kiocb *, struct iov_iter *iter, loff_t offset);
394 ssize_t (*direct_IO)(struct kiocb *, struct iov_iter *iter);
398 /*
399 * migrate the contents of a page to the specified target. If
400 * migrate_mode is MIGRATE_ASYNC, it must not block.
401 */
402 int (*migratepage) (struct address_space *,
403 struct page *, struct page *, enum migrate_mode);
404 int (*launder_page) (struct page *);
405 int (*is_partially_uptodate) (struct page *, unsigned long,

--- 166 unchanged lines hidden (view full) ---

572#define i_size_ordered_init(inode) seqcount_init(&inode->i_size_seqcount)
573#else
574#define i_size_ordered_init(inode) do { } while (0)
575#endif
576
577struct posix_acl;
578#define ACL_NOT_CACHED ((void *)(-1))
579
395 /*
396 * migrate the contents of a page to the specified target. If
397 * migrate_mode is MIGRATE_ASYNC, it must not block.
398 */
399 int (*migratepage) (struct address_space *,
400 struct page *, struct page *, enum migrate_mode);
401 int (*launder_page) (struct page *);
402 int (*is_partially_uptodate) (struct page *, unsigned long,

--- 166 unchanged lines hidden (view full) ---

569#define i_size_ordered_init(inode) seqcount_init(&inode->i_size_seqcount)
570#else
571#define i_size_ordered_init(inode) do { } while (0)
572#endif
573
574struct posix_acl;
575#define ACL_NOT_CACHED ((void *)(-1))
576
577static inline struct posix_acl *
578uncached_acl_sentinel(struct task_struct *task)
579{
580 return (void *)task + 1;
581}
582
583static inline bool
584is_uncached_acl(struct posix_acl *acl)
585{
586 return (long)acl & 1;
587}
588
580#define IOP_FASTPERM 0x0001
581#define IOP_LOOKUP 0x0002
582#define IOP_NOFOLLOW 0x0004
583
584/*
585 * Keep mostly read-only and often accessed (especially for
586 * the RCU path lookup and 'stat' data) fields at the beginning
587 * of the 'struct inode'

--- 42 unchanged lines hidden (view full) ---

630 blkcnt_t i_blocks;
631
632#ifdef __NEED_I_SIZE_ORDERED
633 seqcount_t i_size_seqcount;
634#endif
635
636 /* Misc */
637 unsigned long i_state;
589#define IOP_FASTPERM 0x0001
590#define IOP_LOOKUP 0x0002
591#define IOP_NOFOLLOW 0x0004
592
593/*
594 * Keep mostly read-only and often accessed (especially for
595 * the RCU path lookup and 'stat' data) fields at the beginning
596 * of the 'struct inode'

--- 42 unchanged lines hidden (view full) ---

639 blkcnt_t i_blocks;
640
641#ifdef __NEED_I_SIZE_ORDERED
642 seqcount_t i_size_seqcount;
643#endif
644
645 /* Misc */
646 unsigned long i_state;
638 struct mutex i_mutex;
647 struct rw_semaphore i_rwsem;
639
640 unsigned long dirtied_when; /* jiffies of first dirtying */
641 unsigned long dirtied_time_when;
642
643 struct hlist_node i_hash;
644 struct list_head i_io_list; /* backing dev IO list */
645#ifdef CONFIG_CGROUP_WRITEBACK
646 struct bdi_writeback *i_wb; /* the associated cgroup wb */

--- 20 unchanged lines hidden (view full) ---

667 struct file_lock_context *i_flctx;
668 struct address_space i_data;
669 struct list_head i_devices;
670 union {
671 struct pipe_inode_info *i_pipe;
672 struct block_device *i_bdev;
673 struct cdev *i_cdev;
674 char *i_link;
648
649 unsigned long dirtied_when; /* jiffies of first dirtying */
650 unsigned long dirtied_time_when;
651
652 struct hlist_node i_hash;
653 struct list_head i_io_list; /* backing dev IO list */
654#ifdef CONFIG_CGROUP_WRITEBACK
655 struct bdi_writeback *i_wb; /* the associated cgroup wb */

--- 20 unchanged lines hidden (view full) ---

676 struct file_lock_context *i_flctx;
677 struct address_space i_data;
678 struct list_head i_devices;
679 union {
680 struct pipe_inode_info *i_pipe;
681 struct block_device *i_bdev;
682 struct cdev *i_cdev;
683 char *i_link;
684 unsigned i_dir_seq;
675 };
676
677 __u32 i_generation;
678
679#ifdef CONFIG_FSNOTIFY
680 __u32 i_fsnotify_mask; /* all events this inode cares about */
681 struct hlist_head i_fsnotify_marks;
682#endif

--- 33 unchanged lines hidden (view full) ---

716 I_MUTEX_CHILD,
717 I_MUTEX_XATTR,
718 I_MUTEX_NONDIR2,
719 I_MUTEX_PARENT2,
720};
721
722static inline void inode_lock(struct inode *inode)
723{
685 };
686
687 __u32 i_generation;
688
689#ifdef CONFIG_FSNOTIFY
690 __u32 i_fsnotify_mask; /* all events this inode cares about */
691 struct hlist_head i_fsnotify_marks;
692#endif

--- 33 unchanged lines hidden (view full) ---

726 I_MUTEX_CHILD,
727 I_MUTEX_XATTR,
728 I_MUTEX_NONDIR2,
729 I_MUTEX_PARENT2,
730};
731
732static inline void inode_lock(struct inode *inode)
733{
724 mutex_lock(&inode->i_mutex);
734 down_write(&inode->i_rwsem);
725}
726
727static inline void inode_unlock(struct inode *inode)
728{
735}
736
737static inline void inode_unlock(struct inode *inode)
738{
729 mutex_unlock(&inode->i_mutex);
739 up_write(&inode->i_rwsem);
730}
731
740}
741
742static inline void inode_lock_shared(struct inode *inode)
743{
744 down_read(&inode->i_rwsem);
745}
746
747static inline void inode_unlock_shared(struct inode *inode)
748{
749 up_read(&inode->i_rwsem);
750}
751
732static inline int inode_trylock(struct inode *inode)
733{
752static inline int inode_trylock(struct inode *inode)
753{
734 return mutex_trylock(&inode->i_mutex);
754 return down_write_trylock(&inode->i_rwsem);
735}
736
755}
756
757static inline int inode_trylock_shared(struct inode *inode)
758{
759 return down_read_trylock(&inode->i_rwsem);
760}
761
737static inline int inode_is_locked(struct inode *inode)
738{
762static inline int inode_is_locked(struct inode *inode)
763{
739 return mutex_is_locked(&inode->i_mutex);
764 return rwsem_is_locked(&inode->i_rwsem);
740}
741
742static inline void inode_lock_nested(struct inode *inode, unsigned subclass)
743{
765}
766
767static inline void inode_lock_nested(struct inode *inode, unsigned subclass)
768{
744 mutex_lock_nested(&inode->i_mutex, subclass);
769 down_write_nested(&inode->i_rwsem, subclass);
745}
746
747void lock_two_nondirectories(struct inode *, struct inode*);
748void unlock_two_nondirectories(struct inode *, struct inode*);
749
750/*
751 * NOTE: in a 32bit arch with a preemptable kernel and
752 * an UP compile the i_size_read/write must be atomic

--- 888 unchanged lines hidden (view full) ---

1641struct file_operations {
1642 struct module *owner;
1643 loff_t (*llseek) (struct file *, loff_t, int);
1644 ssize_t (*read) (struct file *, char __user *, size_t, loff_t *);
1645 ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);
1646 ssize_t (*read_iter) (struct kiocb *, struct iov_iter *);
1647 ssize_t (*write_iter) (struct kiocb *, struct iov_iter *);
1648 int (*iterate) (struct file *, struct dir_context *);
770}
771
772void lock_two_nondirectories(struct inode *, struct inode*);
773void unlock_two_nondirectories(struct inode *, struct inode*);
774
775/*
776 * NOTE: in a 32bit arch with a preemptable kernel and
777 * an UP compile the i_size_read/write must be atomic

--- 888 unchanged lines hidden (view full) ---

1666struct file_operations {
1667 struct module *owner;
1668 loff_t (*llseek) (struct file *, loff_t, int);
1669 ssize_t (*read) (struct file *, char __user *, size_t, loff_t *);
1670 ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);
1671 ssize_t (*read_iter) (struct kiocb *, struct iov_iter *);
1672 ssize_t (*write_iter) (struct kiocb *, struct iov_iter *);
1673 int (*iterate) (struct file *, struct dir_context *);
1674 int (*iterate_shared) (struct file *, struct dir_context *);
1649 unsigned int (*poll) (struct file *, struct poll_table_struct *);
1650 long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
1651 long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
1652 int (*mmap) (struct file *, struct vm_area_struct *);
1653 int (*open) (struct inode *, struct file *);
1654 int (*flush) (struct file *, fl_owner_t id);
1655 int (*release) (struct inode *, struct file *);
1656 int (*fsync) (struct file *, loff_t, loff_t, int datasync);

--- 37 unchanged lines hidden (view full) ---

1694 int (*rmdir) (struct inode *,struct dentry *);
1695 int (*mknod) (struct inode *,struct dentry *,umode_t,dev_t);
1696 int (*rename) (struct inode *, struct dentry *,
1697 struct inode *, struct dentry *);
1698 int (*rename2) (struct inode *, struct dentry *,
1699 struct inode *, struct dentry *, unsigned int);
1700 int (*setattr) (struct dentry *, struct iattr *);
1701 int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *);
1675 unsigned int (*poll) (struct file *, struct poll_table_struct *);
1676 long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
1677 long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
1678 int (*mmap) (struct file *, struct vm_area_struct *);
1679 int (*open) (struct inode *, struct file *);
1680 int (*flush) (struct file *, fl_owner_t id);
1681 int (*release) (struct inode *, struct file *);
1682 int (*fsync) (struct file *, loff_t, loff_t, int datasync);

--- 37 unchanged lines hidden (view full) ---

1720 int (*rmdir) (struct inode *,struct dentry *);
1721 int (*mknod) (struct inode *,struct dentry *,umode_t,dev_t);
1722 int (*rename) (struct inode *, struct dentry *,
1723 struct inode *, struct dentry *);
1724 int (*rename2) (struct inode *, struct dentry *,
1725 struct inode *, struct dentry *, unsigned int);
1726 int (*setattr) (struct dentry *, struct iattr *);
1727 int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *);
1702 int (*setxattr) (struct dentry *, const char *,const void *,size_t,int);
1703 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
1728 int (*setxattr) (struct dentry *, struct inode *,
1729 const char *, const void *, size_t, int);
1730 ssize_t (*getxattr) (struct dentry *, struct inode *,
1731 const char *, void *, size_t);
1704 ssize_t (*listxattr) (struct dentry *, char *, size_t);
1705 int (*removexattr) (struct dentry *, const char *);
1706 int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start,
1707 u64 len);
1708 int (*update_time)(struct inode *, struct timespec *, int);
1709 int (*atomic_open)(struct inode *, struct dentry *,
1710 struct file *, unsigned open_flag,
1711 umode_t create_mode, int *opened);

--- 546 unchanged lines hidden (view full) ---

2258struct filename {
2259 const char *name; /* pointer to actual string */
2260 const __user char *uptr; /* original userland pointer */
2261 struct audit_names *aname;
2262 int refcnt;
2263 const char iname[];
2264};
2265
1732 ssize_t (*listxattr) (struct dentry *, char *, size_t);
1733 int (*removexattr) (struct dentry *, const char *);
1734 int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start,
1735 u64 len);
1736 int (*update_time)(struct inode *, struct timespec *, int);
1737 int (*atomic_open)(struct inode *, struct dentry *,
1738 struct file *, unsigned open_flag,
1739 umode_t create_mode, int *opened);

--- 546 unchanged lines hidden (view full) ---

2286struct filename {
2287 const char *name; /* pointer to actual string */
2288 const __user char *uptr; /* original userland pointer */
2289 struct audit_names *aname;
2290 int refcnt;
2291 const char iname[];
2292};
2293
2266extern long vfs_truncate(struct path *, loff_t);
2294extern long vfs_truncate(const struct path *, loff_t);
2267extern int do_truncate(struct dentry *, loff_t start, unsigned int time_attrs,
2268 struct file *filp);
2269extern int vfs_fallocate(struct file *file, int mode, loff_t offset,
2270 loff_t len);
2271extern long do_sys_open(int dfd, const char __user *filename, int flags,
2272 umode_t mode);
2273extern struct file *file_open_name(struct filename *, int, umode_t);
2274extern struct file *filp_open(const char *, int, umode_t);

--- 40 unchanged lines hidden (view full) ---

2315extern void invalidate_bdev(struct block_device *);
2316extern void iterate_bdevs(void (*)(struct block_device *, void *), void *);
2317extern int sync_blockdev(struct block_device *bdev);
2318extern void kill_bdev(struct block_device *);
2319extern struct super_block *freeze_bdev(struct block_device *);
2320extern void emergency_thaw_all(void);
2321extern int thaw_bdev(struct block_device *bdev, struct super_block *sb);
2322extern int fsync_bdev(struct block_device *);
2295extern int do_truncate(struct dentry *, loff_t start, unsigned int time_attrs,
2296 struct file *filp);
2297extern int vfs_fallocate(struct file *file, int mode, loff_t offset,
2298 loff_t len);
2299extern long do_sys_open(int dfd, const char __user *filename, int flags,
2300 umode_t mode);
2301extern struct file *file_open_name(struct filename *, int, umode_t);
2302extern struct file *filp_open(const char *, int, umode_t);

--- 40 unchanged lines hidden (view full) ---

2343extern void invalidate_bdev(struct block_device *);
2344extern void iterate_bdevs(void (*)(struct block_device *, void *), void *);
2345extern int sync_blockdev(struct block_device *bdev);
2346extern void kill_bdev(struct block_device *);
2347extern struct super_block *freeze_bdev(struct block_device *);
2348extern void emergency_thaw_all(void);
2349extern int thaw_bdev(struct block_device *bdev, struct super_block *sb);
2350extern int fsync_bdev(struct block_device *);
2323#ifdef CONFIG_FS_DAX
2324extern bool blkdev_dax_capable(struct block_device *bdev);
2325#else
2326static inline bool blkdev_dax_capable(struct block_device *bdev)
2327{
2328 return false;
2329}
2330#endif
2331
2332extern struct super_block *blockdev_superblock;
2333
2334static inline bool sb_is_blkdev_sb(struct super_block *sb)
2335{
2336 return sb == blockdev_superblock;
2337}
2338#else

--- 51 unchanged lines hidden (view full) ---

2390 struct gendisk *disk)
2391{
2392}
2393#endif
2394#endif
2395
2396/* fs/char_dev.c */
2397#define CHRDEV_MAJOR_HASH_SIZE 255
2351
2352extern struct super_block *blockdev_superblock;
2353
2354static inline bool sb_is_blkdev_sb(struct super_block *sb)
2355{
2356 return sb == blockdev_superblock;
2357}
2358#else

--- 51 unchanged lines hidden (view full) ---

2410 struct gendisk *disk)
2411{
2412}
2413#endif
2414#endif
2415
2416/* fs/char_dev.c */
2417#define CHRDEV_MAJOR_HASH_SIZE 255
2418/* Marks the bottom of the first segment of free char majors */
2419#define CHRDEV_MAJOR_DYN_END 234
2398extern int alloc_chrdev_region(dev_t *, unsigned, unsigned, const char *);
2399extern int register_chrdev_region(dev_t, unsigned, const char *);
2400extern int __register_chrdev(unsigned int major, unsigned int baseminor,
2401 unsigned int count, const char *name,
2402 const struct file_operations *fops);
2403extern void __unregister_chrdev(unsigned int major, unsigned int baseminor,
2404 unsigned int count, const char *name);
2405extern void unregister_chrdev_region(dev_t, unsigned);

--- 27 unchanged lines hidden (view full) ---

2433
2434extern void init_special_inode(struct inode *, umode_t, dev_t);
2435
2436/* Invalid inode operations -- fs/bad_inode.c */
2437extern void make_bad_inode(struct inode *);
2438extern bool is_bad_inode(struct inode *);
2439
2440#ifdef CONFIG_BLOCK
2420extern int alloc_chrdev_region(dev_t *, unsigned, unsigned, const char *);
2421extern int register_chrdev_region(dev_t, unsigned, const char *);
2422extern int __register_chrdev(unsigned int major, unsigned int baseminor,
2423 unsigned int count, const char *name,
2424 const struct file_operations *fops);
2425extern void __unregister_chrdev(unsigned int major, unsigned int baseminor,
2426 unsigned int count, const char *name);
2427extern void unregister_chrdev_region(dev_t, unsigned);

--- 27 unchanged lines hidden (view full) ---

2455
2456extern void init_special_inode(struct inode *, umode_t, dev_t);
2457
2458/* Invalid inode operations -- fs/bad_inode.c */
2459extern void make_bad_inode(struct inode *);
2460extern bool is_bad_inode(struct inode *);
2461
2462#ifdef CONFIG_BLOCK
2441/*
2442 * return READ, READA, or WRITE
2443 */
2444#define bio_rw(bio) ((bio)->bi_rw & (RW_MASK | RWA_MASK))
2463static inline bool op_is_write(unsigned int op)
2464{
2465 return op == REQ_OP_READ ? false : true;
2466}
2445
2446/*
2447 * return data direction, READ or WRITE
2448 */
2467
2468/*
2469 * return data direction, READ or WRITE
2470 */
2449#define bio_data_dir(bio) ((bio)->bi_rw & 1)
2471static inline int bio_data_dir(struct bio *bio)
2472{
2473 return op_is_write(bio_op(bio)) ? WRITE : READ;
2474}
2450
2451extern void check_disk_size_change(struct gendisk *disk,
2452 struct block_device *bdev);
2453extern int revalidate_disk(struct gendisk *);
2454extern int check_disk_change(struct block_device *);
2455extern int __invalidate_device(struct block_device *, bool);
2456extern int invalidate_partition(struct gendisk *, int);
2457#endif

--- 22 unchanged lines hidden (view full) ---

2480extern int __filemap_fdatawrite_range(struct address_space *mapping,
2481 loff_t start, loff_t end, int sync_mode);
2482extern int filemap_fdatawrite_range(struct address_space *mapping,
2483 loff_t start, loff_t end);
2484
2485extern int vfs_fsync_range(struct file *file, loff_t start, loff_t end,
2486 int datasync);
2487extern int vfs_fsync(struct file *file, int datasync);
2475
2476extern void check_disk_size_change(struct gendisk *disk,
2477 struct block_device *bdev);
2478extern int revalidate_disk(struct gendisk *);
2479extern int check_disk_change(struct block_device *);
2480extern int __invalidate_device(struct block_device *, bool);
2481extern int invalidate_partition(struct gendisk *, int);
2482#endif

--- 22 unchanged lines hidden (view full) ---

2505extern int __filemap_fdatawrite_range(struct address_space *mapping,
2506 loff_t start, loff_t end, int sync_mode);
2507extern int filemap_fdatawrite_range(struct address_space *mapping,
2508 loff_t start, loff_t end);
2509
2510extern int vfs_fsync_range(struct file *file, loff_t start, loff_t end,
2511 int datasync);
2512extern int vfs_fsync(struct file *file, int datasync);
2488static inline int generic_write_sync(struct file *file, loff_t pos, loff_t count)
2513
2514/*
2515 * Sync the bytes written if this was a synchronous write. Expect ki_pos
2516 * to already be updated for the write, and will return either the amount
2517 * of bytes passed in, or an error if syncing the file failed.
2518 */
2519static inline ssize_t generic_write_sync(struct kiocb *iocb, ssize_t count)
2489{
2520{
2490 if (!(file->f_flags & O_DSYNC) && !IS_SYNC(file->f_mapping->host))
2491 return 0;
2492 return vfs_fsync_range(file, pos, pos + count - 1,
2493 (file->f_flags & __O_SYNC) ? 0 : 1);
2521 if (iocb->ki_flags & IOCB_DSYNC) {
2522 int ret = vfs_fsync_range(iocb->ki_filp,
2523 iocb->ki_pos - count, iocb->ki_pos - 1,
2524 (iocb->ki_flags & IOCB_SYNC) ? 0 : 1);
2525 if (ret)
2526 return ret;
2527 }
2528
2529 return count;
2494}
2530}
2531
2495extern void emergency_sync(void);
2496extern void emergency_remount(void);
2497#ifdef CONFIG_BLOCK
2498extern sector_t bmap(struct inode *, sector_t);
2499#endif
2500extern int notify_change(struct dentry *, struct iattr *, struct inode **);
2501extern int inode_permission(struct inode *, int);
2502extern int __inode_permission(struct inode *, int);

--- 82 unchanged lines hidden (view full) ---

2585}
2586static inline void i_readcount_inc(struct inode *inode)
2587{
2588 return;
2589}
2590#endif
2591extern int do_pipe_flags(int *, int);
2592
2532extern void emergency_sync(void);
2533extern void emergency_remount(void);
2534#ifdef CONFIG_BLOCK
2535extern sector_t bmap(struct inode *, sector_t);
2536#endif
2537extern int notify_change(struct dentry *, struct iattr *, struct inode **);
2538extern int inode_permission(struct inode *, int);
2539extern int __inode_permission(struct inode *, int);

--- 82 unchanged lines hidden (view full) ---

2622}
2623static inline void i_readcount_inc(struct inode *inode)
2624{
2625 return;
2626}
2627#endif
2628extern int do_pipe_flags(int *, int);
2629
2630#define __kernel_read_file_id(id) \
2631 id(UNKNOWN, unknown) \
2632 id(FIRMWARE, firmware) \
2633 id(MODULE, kernel-module) \
2634 id(KEXEC_IMAGE, kexec-image) \
2635 id(KEXEC_INITRAMFS, kexec-initramfs) \
2636 id(POLICY, security-policy) \
2637 id(MAX_ID, )
2638
2639#define __fid_enumify(ENUM, dummy) READING_ ## ENUM,
2640#define __fid_stringify(dummy, str) #str,
2641
2593enum kernel_read_file_id {
2642enum kernel_read_file_id {
2594 READING_FIRMWARE = 1,
2595 READING_MODULE,
2596 READING_KEXEC_IMAGE,
2597 READING_KEXEC_INITRAMFS,
2598 READING_POLICY,
2599 READING_MAX_ID
2643 __kernel_read_file_id(__fid_enumify)
2600};
2601
2644};
2645
2646static const char * const kernel_read_file_str[] = {
2647 __kernel_read_file_id(__fid_stringify)
2648};
2649
2650static inline const char *kernel_read_file_id_str(enum kernel_read_file_id id)
2651{
2652 if (id < 0 || id >= READING_MAX_ID)
2653 return kernel_read_file_str[READING_UNKNOWN];
2654
2655 return kernel_read_file_str[id];
2656}
2657
2602extern int kernel_read(struct file *, loff_t, char *, unsigned long);
2603extern int kernel_read_file(struct file *, void **, loff_t *, loff_t,
2604 enum kernel_read_file_id);
2605extern int kernel_read_file_from_path(char *, void **, loff_t *, loff_t,
2606 enum kernel_read_file_id);
2607extern int kernel_read_file_from_fd(int, void **, loff_t *, loff_t,
2608 enum kernel_read_file_id);
2609extern ssize_t kernel_write(struct file *, const char *, size_t, loff_t);

--- 75 unchanged lines hidden (view full) ---

2685{
2686 if (!inode_unhashed(inode) && !hlist_fake(&inode->i_hash))
2687 __remove_inode_hash(inode);
2688}
2689
2690extern void inode_sb_list_add(struct inode *inode);
2691
2692#ifdef CONFIG_BLOCK
2658extern int kernel_read(struct file *, loff_t, char *, unsigned long);
2659extern int kernel_read_file(struct file *, void **, loff_t *, loff_t,
2660 enum kernel_read_file_id);
2661extern int kernel_read_file_from_path(char *, void **, loff_t *, loff_t,
2662 enum kernel_read_file_id);
2663extern int kernel_read_file_from_fd(int, void **, loff_t *, loff_t,
2664 enum kernel_read_file_id);
2665extern ssize_t kernel_write(struct file *, const char *, size_t, loff_t);

--- 75 unchanged lines hidden (view full) ---

2741{
2742 if (!inode_unhashed(inode) && !hlist_fake(&inode->i_hash))
2743 __remove_inode_hash(inode);
2744}
2745
2746extern void inode_sb_list_add(struct inode *inode);
2747
2748#ifdef CONFIG_BLOCK
2693extern blk_qc_t submit_bio(int, struct bio *);
2749extern blk_qc_t submit_bio(struct bio *);
2694extern int bdev_read_only(struct block_device *);
2695#endif
2696extern int set_blocksize(struct block_device *, int);
2697extern int sb_set_blocksize(struct super_block *, int);
2698extern int sb_min_blocksize(struct super_block *, int);
2699
2700extern int generic_file_mmap(struct file *, struct vm_area_struct *);
2701extern int generic_file_readonly_mmap(struct file *, struct vm_area_struct *);
2702extern ssize_t generic_write_checks(struct kiocb *, struct iov_iter *);
2703extern ssize_t generic_file_read_iter(struct kiocb *, struct iov_iter *);
2704extern ssize_t __generic_file_write_iter(struct kiocb *, struct iov_iter *);
2705extern ssize_t generic_file_write_iter(struct kiocb *, struct iov_iter *);
2750extern int bdev_read_only(struct block_device *);
2751#endif
2752extern int set_blocksize(struct block_device *, int);
2753extern int sb_set_blocksize(struct super_block *, int);
2754extern int sb_min_blocksize(struct super_block *, int);
2755
2756extern int generic_file_mmap(struct file *, struct vm_area_struct *);
2757extern int generic_file_readonly_mmap(struct file *, struct vm_area_struct *);
2758extern ssize_t generic_write_checks(struct kiocb *, struct iov_iter *);
2759extern ssize_t generic_file_read_iter(struct kiocb *, struct iov_iter *);
2760extern ssize_t __generic_file_write_iter(struct kiocb *, struct iov_iter *);
2761extern ssize_t generic_file_write_iter(struct kiocb *, struct iov_iter *);
2706extern ssize_t generic_file_direct_write(struct kiocb *, struct iov_iter *, loff_t);
2762extern ssize_t generic_file_direct_write(struct kiocb *, struct iov_iter *);
2707extern ssize_t generic_perform_write(struct file *, struct iov_iter *, loff_t);
2708
2709ssize_t vfs_iter_read(struct file *file, struct iov_iter *iter, loff_t *ppos);
2710ssize_t vfs_iter_write(struct file *file, struct iov_iter *iter, loff_t *ppos);
2711
2712/* fs/block_dev.c */
2713extern ssize_t blkdev_read_iter(struct kiocb *iocb, struct iov_iter *to);
2714extern ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from);

--- 25 unchanged lines hidden (view full) ---

2740extern loff_t fixed_size_llseek(struct file *file, loff_t offset,
2741 int whence, loff_t size);
2742extern loff_t no_seek_end_llseek_size(struct file *, loff_t, int, loff_t);
2743extern loff_t no_seek_end_llseek(struct file *, loff_t, int);
2744extern int generic_file_open(struct inode * inode, struct file * filp);
2745extern int nonseekable_open(struct inode * inode, struct file * filp);
2746
2747#ifdef CONFIG_BLOCK
2763extern ssize_t generic_perform_write(struct file *, struct iov_iter *, loff_t);
2764
2765ssize_t vfs_iter_read(struct file *file, struct iov_iter *iter, loff_t *ppos);
2766ssize_t vfs_iter_write(struct file *file, struct iov_iter *iter, loff_t *ppos);
2767
2768/* fs/block_dev.c */
2769extern ssize_t blkdev_read_iter(struct kiocb *iocb, struct iov_iter *to);
2770extern ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from);

--- 25 unchanged lines hidden (view full) ---

2796extern loff_t fixed_size_llseek(struct file *file, loff_t offset,
2797 int whence, loff_t size);
2798extern loff_t no_seek_end_llseek_size(struct file *, loff_t, int, loff_t);
2799extern loff_t no_seek_end_llseek(struct file *, loff_t, int);
2800extern int generic_file_open(struct inode * inode, struct file * filp);
2801extern int nonseekable_open(struct inode * inode, struct file * filp);
2802
2803#ifdef CONFIG_BLOCK
2748typedef void (dio_submit_t)(int rw, struct bio *bio, struct inode *inode,
2804typedef void (dio_submit_t)(struct bio *bio, struct inode *inode,
2749 loff_t file_offset);
2750
2751enum {
2752 /* need locking between buffered and direct access */
2753 DIO_LOCKING = 0x01,
2754
2755 /* filesystem does not support filling holes */
2756 DIO_SKIP_HOLES = 0x02,

--- 4 unchanged lines hidden (view full) ---

2761 /* inode/fs/bdev does not need truncate protection */
2762 DIO_SKIP_DIO_COUNT = 0x08,
2763};
2764
2765void dio_end_io(struct bio *bio, int error);
2766
2767ssize_t __blockdev_direct_IO(struct kiocb *iocb, struct inode *inode,
2768 struct block_device *bdev, struct iov_iter *iter,
2805 loff_t file_offset);
2806
2807enum {
2808 /* need locking between buffered and direct access */
2809 DIO_LOCKING = 0x01,
2810
2811 /* filesystem does not support filling holes */
2812 DIO_SKIP_HOLES = 0x02,

--- 4 unchanged lines hidden (view full) ---

2817 /* inode/fs/bdev does not need truncate protection */
2818 DIO_SKIP_DIO_COUNT = 0x08,
2819};
2820
2821void dio_end_io(struct bio *bio, int error);
2822
2823ssize_t __blockdev_direct_IO(struct kiocb *iocb, struct inode *inode,
2824 struct block_device *bdev, struct iov_iter *iter,
2769 loff_t offset, get_block_t get_block,
2825 get_block_t get_block,
2770 dio_iodone_t end_io, dio_submit_t submit_io,
2771 int flags);
2772
2773static inline ssize_t blockdev_direct_IO(struct kiocb *iocb,
2774 struct inode *inode,
2826 dio_iodone_t end_io, dio_submit_t submit_io,
2827 int flags);
2828
2829static inline ssize_t blockdev_direct_IO(struct kiocb *iocb,
2830 struct inode *inode,
2775 struct iov_iter *iter, loff_t offset,
2831 struct iov_iter *iter,
2776 get_block_t get_block)
2777{
2778 return __blockdev_direct_IO(iocb, inode, inode->i_sb->s_bdev, iter,
2832 get_block_t get_block)
2833{
2834 return __blockdev_direct_IO(iocb, inode, inode->i_sb->s_bdev, iter,
2779 offset, get_block, NULL, NULL,
2780 DIO_LOCKING | DIO_SKIP_HOLES);
2835 get_block, NULL, NULL, DIO_LOCKING | DIO_SKIP_HOLES);
2781}
2782#endif
2783
2784void inode_dio_wait(struct inode *inode);
2785
2786/*
2787 * inode_dio_begin - signal start of a direct I/O requests
2788 * @inode: inode the direct I/O happens on

--- 149 unchanged lines hidden (view full) ---

2938
2939static inline int iocb_flags(struct file *file)
2940{
2941 int res = 0;
2942 if (file->f_flags & O_APPEND)
2943 res |= IOCB_APPEND;
2944 if (io_is_direct(file))
2945 res |= IOCB_DIRECT;
2836}
2837#endif
2838
2839void inode_dio_wait(struct inode *inode);
2840
2841/*
2842 * inode_dio_begin - signal start of a direct I/O requests
2843 * @inode: inode the direct I/O happens on

--- 149 unchanged lines hidden (view full) ---

2993
2994static inline int iocb_flags(struct file *file)
2995{
2996 int res = 0;
2997 if (file->f_flags & O_APPEND)
2998 res |= IOCB_APPEND;
2999 if (io_is_direct(file))
3000 res |= IOCB_DIRECT;
3001 if ((file->f_flags & O_DSYNC) || IS_SYNC(file->f_mapping->host))
3002 res |= IOCB_DSYNC;
3003 if (file->f_flags & __O_SYNC)
3004 res |= IOCB_SYNC;
2946 return res;
2947}
2948
2949static inline ino_t parent_ino(struct dentry *dentry)
2950{
2951 ino_t res;
2952
2953 /*

--- 145 unchanged lines hidden (view full) ---

3099}
3100static inline bool dir_relax(struct inode *inode)
3101{
3102 inode_unlock(inode);
3103 inode_lock(inode);
3104 return !IS_DEADDIR(inode);
3105}
3106
3005 return res;
3006}
3007
3008static inline ino_t parent_ino(struct dentry *dentry)
3009{
3010 ino_t res;
3011
3012 /*

--- 145 unchanged lines hidden (view full) ---

3158}
3159static inline bool dir_relax(struct inode *inode)
3160{
3161 inode_unlock(inode);
3162 inode_lock(inode);
3163 return !IS_DEADDIR(inode);
3164}
3165
3166static inline bool dir_relax_shared(struct inode *inode)
3167{
3168 inode_unlock_shared(inode);
3169 inode_lock_shared(inode);
3170 return !IS_DEADDIR(inode);
3171}
3172
3107extern bool path_noexec(const struct path *path);
3108extern void inode_nohighmem(struct inode *inode);
3109
3110#endif /* _LINUX_FS_H */
3173extern bool path_noexec(const struct path *path);
3174extern void inode_nohighmem(struct inode *inode);
3175
3176#endif /* _LINUX_FS_H */