leaving function in locked state

File: mm/.tmp_shmem.o.preproc
Full description: {AutomatonChecker of /usr/share/stanse/checkers/AutomatonChecker/kernel_locking_irq.xml} in function 'shmem_unuse' leaving function in locked state [traces: 1]
Importance: 1
Checker: AutomatonChecker of /usr/share/stanse/checkers/AutomatonChecker/kernel_locking_irq.xml
Trace:
line 8267: The lock is locked here.
line 8268: not affected ==> the lock is still locked.
line 8268: not affected ==> the lock is still locked.
line 8268: not affected ==> the lock is still locked.
line 8269: not affected ==> the lock is still locked.
line 8270: not affected ==> the lock is still locked.
line 8128: not affected ==> the lock is still locked.
line 8129: not affected ==> the lock is still locked.
line 8130: not affected ==> the lock is still locked.
line 8131: not affected ==> the lock is still locked.
line 8131: not affected ==> the lock is still locked.
line 8135: not affected ==> the lock is still locked.
line 8136: not affected ==> the lock is still locked.
line 8137: not affected ==> the lock is still locked.
line 8137: not affected ==> the lock is still locked.
line 8139: not affected ==> the lock is still locked.
line 8108: not affected ==> the lock is still locked.
line 8108: not affected ==> the lock is still locked.
line 8108: not affected ==> the lock is still locked.
line 8109: not affected ==> the lock is still locked.
line 8109: not affected ==> the lock is still locked.
line 8110: not affected ==> the lock is still locked.
line 8113: not affected ==> the lock is still locked.
line 8139: not affected ==> the lock is still locked.
line 8140: not affected ==> the lock is still locked.
line 8140: not affected ==> the lock is still locked.
line 8142: not affected ==> the lock is still locked.
line 8142: not affected ==> the lock is still locked.
line 8145: not affected ==> the lock is still locked.
line 7494: not affected ==> the lock is still locked.
line 7495: not affected ==> the lock is still locked.
line 8145: not affected ==> the lock is still locked.
line 8146: not affected ==> the lock is still locked.
line 8148: not affected ==> the lock is still locked.
line 8148: not affected ==> the lock is still locked.
line 8148: not affected ==> the lock is still locked.
line 8187: not affected ==> the lock is still locked.
line 7499: not affected ==> the lock is still locked.
line 7499: not affected ==> the lock is still locked.
line 7499: not affected ==> the lock is still locked.
line 7500: not affected ==> the lock is still locked.
line 8187: not affected ==> the lock is still locked.
line 8189: not affected ==> the lock is still locked.
line 8190: not affected ==> the lock is still locked.
line 8256: not affected ==> the lock is still locked.
line 8270: not affected ==> the lock is still locked.
line 8271: not affected ==> the lock is still locked.
line 8271: not affected ==> the lock is still locked.
line 8272: not affected ==> the lock is still locked.
line 8272: not affected ==> the lock is still locked.
line 8273: not affected ==> the lock is still locked.
line 8283: not affected ==> the lock is still locked.
line 8284: Leaving function in locked state.[& shmem_swaplist_mutex]
This one is:
False positive index (the lower the better): 0
File contents (this file is distributed under the terms specified in the original file):
    1|static struct vfsmount *shm_mnt;
    2|struct inode;
    3|struct dentry;
    4|
    5|struct xattr_handler {
    6| const char *prefix;
    7| int flags;
    8| size_t (*list)(struct dentry *dentry, char *list, size_t list_size,
    9|         const char *name, size_t name_len, int handler_flags);
   10| int (*get)(struct dentry *dentry, const char *name, void *buffer,
   11|     size_t size, int handler_flags);
   12| int (*set)(struct dentry *dentry, const char *name, const void *buffer,
   13|     size_t size, int flags, int handler_flags);
   14|};
   15|
   16|ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t);
   17|ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t);
   18|ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
   19|int __vfs_setxattr_noperm(struct dentry *, const char *, const void *, size_t, int);
   20|int vfs_setxattr(struct dentry *, const char *, const void *, size_t, int);
   21|int vfs_removexattr(struct dentry *, const char *);
   22|
   23|ssize_t generic_getxattr(struct dentry *dentry, const char *name, void *buffer, size_t size);
   24|ssize_t generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size);
   25|int generic_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags);
   26|int generic_removexattr(struct dentry *dentry, const char *name);
   27|
   28|
   29|
   30|
   31|
   32|struct dentry;
   33|struct inode;
   34|struct super_block;
   35|struct vfsmount;
   36|enum fid_type {
   37|
   38|
   39|
   40|
   41| FILEID_ROOT = 0,
   42|
   43|
   44|
   45|
   46| FILEID_INO32_GEN = 1,
   47|
   48|
   49|
   50|
   51|
   52| FILEID_INO32_GEN_PARENT = 2,
   53|
   54|
   55|
   56|
   57|
   58| FILEID_BTRFS_WITHOUT_PARENT = 0x4d,
   59|
   60|
   61|
   62|
   63|
   64|
   65| FILEID_BTRFS_WITH_PARENT = 0x4e,
   66|
   67|
   68|
   69|
   70|
   71|
   72|
   73| FILEID_BTRFS_WITH_PARENT_ROOT = 0x4f,
   74|
   75|
   76|
   77|
   78|
   79| FILEID_UDF_WITHOUT_PARENT = 0x51,
   80|
   81|
   82|
   83|
   84|
   85|
   86| FILEID_UDF_WITH_PARENT = 0x52,
   87|
   88|
   89|
   90|
   91|
   92| FILEID_NILFS_WITHOUT_PARENT = 0x61,
   93|
   94|
   95|
   96|
   97|
   98|
   99| FILEID_NILFS_WITH_PARENT = 0x62,
  100|};
  101|
  102|struct fid {
  103| union {
  104|  struct {
  105|   u32 ino;
  106|   u32 gen;
  107|   u32 parent_ino;
  108|   u32 parent_gen;
  109|  } i32;
  110|   struct {
  111|    u32 block;
  112|    u16 partref;
  113|    u16 parent_partref;
  114|    u32 generation;
  115|    u32 parent_block;
  116|    u32 parent_generation;
  117|   } udf;
  118|  __u32 raw[0];
  119| };
  120|};
  121|struct export_operations {
  122| int (*encode_fh)(struct dentry *de, __u32 *fh, int *max_len,
  123|   int connectable);
  124| struct dentry * (*fh_to_dentry)(struct super_block *sb, struct fid *fid,
  125|   int fh_len, int fh_type);
  126| struct dentry * (*fh_to_parent)(struct super_block *sb, struct fid *fid,
  127|   int fh_len, int fh_type);
  128| int (*get_name)(struct dentry *parent, char *name,
  129|   struct dentry *child);
  130| struct dentry * (*get_parent)(struct dentry *child);
  131| int (*commit_metadata)(struct inode *inode);
  132|};
  133|
  134|extern int exportfs_encode_fh(struct dentry *dentry, struct fid *fid,
  135| int *max_len, int connectable);
  136|extern struct dentry *exportfs_decode_fh(struct vfsmount *mnt, struct fid *fid,
  137| int fh_len, int fileid_type, int (*acceptable)(void *, struct dentry *),
  138| void *context);
  139|
  140|
  141|
  142|
  143|extern struct dentry *generic_fh_to_dentry(struct super_block *sb,
  144| struct fid *fid, int fh_len, int fh_type,
  145| struct inode *(*get_inode) (struct super_block *sb, u64 ino, u32 gen));
  146|extern struct dentry *generic_fh_to_parent(struct super_block *sb,
  147| struct fid *fid, int fh_len, int fh_type,
  148| struct inode *(*get_inode) (struct super_block *sb, u64 ino, u32 gen));
  149|void kmem_cache_init(void);
  150|int slab_is_available(void);
  151|
  152|struct kmem_cache *kmem_cache_create(const char *, size_t, size_t,
  153|   unsigned long,
  154|   void (*)(void *));
  155|void kmem_cache_destroy(struct kmem_cache *);
  156|int kmem_cache_shrink(struct kmem_cache *);
  157|void kmem_cache_free(struct kmem_cache *, void *);
  158|unsigned int kmem_cache_size(struct kmem_cache *);
  159|const char *kmem_cache_name(struct kmem_cache *);
  160|int kern_ptr_validate(const void *ptr, unsigned long size);
  161|int kmem_ptr_validate(struct kmem_cache *cachep, const void *ptr);
  162|void * __krealloc(const void *, size_t, gfp_t);
  163|void * krealloc(const void *, size_t, gfp_t);
  164|void kfree(const void *);
  165|void kzfree(const void *);
  166|size_t ksize(const void *);
  167|static inline void kmemleak_init(void)
  168|{
  169|}
  170|static inline void kmemleak_alloc(const void *ptr, size_t size, int min_count,
  171|      gfp_t gfp)
  172|{
  173|}
  174|static inline void kmemleak_alloc_recursive(const void *ptr, size_t size,
  175|         int min_count, unsigned long flags,
  176|         gfp_t gfp)
  177|{
  178|}
  179|static inline void kmemleak_free(const void *ptr)
  180|{
  181|}
  182|static inline void kmemleak_free_part(const void *ptr, size_t size)
  183|{
  184|}
  185|static inline void kmemleak_free_recursive(const void *ptr, unsigned long flags)
  186|{
  187|}
  188|static inline void kmemleak_not_leak(const void *ptr)
  189|{
  190|}
  191|static inline void kmemleak_ignore(const void *ptr)
  192|{
  193|}
  194|static inline void kmemleak_scan_area(const void *ptr, size_t size, gfp_t gfp)
  195|{
  196|}
  197|static inline void kmemleak_erase(void **ptr)
  198|{
  199|}
  200|static inline void kmemleak_no_scan(const void *ptr)
  201|{
  202|}
  203|
  204|enum stat_item {
  205| ALLOC_FASTPATH,
  206| ALLOC_SLOWPATH,
  207| FREE_FASTPATH,
  208| FREE_SLOWPATH,
  209| FREE_FROZEN,
  210| FREE_ADD_PARTIAL,
  211| FREE_REMOVE_PARTIAL,
  212| ALLOC_FROM_PARTIAL,
  213| ALLOC_SLAB,
  214| ALLOC_REFILL,
  215| FREE_SLAB,
  216| CPUSLAB_FLUSH,
  217| DEACTIVATE_FULL,
  218| DEACTIVATE_EMPTY,
  219| DEACTIVATE_TO_HEAD,
  220| DEACTIVATE_TO_TAIL,
  221| DEACTIVATE_REMOTE_FREES,
  222| ORDER_FALLBACK,
  223| NR_SLUB_STAT_ITEMS };
  224|
  225|struct kmem_cache_cpu {
  226| void **freelist;
  227| struct page *page;
  228| int node;
  229|
  230|
  231|
  232|};
  233|
  234|struct kmem_cache_node {
  235| spinlock_t list_lock;
  236| unsigned long nr_partial;
  237| struct list_head partial;
  238|
  239| atomic_long_t nr_slabs;
  240| atomic_long_t total_objects;
  241| struct list_head full;
  242|
  243|};
  244|
  245|
  246|
  247|
  248|
  249|
  250|struct kmem_cache_order_objects {
  251| unsigned long x;
  252|};
  253|
  254|
  255|
  256|
  257|struct kmem_cache {
  258| struct kmem_cache_cpu *cpu_slab;
  259|
  260| unsigned long flags;
  261| int size;
  262| int objsize;
  263| int offset;
  264| struct kmem_cache_order_objects oo;
  265|
  266|
  267| struct kmem_cache_order_objects max;
  268| struct kmem_cache_order_objects min;
  269| gfp_t allocflags;
  270| int refcount;
  271| void (*ctor)(void *);
  272| int inuse;
  273| int align;
  274| unsigned long min_partial;
  275| const char *name;
  276| struct list_head list;
  277|
  278| struct kobject kobj;
  279|
  280|
  281|
  282|
  283|
  284|
  285| int remote_node_defrag_ratio;
  286|
  287| struct kmem_cache_node *node[(1 << 10)];
  288|};
  289|extern struct kmem_cache *kmalloc_caches[(12 + 2)];
  290|
  291|
  292|
  293|
  294|
  295|static inline int kmalloc_index(size_t size)
  296|{
  297| if (!size)
  298|  return 0;
  299|
  300| if (size <= 8)
  301|  return ( __builtin_constant_p(8) ? ( (8) < 1 ? ____ilog2_NaN() : (8) & (1ULL << 63) ? 63 : (8) & (1ULL << 62) ? 62 : (8) & (1ULL << 61) ? 61 : (8) & (1ULL << 60) ? 60 : (8) & (1ULL << 59) ? 59 : (8) & (1ULL << 58) ? 58 : (8) & (1ULL << 57) ? 57 : (8) & (1ULL << 56) ? 56 : (8) & (1ULL << 55) ? 55 : (8) & (1ULL << 54) ? 54 : (8) & (1ULL << 53) ? 53 : (8) & (1ULL << 52) ? 52 : (8) & (1ULL << 51) ? 51 : (8) & (1ULL << 50) ? 50 : (8) & (1ULL << 49) ? 49 : (8) & (1ULL << 48) ? 48 : (8) & (1ULL << 47) ? 47 : (8) & (1ULL << 46) ? 46 : (8) & (1ULL << 45) ? 45 : (8) & (1ULL << 44) ? 44 : (8) & (1ULL << 43) ? 43 : (8) & (1ULL << 42) ? 42 : (8) & (1ULL << 41) ? 41 : (8) & (1ULL << 40) ? 40 : (8) & (1ULL << 39) ? 39 : (8) & (1ULL << 38) ? 38 : (8) & (1ULL << 37) ? 37 : (8) & (1ULL << 36) ? 36 : (8) & (1ULL << 35) ? 35 : (8) & (1ULL << 34) ? 34 : (8) & (1ULL << 33) ? 33 : (8) & (1ULL << 32) ? 32 : (8) & (1ULL << 31) ? 31 : (8) & (1ULL << 30) ? 30 : (8) & (1ULL << 29) ? 29 : (8) & (1ULL << 28) ? 28 : (8) & (1ULL << 27) ? 27 : (8) & (1ULL << 26) ? 26 : (8) & (1ULL << 25) ? 25 : (8) & (1ULL << 24) ? 24 : (8) & (1ULL << 23) ? 23 : (8) & (1ULL << 22) ? 22 : (8) & (1ULL << 21) ? 21 : (8) & (1ULL << 20) ? 20 : (8) & (1ULL << 19) ? 19 : (8) & (1ULL << 18) ? 18 : (8) & (1ULL << 17) ? 17 : (8) & (1ULL << 16) ? 16 : (8) & (1ULL << 15) ? 15 : (8) & (1ULL << 14) ? 14 : (8) & (1ULL << 13) ? 13 : (8) & (1ULL << 12) ? 12 : (8) & (1ULL << 11) ? 11 : (8) & (1ULL << 10) ? 10 : (8) & (1ULL << 9) ? 9 : (8) & (1ULL << 8) ? 8 : (8) & (1ULL << 7) ? 7 : (8) & (1ULL << 6) ? 6 : (8) & (1ULL << 5) ? 5 : (8) & (1ULL << 4) ? 4 : (8) & (1ULL << 3) ? 3 : (8) & (1ULL << 2) ? 2 : (8) & (1ULL << 1) ? 1 : (8) & (1ULL << 0) ? 0 : ____ilog2_NaN() ) : (sizeof(8) <= 4) ? __ilog2_u32(8) : __ilog2_u64(8) );
  302|
  303| if (8 <= 32 && size > 64 && size <= 96)
  304|  return 1;
  305| if (8 <= 64 && size > 128 && size <= 192)
  306|  return 2;
  307| if (size <= 8) return 3;
  308| if (size <= 16) return 4;
  309| if (size <= 32) return 5;
  310| if (size <= 64) return 6;
  311| if (size <= 128) return 7;
  312| if (size <= 256) return 8;
  313| if (size <= 512) return 9;
  314| if (size <= 1024) return 10;
  315| if (size <= 2 * 1024) return 11;
  316| if (size <= 4 * 1024) return 12;
  317|
  318|
  319|
  320|
  321| if (size <= 8 * 1024) return 13;
  322| if (size <= 16 * 1024) return 14;
  323| if (size <= 32 * 1024) return 15;
  324| if (size <= 64 * 1024) return 16;
  325| if (size <= 128 * 1024) return 17;
  326| if (size <= 256 * 1024) return 18;
  327| if (size <= 512 * 1024) return 19;
  328| if (size <= 1024 * 1024) return 20;
  329| if (size <= 2 * 1024 * 1024) return 21;
  330| return -1;
  331|}
  332|
  333|
  334|
  335|
  336|
  337|
  338|
  339|static inline struct kmem_cache *kmalloc_slab(size_t size)
  340|{
  341| int index = kmalloc_index(size);
  342|
  343| if (index == 0)
  344|  return ((void *)0);
  345|
  346| return kmalloc_caches[index];
  347|}
  348|
  349|void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
  350|void *__kmalloc(size_t size, gfp_t flags);
  351|
  352|static inline void *
  353|kmalloc_order(size_t size, gfp_t flags, unsigned int order)
  354|{
  355| void *ret = (void *) __get_free_pages(flags | (( gfp_t)0x4000u), order);
  356| kmemleak_alloc(ret, size, 1, flags);
  357| return ret;
  358|}
  359|
  360|
  361|extern void *
  362|kmem_cache_alloc_trace(struct kmem_cache *s, gfp_t gfpflags, size_t size);
  363|extern void *kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order);
  364|static inline void *kmalloc_large(size_t size, gfp_t flags)
  365|{
  366| unsigned int order = get_order(size);
  367| return kmalloc_order_trace(size, flags, order);
  368|}
  369|
  370|static inline void *kmalloc(size_t size, gfp_t flags)
  371|{
  372| if (__builtin_constant_p(size)) {
  373|  if (size > (2 * ((1UL) << 12)))
  374|   return kmalloc_large(size, flags);
  375|
  376|  if (!(flags & (( gfp_t)0x01u))) {
  377|   struct kmem_cache *s = kmalloc_slab(size);
  378|
  379|   if (!s)
  380|    return ((void *)16);
  381|
  382|   return kmem_cache_alloc_trace(s, flags, size);
  383|  }
  384| }
  385| return __kmalloc(size, flags);
  386|}
  387|
  388|
  389|void *__kmalloc_node(size_t size, gfp_t flags, int node);
  390|void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
  391|
  392|
  393|extern void *kmem_cache_alloc_node_trace(struct kmem_cache *s,
  394|        gfp_t gfpflags,
  395|        int node, size_t size);
  396|static inline void *kmalloc_node(size_t size, gfp_t flags, int node)
  397|{
  398| if (__builtin_constant_p(size) &&
  399|  size <= (2 * ((1UL) << 12)) && !(flags & (( gfp_t)0x01u))) {
  400|   struct kmem_cache *s = kmalloc_slab(size);
  401|
  402|  if (!s)
  403|   return ((void *)16);
  404|
  405|  return kmem_cache_alloc_node_trace(s, flags, node, size);
  406| }
  407| return __kmalloc_node(size, flags, node);
  408|}
  409|static inline void *kcalloc(size_t n, size_t size, gfp_t flags)
  410|{
  411| if (size != 0 && n > (~0UL) / size)
  412|  return ((void *)0);
  413| return __kmalloc(n * size, flags | (( gfp_t)0x8000u));
  414|}
  415|extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
  416|extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
  417|static inline void *kmem_cache_zalloc(struct kmem_cache *k, gfp_t flags)
  418|{
  419| return kmem_cache_alloc(k, flags | (( gfp_t)0x8000u));
  420|}
  421|
  422|
  423|
  424|
  425|
  426|
  427|static inline void *kzalloc(size_t size, gfp_t flags)
  428|{
  429| return kmalloc(size, flags | (( gfp_t)0x8000u));
  430|}
  431|
  432|
  433|
  434|
  435|
  436|
  437|
  438|static inline void *kzalloc_node(size_t size, gfp_t flags, int node)
  439|{
  440| return kmalloc_node(size, flags | (( gfp_t)0x8000u), node);
  441|}
  442|
  443|void kmem_cache_init_late(void);
  444|struct posix_acl_entry {
  445| short e_tag;
  446| unsigned short e_perm;
  447| unsigned int e_id;
  448|};
  449|
  450|struct posix_acl {
  451| atomic_t a_refcount;
  452| unsigned int a_count;
  453| struct posix_acl_entry a_entries[0];
  454|};
  455|static inline struct posix_acl *
  456|posix_acl_dup(struct posix_acl *acl)
  457|{
  458| if (acl)
  459|  atomic_inc(&acl->a_refcount);
  460| return acl;
  461|}
  462|
  463|
  464|
  465|
  466|static inline void
  467|posix_acl_release(struct posix_acl *acl)
  468|{
  469| if (acl && atomic_dec_and_test(&acl->a_refcount))
  470|  kfree(acl);
  471|}
  472|
  473|
  474|
  475|
  476|extern struct posix_acl *posix_acl_alloc(int, gfp_t);
  477|extern struct posix_acl *posix_acl_clone(const struct posix_acl *, gfp_t);
  478|extern int posix_acl_valid(const struct posix_acl *);
  479|extern int posix_acl_permission(struct inode *, const struct posix_acl *, int);
  480|extern struct posix_acl *posix_acl_from_mode(mode_t, gfp_t);
  481|extern int posix_acl_equiv_mode(const struct posix_acl *, mode_t *);
  482|extern int posix_acl_create_masq(struct posix_acl *, mode_t *);
  483|extern int posix_acl_chmod_masq(struct posix_acl *, mode_t);
  484|
  485|extern struct posix_acl *get_posix_acl(struct inode *, int);
  486|extern int set_posix_acl(struct inode *, int, struct posix_acl *);
  487|
  488|
  489|static inline struct posix_acl *get_cached_acl(struct inode *inode, int type)
  490|{
  491| struct posix_acl **p, *acl;
  492| switch (type) {
  493| case (0x8000):
  494|  p = &inode->i_acl;
  495|  break;
  496| case (0x4000):
  497|  p = &inode->i_default_acl;
  498|  break;
  499| default:
  500|  return ERR_PTR(-22);
  501| }
  502| acl = (*(volatile typeof(*p) *)&(*p));
  503| if (acl) {
  504|  spin_lock(&inode->i_lock);
  505|  acl = *p;
  506|  if (acl != ((void *)(-1)))
  507|   acl = posix_acl_dup(acl);
  508|  spin_unlock(&inode->i_lock);
  509| }
  510| return acl;
  511|}
  512|
  513|static inline void set_cached_acl(struct inode *inode,
  514|      int type,
  515|      struct posix_acl *acl)
  516|{
  517| struct posix_acl *old = ((void *)0);
  518| spin_lock(&inode->i_lock);
  519| switch (type) {
  520| case (0x8000):
  521|  old = inode->i_acl;
  522|  inode->i_acl = posix_acl_dup(acl);
  523|  break;
  524| case (0x4000):
  525|  old = inode->i_default_acl;
  526|  inode->i_default_acl = posix_acl_dup(acl);
  527|  break;
  528| }
  529| spin_unlock(&inode->i_lock);
  530| if (old != ((void *)(-1)))
  531|  posix_acl_release(old);
  532|}
  533|
  534|static inline void forget_cached_acl(struct inode *inode, int type)
  535|{
  536| struct posix_acl *old = ((void *)0);
  537| spin_lock(&inode->i_lock);
  538| switch (type) {
  539| case (0x8000):
  540|  old = inode->i_acl;
  541|  inode->i_acl = ((void *)(-1));
  542|  break;
  543| case (0x4000):
  544|  old = inode->i_default_acl;
  545|  inode->i_default_acl = ((void *)(-1));
  546|  break;
  547| }
  548| spin_unlock(&inode->i_lock);
  549| if (old != ((void *)(-1)))
  550|  posix_acl_release(old);
  551|}
  552|
  553|static inline void forget_all_cached_acls(struct inode *inode)
  554|{
  555| struct posix_acl *old_access, *old_default;
  556| spin_lock(&inode->i_lock);
  557| old_access = inode->i_acl;
  558| old_default = inode->i_default_acl;
  559| inode->i_acl = inode->i_default_acl = ((void *)(-1));
  560| spin_unlock(&inode->i_lock);
  561| if (old_access != ((void *)(-1)))
  562|  posix_acl_release(old_access);
  563| if (old_default != ((void *)(-1)))
  564|  posix_acl_release(old_default);
  565|}
  566|
  567|
  568|static inline void cache_no_acl(struct inode *inode)
  569|{
  570|
  571| inode->i_acl = ((void *)0);
  572| inode->i_default_acl = ((void *)0);
  573|
  574|}
  575|
  576|
  577|
  578|
  579|
  580|struct inode;
  581|
  582|extern const struct xattr_handler generic_acl_access_handler;
  583|extern const struct xattr_handler generic_acl_default_handler;
  584|
  585|int generic_acl_init(struct inode *, struct inode *);
  586|int generic_acl_chmod(struct inode *);
  587|int generic_check_acl(struct inode *inode, int mask);
  588|
  589|
  590|
  591|
  592|
  593|
  594|
  595|
  596|
  597|
  598|
  599|extern int sysctl_overcommit_memory;
  600|extern int sysctl_overcommit_ratio;
  601|extern struct percpu_counter vm_committed_as;
  602|
  603|static inline void vm_acct_memory(long pages)
  604|{
  605| percpu_counter_add(&vm_committed_as, pages);
  606|}
  607|
  608|static inline void vm_unacct_memory(long pages)
  609|{
  610| vm_acct_memory(-pages);
  611|}
  612|static inline int arch_validate_prot(unsigned long prot)
  613|{
  614| return (prot & ~(0x1 | 0x2 | 0x4 | 0x8)) == 0;
  615|}
  616|static inline unsigned long
  617|calc_vm_prot_bits(unsigned long prot)
  618|{
  619| return ((0x1) <= (0x00000001) ? ((prot) & (0x1)) * ((0x00000001) / (0x1)) : ((prot) & (0x1)) / ((0x1) / (0x00000001))) |
  620|        ((0x2) <= (0x00000002) ? ((prot) & (0x2)) * ((0x00000002) / (0x2)) : ((prot) & (0x2)) / ((0x2) / (0x00000002))) |
  621|        ((0x4) <= (0x00000004) ? ((prot) & (0x4)) * ((0x00000004) / (0x4)) : ((prot) & (0x4)) / ((0x4) / (0x00000004))) |
  622|        0;
  623|}
  624|
  625|
  626|
  627|
  628|static inline unsigned long
  629|calc_vm_flag_bits(unsigned long flags)
  630|{
  631| return ((0x0100) <= (0x00000100) ? ((flags) & (0x0100)) * ((0x00000100) / (0x0100)) : ((flags) & (0x0100)) / ((0x0100) / (0x00000100))) |
  632|        ((0x0800) <= (0x00000800) ? ((flags) & (0x0800)) * ((0x00000800) / (0x0800)) : ((flags) & (0x0800)) / ((0x0800) / (0x00000800))) |
  633|        ((0x1000) <= (0x00001000) ? ((flags) & (0x1000)) * ((0x00001000) / (0x1000)) : ((flags) & (0x1000)) / ((0x1000) / (0x00001000))) |
  634|        ((0x2000) <= (0x00002000) ? ((flags) & (0x2000)) * ((0x00002000) / (0x2000)) : ((flags) & (0x2000)) / ((0x2000) / (0x00002000)));
  635|}
  636|
  637|
  638|struct backing_dev_info;
  639|
  640|extern spinlock_t inode_lock;
  641|
  642|
  643|
  644|
  645|enum writeback_sync_modes {
  646| WB_SYNC_NONE,
  647| WB_SYNC_ALL,
  648|};
  649|
  650|
  651|
  652|
  653|
  654|
  655|struct writeback_control {
  656| enum writeback_sync_modes sync_mode;
  657| unsigned long *older_than_this;
  658|
  659| unsigned long wb_start;
  660|
  661|
  662| long nr_to_write;
  663|
  664| long pages_skipped;
  665|
  666|
  667|
  668|
  669|
  670|
  671| loff_t range_start;
  672| loff_t range_end;
  673|
  674| unsigned nonblocking:1;
  675| unsigned encountered_congestion:1;
  676| unsigned for_kupdate:1;
  677| unsigned for_background:1;
  678| unsigned for_reclaim:1;
  679| unsigned range_cyclic:1;
  680| unsigned more_io:1;
  681|};
  682|
  683|
  684|
  685|
  686|struct bdi_writeback;
  687|int inode_wait(void *);
  688|void writeback_inodes_sb(struct super_block *);
  689|void writeback_inodes_sb_nr(struct super_block *, unsigned long nr);
  690|int writeback_inodes_sb_if_idle(struct super_block *);
  691|int writeback_inodes_sb_nr_if_idle(struct super_block *, unsigned long nr);
  692|void sync_inodes_sb(struct super_block *);
  693|void writeback_inodes_wb(struct bdi_writeback *wb,
  694|  struct writeback_control *wbc);
  695|long wb_do_writeback(struct bdi_writeback *wb, int force_wait);
  696|void wakeup_flusher_threads(long nr_pages);
  697|
  698|
  699|static inline void wait_on_inode(struct inode *inode)
  700|{
  701| do { __might_sleep("/home/l/latest/linux/include/linux/writeback.h", 73, 0); do { } while (0); } while (0);
  702| wait_on_bit(&inode->i_state, 3, inode_wait, 2);
  703|}
  704|static inline void inode_sync_wait(struct inode *inode)
  705|{
  706| do { __might_sleep("/home/l/latest/linux/include/linux/writeback.h", 78, 0); do { } while (0); } while (0);
  707| wait_on_bit(&inode->i_state, 7, inode_wait,
  708|       2);
  709|}
  710|
  711|
  712|
  713|
  714|
  715|
  716|void laptop_io_completion(struct backing_dev_info *info);
  717|void laptop_sync_completion(void);
  718|void laptop_mode_sync(struct work_struct *work);
  719|void laptop_mode_timer_fn(unsigned long data);
  720|
  721|
  722|
  723|void throttle_vm_writeout(gfp_t gfp_mask);
  724|
  725|
  726|extern int dirty_background_ratio;
  727|extern unsigned long dirty_background_bytes;
  728|extern int vm_dirty_ratio;
  729|extern unsigned long vm_dirty_bytes;
  730|extern unsigned int dirty_writeback_interval;
  731|extern unsigned int dirty_expire_interval;
  732|extern int vm_highmem_is_dirtyable;
  733|extern int block_dump;
  734|extern int laptop_mode;
  735|
  736|extern unsigned long determine_dirtyable_memory(void);
  737|
  738|extern int dirty_background_ratio_handler(struct ctl_table *table, int write,
  739|  void *buffer, size_t *lenp,
  740|  loff_t *ppos);
  741|extern int dirty_background_bytes_handler(struct ctl_table *table, int write,
  742|  void *buffer, size_t *lenp,
  743|  loff_t *ppos);
  744|extern int dirty_ratio_handler(struct ctl_table *table, int write,
  745|  void *buffer, size_t *lenp,
  746|  loff_t *ppos);
  747|extern int dirty_bytes_handler(struct ctl_table *table, int write,
  748|  void *buffer, size_t *lenp,
  749|  loff_t *ppos);
  750|
  751|struct ctl_table;
  752|int dirty_writeback_centisecs_handler(struct ctl_table *, int,
  753|          void *, size_t *, loff_t *);
  754|
  755|void global_dirty_limits(unsigned long *pbackground, unsigned long *pdirty);
  756|unsigned long bdi_dirty_limit(struct backing_dev_info *bdi,
  757|          unsigned long dirty);
  758|
  759|void page_writeback_init(void);
  760|void balance_dirty_pages_ratelimited_nr(struct address_space *mapping,
  761|     unsigned long nr_pages_dirtied);
  762|
  763|static inline void
  764|balance_dirty_pages_ratelimited(struct address_space *mapping)
  765|{
  766| balance_dirty_pages_ratelimited_nr(mapping, 1);
  767|}
  768|
  769|typedef int (*writepage_t)(struct page *page, struct writeback_control *wbc,
  770|    void *data);
  771|
  772|int generic_writepages(struct address_space *mapping,
  773|         struct writeback_control *wbc);
  774|void tag_pages_for_writeback(struct address_space *mapping,
  775|        unsigned long start, unsigned long end);
  776|int write_cache_pages(struct address_space *mapping,
  777|        struct writeback_control *wbc, writepage_t writepage,
  778|        void *data);
  779|int do_writepages(struct address_space *mapping, struct writeback_control *wbc);
  780|void set_page_dirty_balance(struct page *page, int page_mkwrite);
  781|void writeback_set_ratelimit(void);
  782|void tag_pages_for_writeback(struct address_space *mapping,
  783|        unsigned long start, unsigned long end);
  784|
  785|
  786|extern int nr_pdflush_threads;
  787|
  788|
  789|struct page;
  790|struct device;
  791|struct dentry;
  792|
  793|
  794|
  795|
  796|enum bdi_state {
  797| BDI_pending,
  798| BDI_wb_alloc,
  799| BDI_async_congested,
  800| BDI_sync_congested,
  801| BDI_registered,
  802| BDI_writeback_running,
  803| BDI_unused,
  804|};
  805|
  806|typedef int (congested_fn)(void *, int);
  807|
  808|enum bdi_stat_item {
  809| BDI_RECLAIMABLE,
  810| BDI_WRITEBACK,
  811| NR_BDI_STAT_ITEMS
  812|};
  813|
  814|
  815|
  816|struct bdi_writeback {
  817| struct backing_dev_info *bdi;
  818| unsigned int nr;
  819|
  820| unsigned long last_old_flush;
  821| unsigned long last_active;
  822|
  823| struct task_struct *task;
  824| struct timer_list wakeup_timer;
  825| struct list_head b_dirty;
  826| struct list_head b_io;
  827| struct list_head b_more_io;
  828|};
  829|
  830|struct backing_dev_info {
  831| struct list_head bdi_list;
  832| unsigned long ra_pages;
  833| unsigned long state;
  834| unsigned int capabilities;
  835| congested_fn *congested_fn;
  836| void *congested_data;
  837| void (*unplug_io_fn)(struct backing_dev_info *, struct page *);
  838| void *unplug_io_data;
  839|
  840| char *name;
  841|
  842| struct percpu_counter bdi_stat[NR_BDI_STAT_ITEMS];
  843|
  844| struct prop_local_percpu completions;
  845| int dirty_exceeded;
  846|
  847| unsigned int min_ratio;
  848| unsigned int max_ratio, max_prop_frac;
  849|
  850| struct bdi_writeback wb;
  851| spinlock_t wb_lock;
  852|
  853| struct list_head work_list;
  854|
  855| struct device *dev;
  856|
  857| struct timer_list laptop_mode_wb_timer;
  858|
  859|
  860| struct dentry *debug_dir;
  861| struct dentry *debug_stats;
  862|
  863|};
  864|
  865|int bdi_init(struct backing_dev_info *bdi);
  866|void bdi_destroy(struct backing_dev_info *bdi);
  867|
  868|int bdi_register(struct backing_dev_info *bdi, struct device *parent,
  869|  const char *fmt, ...);
  870|int bdi_register_dev(struct backing_dev_info *bdi, dev_t dev);
  871|void bdi_unregister(struct backing_dev_info *bdi);
  872|int bdi_setup_and_register(struct backing_dev_info *, char *, unsigned int);
  873|void bdi_start_writeback(struct backing_dev_info *bdi, long nr_pages);
  874|void bdi_start_background_writeback(struct backing_dev_info *bdi);
  875|int bdi_writeback_thread(void *data);
  876|int bdi_has_dirty_io(struct backing_dev_info *bdi);
  877|void bdi_arm_supers_timer(void);
  878|void bdi_wakeup_thread_delayed(struct backing_dev_info *bdi);
  879|
  880|extern spinlock_t bdi_lock;
  881|extern struct list_head bdi_list;
  882|extern struct list_head bdi_pending_list;
  883|
  884|static inline int wb_has_dirty_io(struct bdi_writeback *wb)
  885|{
  886| return !list_empty(&wb->b_dirty) ||
  887|        !list_empty(&wb->b_io) ||
  888|        !list_empty(&wb->b_more_io);
  889|}
  890|
  891|static inline void __add_bdi_stat(struct backing_dev_info *bdi,
  892|  enum bdi_stat_item item, s64 amount)
  893|{
  894| __percpu_counter_add(&bdi->bdi_stat[item], amount, (8*(1+( __builtin_constant_p(nr_cpu_ids) ? ( (nr_cpu_ids) < 1 ? ____ilog2_NaN() : (nr_cpu_ids) & (1ULL << 63) ? 63 : (nr_cpu_ids) & (1ULL << 62) ? 62 : (nr_cpu_ids) & (1ULL << 61) ? 61 : (nr_cpu_ids) & (1ULL << 60) ? 60 : (nr_cpu_ids) & (1ULL << 59) ? 59 : (nr_cpu_ids) & (1ULL << 58) ? 58 : (nr_cpu_ids) & (1ULL << 57) ? 57 : (nr_cpu_ids) & (1ULL << 56) ? 56 : (nr_cpu_ids) & (1ULL << 55) ? 55 : (nr_cpu_ids) & (1ULL << 54) ? 54 : (nr_cpu_ids) & (1ULL << 53) ? 53 : (nr_cpu_ids) & (1ULL << 52) ? 52 : (nr_cpu_ids) & (1ULL << 51) ? 51 : (nr_cpu_ids) & (1ULL << 50) ? 50 : (nr_cpu_ids) & (1ULL << 49) ? 49 : (nr_cpu_ids) & (1ULL << 48) ? 48 : (nr_cpu_ids) & (1ULL << 47) ? 47 : (nr_cpu_ids) & (1ULL << 46) ? 46 : (nr_cpu_ids) & (1ULL << 45) ? 45 : (nr_cpu_ids) & (1ULL << 44) ? 44 : (nr_cpu_ids) & (1ULL << 43) ? 43 : (nr_cpu_ids) & (1ULL << 42) ? 42 : (nr_cpu_ids) & (1ULL << 41) ? 41 : (nr_cpu_ids) & (1ULL << 40) ? 40 : (nr_cpu_ids) & (1ULL << 39) ? 39 : (nr_cpu_ids) & (1ULL << 38) ? 38 : (nr_cpu_ids) & (1ULL << 37) ? 37 : (nr_cpu_ids) & (1ULL << 36) ? 36 : (nr_cpu_ids) & (1ULL << 35) ? 35 : (nr_cpu_ids) & (1ULL << 34) ? 34 : (nr_cpu_ids) & (1ULL << 33) ? 33 : (nr_cpu_ids) & (1ULL << 32) ? 32 : (nr_cpu_ids) & (1ULL << 31) ? 31 : (nr_cpu_ids) & (1ULL << 30) ? 30 : (nr_cpu_ids) & (1ULL << 29) ? 29 : (nr_cpu_ids) & (1ULL << 28) ? 28 : (nr_cpu_ids) & (1ULL << 27) ? 27 : (nr_cpu_ids) & (1ULL << 26) ? 26 : (nr_cpu_ids) & (1ULL << 25) ? 25 : (nr_cpu_ids) & (1ULL << 24) ? 24 : (nr_cpu_ids) & (1ULL << 23) ? 23 : (nr_cpu_ids) & (1ULL << 22) ? 22 : (nr_cpu_ids) & (1ULL << 21) ? 21 : (nr_cpu_ids) & (1ULL << 20) ? 20 : (nr_cpu_ids) & (1ULL << 19) ? 19 : (nr_cpu_ids) & (1ULL << 18) ? 18 : (nr_cpu_ids) & (1ULL << 17) ? 17 : (nr_cpu_ids) & (1ULL << 16) ? 16 : (nr_cpu_ids) & (1ULL << 15) ? 15 : (nr_cpu_ids) & (1ULL << 14) ? 14 : (nr_cpu_ids) & (1ULL << 13) ? 13 : (nr_cpu_ids) & (1ULL << 12) ? 12 : (nr_cpu_ids) & (1ULL << 11) ? 11 : (nr_cpu_ids) & (1ULL << 10) ? 10 : (nr_cpu_ids) & (1ULL << 9) ? 9 : (nr_cpu_ids) & (1ULL << 8) ? 8 : (nr_cpu_ids) & (1ULL << 7) ? 7 : (nr_cpu_ids) & (1ULL << 6) ? 6 : (nr_cpu_ids) & (1ULL << 5) ? 5 : (nr_cpu_ids) & (1ULL << 4) ? 4 : (nr_cpu_ids) & (1ULL << 3) ? 3 : (nr_cpu_ids) & (1ULL << 2) ? 2 : (nr_cpu_ids) & (1ULL << 1) ? 1 : (nr_cpu_ids) & (1ULL << 0) ? 0 : ____ilog2_NaN() ) : (sizeof(nr_cpu_ids) <= 4) ? __ilog2_u32(nr_cpu_ids) : __ilog2_u64(nr_cpu_ids) ))));
  895|}
  896|
  897|static inline void __inc_bdi_stat(struct backing_dev_info *bdi,
  898|  enum bdi_stat_item item)
  899|{
  900| __add_bdi_stat(bdi, item, 1);
  901|}
  902|
  903|static inline void inc_bdi_stat(struct backing_dev_info *bdi,
  904|  enum bdi_stat_item item)
  905|{
  906| unsigned long flags;
  907|
  908| do { do { ({ unsigned long __dummy; typeof(flags) __dummy2; (void)(&__dummy == &__dummy2); 1; }); flags = arch_local_irq_save(); } while (0); trace_hardirqs_off(); } while (0);
  909| __inc_bdi_stat(bdi, item);
  910| do { if (({ ({ unsigned long __dummy; typeof(flags) __dummy2; (void)(&__dummy == &__dummy2); 1; }); arch_irqs_disabled_flags(flags); })) { do { ({ unsigned long __dummy; typeof(flags) __dummy2; (void)(&__dummy == &__dummy2); 1; }); arch_local_irq_restore(flags); } while (0); trace_hardirqs_off(); } else { trace_hardirqs_on(); do { ({ unsigned long __dummy; typeof(flags) __dummy2; (void)(&__dummy == &__dummy2); 1; }); arch_local_irq_restore(flags); } while (0); } } while (0);
  911|}
  912|
  913|static inline void __dec_bdi_stat(struct backing_dev_info *bdi,
  914|  enum bdi_stat_item item)
  915|{
  916| __add_bdi_stat(bdi, item, -1);
  917|}
  918|
  919|static inline void dec_bdi_stat(struct backing_dev_info *bdi,
  920|  enum bdi_stat_item item)
  921|{
  922| unsigned long flags;
  923|
  924| do { do { ({ unsigned long __dummy; typeof(flags) __dummy2; (void)(&__dummy == &__dummy2); 1; }); flags = arch_local_irq_save(); } while (0); trace_hardirqs_off(); } while (0);
  925| __dec_bdi_stat(bdi, item);
  926| do { if (({ ({ unsigned long __dummy; typeof(flags) __dummy2; (void)(&__dummy == &__dummy2); 1; }); arch_irqs_disabled_flags(flags); })) { do { ({ unsigned long __dummy; typeof(flags) __dummy2; (void)(&__dummy == &__dummy2); 1; }); arch_local_irq_restore(flags); } while (0); trace_hardirqs_off(); } else { trace_hardirqs_on(); do { ({ unsigned long __dummy; typeof(flags) __dummy2; (void)(&__dummy == &__dummy2); 1; }); arch_local_irq_restore(flags); } while (0); } } while (0);
  927|}
  928|
  929|static inline s64 bdi_stat(struct backing_dev_info *bdi,
  930|  enum bdi_stat_item item)
  931|{
  932| return percpu_counter_read_positive(&bdi->bdi_stat[item]);
  933|}
  934|
  935|static inline s64 __bdi_stat_sum(struct backing_dev_info *bdi,
  936|  enum bdi_stat_item item)
  937|{
  938| return percpu_counter_sum_positive(&bdi->bdi_stat[item]);
  939|}
  940|
  941|static inline s64 bdi_stat_sum(struct backing_dev_info *bdi,
  942|  enum bdi_stat_item item)
  943|{
  944| s64 sum;
  945| unsigned long flags;
  946|
  947| do { do { ({ unsigned long __dummy; typeof(flags) __dummy2; (void)(&__dummy == &__dummy2); 1; }); flags = arch_local_irq_save(); } while (0); trace_hardirqs_off(); } while (0);
  948| sum = __bdi_stat_sum(bdi, item);
  949| do { if (({ ({ unsigned long __dummy; typeof(flags) __dummy2; (void)(&__dummy == &__dummy2); 1; }); arch_irqs_disabled_flags(flags); })) { do { ({ unsigned long __dummy; typeof(flags) __dummy2; (void)(&__dummy == &__dummy2); 1; }); arch_local_irq_restore(flags); } while (0); trace_hardirqs_off(); } else { trace_hardirqs_on(); do { ({ unsigned long __dummy; typeof(flags) __dummy2; (void)(&__dummy == &__dummy2); 1; }); arch_local_irq_restore(flags); } while (0); } } while (0);
  950|
  951| return sum;
  952|}
  953|
  954|extern void bdi_writeout_inc(struct backing_dev_info *bdi);
  955|
  956|
  957|
  958|
  959|static inline unsigned long bdi_stat_error(struct backing_dev_info *bdi)
  960|{
  961|
  962| return nr_cpu_ids * (8*(1+( __builtin_constant_p(nr_cpu_ids) ? ( (nr_cpu_ids) < 1 ? ____ilog2_NaN() : (nr_cpu_ids) & (1ULL << 63) ? 63 : (nr_cpu_ids) & (1ULL << 62) ? 62 : (nr_cpu_ids) & (1ULL << 61) ? 61 : (nr_cpu_ids) & (1ULL << 60) ? 60 : (nr_cpu_ids) & (1ULL << 59) ? 59 : (nr_cpu_ids) & (1ULL << 58) ? 58 : (nr_cpu_ids) & (1ULL << 57) ? 57 : (nr_cpu_ids) & (1ULL << 56) ? 56 : (nr_cpu_ids) & (1ULL << 55) ? 55 : (nr_cpu_ids) & (1ULL << 54) ? 54 : (nr_cpu_ids) & (1ULL << 53) ? 53 : (nr_cpu_ids) & (1ULL << 52) ? 52 : (nr_cpu_ids) & (1ULL << 51) ? 51 : (nr_cpu_ids) & (1ULL << 50) ? 50 : (nr_cpu_ids) & (1ULL << 49) ? 49 : (nr_cpu_ids) & (1ULL << 48) ? 48 : (nr_cpu_ids) & (1ULL << 47) ? 47 : (nr_cpu_ids) & (1ULL << 46) ? 46 : (nr_cpu_ids) & (1ULL << 45) ? 45 : (nr_cpu_ids) & (1ULL << 44) ? 44 : (nr_cpu_ids) & (1ULL << 43) ? 43 : (nr_cpu_ids) & (1ULL << 42) ? 42 : (nr_cpu_ids) & (1ULL << 41) ? 41 : (nr_cpu_ids) & (1ULL << 40) ? 40 : (nr_cpu_ids) & (1ULL << 39) ? 39 : (nr_cpu_ids) & (1ULL << 38) ? 38 : (nr_cpu_ids) & (1ULL << 37) ? 37 : (nr_cpu_ids) & (1ULL << 36) ? 36 : (nr_cpu_ids) & (1ULL << 35) ? 35 : (nr_cpu_ids) & (1ULL << 34) ? 34 : (nr_cpu_ids) & (1ULL << 33) ? 33 : (nr_cpu_ids) & (1ULL << 32) ? 32 : (nr_cpu_ids) & (1ULL << 31) ? 31 : (nr_cpu_ids) & (1ULL << 30) ? 30 : (nr_cpu_ids) & (1ULL << 29) ? 29 : (nr_cpu_ids) & (1ULL << 28) ? 28 : (nr_cpu_ids) & (1ULL << 27) ? 27 : (nr_cpu_ids) & (1ULL << 26) ? 26 : (nr_cpu_ids) & (1ULL << 25) ? 25 : (nr_cpu_ids) & (1ULL << 24) ? 24 : (nr_cpu_ids) & (1ULL << 23) ? 23 : (nr_cpu_ids) & (1ULL << 22) ? 22 : (nr_cpu_ids) & (1ULL << 21) ? 21 : (nr_cpu_ids) & (1ULL << 20) ? 20 : (nr_cpu_ids) & (1ULL << 19) ? 19 : (nr_cpu_ids) & (1ULL << 18) ? 18 : (nr_cpu_ids) & (1ULL << 17) ? 17 : (nr_cpu_ids) & (1ULL << 16) ? 16 : (nr_cpu_ids) & (1ULL << 15) ? 15 : (nr_cpu_ids) & (1ULL << 14) ? 14 : (nr_cpu_ids) & (1ULL << 13) ? 13 : (nr_cpu_ids) & (1ULL << 12) ? 12 : (nr_cpu_ids) & (1ULL << 11) ? 11 : (nr_cpu_ids) & (1ULL << 10) ? 10 : (nr_cpu_ids) & (1ULL << 9) ? 9 : (nr_cpu_ids) & (1ULL << 8) ? 8 : (nr_cpu_ids) & (1ULL << 7) ? 7 : (nr_cpu_ids) & (1ULL << 6) ? 6 : (nr_cpu_ids) & (1ULL << 5) ? 5 : (nr_cpu_ids) & (1ULL << 4) ? 4 : (nr_cpu_ids) & (1ULL << 3) ? 3 : (nr_cpu_ids) & (1ULL << 2) ? 2 : (nr_cpu_ids) & (1ULL << 1) ? 1 : (nr_cpu_ids) & (1ULL << 0) ? 0 : ____ilog2_NaN() ) : (sizeof(nr_cpu_ids) <= 4) ? __ilog2_u32(nr_cpu_ids) : __ilog2_u64(nr_cpu_ids) )));
  963|
  964|
  965|
  966|}
  967|
  968|int bdi_set_min_ratio(struct backing_dev_info *bdi, unsigned int min_ratio);
  969|int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned int max_ratio);
  970|extern struct backing_dev_info default_backing_dev_info;
  971|extern struct backing_dev_info noop_backing_dev_info;
  972|void default_unplug_io_fn(struct backing_dev_info *bdi, struct page *page);
  973|
  974|int writeback_in_progress(struct backing_dev_info *bdi);
  975|
  976|static inline int bdi_congested(struct backing_dev_info *bdi, int bdi_bits)
  977|{
  978| if (bdi->congested_fn)
  979|  return bdi->congested_fn(bdi->congested_data, bdi_bits);
  980| return (bdi->state & bdi_bits);
  981|}
  982|
  983|static inline int bdi_read_congested(struct backing_dev_info *bdi)
  984|{
  985| return bdi_congested(bdi, 1 << BDI_sync_congested);
  986|}
  987|
  988|static inline int bdi_write_congested(struct backing_dev_info *bdi)
  989|{
  990| return bdi_congested(bdi, 1 << BDI_async_congested);
  991|}
  992|
  993|static inline int bdi_rw_congested(struct backing_dev_info *bdi)
  994|{
  995| return bdi_congested(bdi, (1 << BDI_sync_congested) |
  996|      (1 << BDI_async_congested));
  997|}
  998|
  999|enum {
 1000| BLK_RW_ASYNC = 0,
 1001| BLK_RW_SYNC = 1,
 1002|};
 1003|
 1004|void clear_bdi_congested(struct backing_dev_info *bdi, int sync);
 1005|void set_bdi_congested(struct backing_dev_info *bdi, int sync);
 1006|long congestion_wait(int sync, long timeout);
 1007|long wait_iff_congested(struct zone *zone, int sync, long timeout);
 1008|
 1009|static inline bool bdi_cap_writeback_dirty(struct backing_dev_info *bdi)
 1010|{
 1011| return !(bdi->capabilities & 0x00000002);
 1012|}
 1013|
 1014|static inline bool bdi_cap_account_dirty(struct backing_dev_info *bdi)
 1015|{
 1016| return !(bdi->capabilities & 0x00000001);
 1017|}
 1018|
 1019|static inline bool bdi_cap_account_writeback(struct backing_dev_info *bdi)
 1020|{
 1021|
 1022| return !(bdi->capabilities & (0x00000080 |
 1023|          0x00000002));
 1024|}
 1025|
 1026|static inline bool bdi_cap_swap_backed(struct backing_dev_info *bdi)
 1027|{
 1028| return bdi->capabilities & 0x00000100;
 1029|}
 1030|
 1031|static inline bool bdi_cap_flush_forker(struct backing_dev_info *bdi)
 1032|{
 1033| return bdi == &default_backing_dev_info;
 1034|}
 1035|
 1036|static inline bool mapping_cap_writeback_dirty(struct address_space *mapping)
 1037|{
 1038| return bdi_cap_writeback_dirty(mapping->backing_dev_info);
 1039|}
 1040|
 1041|static inline bool mapping_cap_account_dirty(struct address_space *mapping)
 1042|{
 1043| return bdi_cap_account_dirty(mapping->backing_dev_info);
 1044|}
 1045|
 1046|static inline bool mapping_cap_swap_backed(struct address_space *mapping)
 1047|{
 1048| return bdi_cap_swap_backed(mapping->backing_dev_info);
 1049|}
 1050|
 1051|static inline int bdi_sched_wait(void *word)
 1052|{
 1053| schedule();
 1054| return 0;
 1055|}
 1056|
 1057|static inline void blk_run_backing_dev(struct backing_dev_info *bdi,
 1058|           struct page *page)
 1059|{
 1060| if (bdi && bdi->unplug_io_fn)
 1061|  bdi->unplug_io_fn(bdi, page);
 1062|}
 1063|
 1064|static inline void blk_run_address_space(struct address_space *mapping)
 1065|{
 1066| if (mapping)
 1067|  blk_run_backing_dev(mapping->backing_dev_info, ((void *)0));
 1068|}
 1069|
 1070|
 1071|
 1072|
 1073|enum {
 1074| MPOL_DEFAULT,
 1075| MPOL_PREFERRED,
 1076| MPOL_BIND,
 1077| MPOL_INTERLEAVE,
 1078| MPOL_MAX,
 1079|};
 1080|
 1081|enum mpol_rebind_step {
 1082| MPOL_REBIND_ONCE,
 1083| MPOL_REBIND_STEP1,
 1084| MPOL_REBIND_STEP2,
 1085| MPOL_REBIND_NSTEP,
 1086|};
 1087|struct mm_struct;
 1088|struct mempolicy {
 1089| atomic_t refcnt;
 1090| unsigned short mode;
 1091| unsigned short flags;
 1092| union {
 1093|  short preferred_node;
 1094|  nodemask_t nodes;
 1095|
 1096| } v;
 1097| union {
 1098|  nodemask_t cpuset_mems_allowed;
 1099|  nodemask_t user_nodemask;
 1100| } w;
 1101|};
 1102|
 1103|
 1104|
 1105|
 1106|
 1107|
 1108|extern void __mpol_put(struct mempolicy *pol);
 1109|static inline void mpol_put(struct mempolicy *pol)
 1110|{
 1111| if (pol)
 1112|  __mpol_put(pol);
 1113|}
 1114|
 1115|
 1116|
 1117|
 1118|
 1119|static inline int mpol_needs_cond_ref(struct mempolicy *pol)
 1120|{
 1121| return (pol && (pol->flags & (1 << 0)));
 1122|}
 1123|
 1124|static inline void mpol_cond_put(struct mempolicy *pol)
 1125|{
 1126| if (mpol_needs_cond_ref(pol))
 1127|  __mpol_put(pol);
 1128|}
 1129|
 1130|extern struct mempolicy *__mpol_cond_copy(struct mempolicy *tompol,
 1131|       struct mempolicy *frompol);
 1132|static inline struct mempolicy *mpol_cond_copy(struct mempolicy *tompol,
 1133|      struct mempolicy *frompol)
 1134|{
 1135| if (!frompol)
 1136|  return frompol;
 1137| return __mpol_cond_copy(tompol, frompol);
 1138|}
 1139|
 1140|extern struct mempolicy *__mpol_dup(struct mempolicy *pol);
 1141|static inline struct mempolicy *mpol_dup(struct mempolicy *pol)
 1142|{
 1143| if (pol)
 1144|  pol = __mpol_dup(pol);
 1145| return pol;
 1146|}
 1147|
 1148|
 1149|
 1150|
 1151|static inline void mpol_get(struct mempolicy *pol)
 1152|{
 1153| if (pol)
 1154|  atomic_inc(&pol->refcnt);
 1155|}
 1156|
 1157|extern int __mpol_equal(struct mempolicy *a, struct mempolicy *b);
 1158|static inline int mpol_equal(struct mempolicy *a, struct mempolicy *b)
 1159|{
 1160| if (a == b)
 1161|  return 1;
 1162| return __mpol_equal(a, b);
 1163|}
 1164|struct sp_node {
 1165| struct rb_node nd;
 1166| unsigned long start, end;
 1167| struct mempolicy *policy;
 1168|};
 1169|
 1170|struct shared_policy {
 1171| struct rb_root root;
 1172| spinlock_t lock;
 1173|};
 1174|
 1175|void mpol_shared_policy_init(struct shared_policy *sp, struct mempolicy *mpol);
 1176|int mpol_set_shared_policy(struct shared_policy *info,
 1177|    struct vm_area_struct *vma,
 1178|    struct mempolicy *new);
 1179|void mpol_free_shared_policy(struct shared_policy *p);
 1180|struct mempolicy *mpol_shared_policy_lookup(struct shared_policy *sp,
 1181|         unsigned long idx);
 1182|
 1183|extern void numa_default_policy(void);
 1184|extern void numa_policy_init(void);
 1185|extern void mpol_rebind_task(struct task_struct *tsk, const nodemask_t *new,
 1186|    enum mpol_rebind_step step);
 1187|extern void mpol_rebind_mm(struct mm_struct *mm, nodemask_t *new);
 1188|extern void mpol_fix_fork_child_flag(struct task_struct *p);
 1189|
 1190|extern struct zonelist *huge_zonelist(struct vm_area_struct *vma,
 1191|    unsigned long addr, gfp_t gfp_flags,
 1192|    struct mempolicy **mpol, nodemask_t **nodemask);
 1193|extern bool init_nodemask_of_mempolicy(nodemask_t *mask);
 1194|extern bool mempolicy_nodemask_intersects(struct task_struct *tsk,
 1195|    const nodemask_t *mask);
 1196|extern unsigned slab_node(struct mempolicy *policy);
 1197|
 1198|extern enum zone_type policy_zone;
 1199|
 1200|static inline void check_highest_zone(enum zone_type k)
 1201|{
 1202| if (k > policy_zone && k != ZONE_MOVABLE)
 1203|  policy_zone = k;
 1204|}
 1205|
 1206|int do_migrate_pages(struct mm_struct *mm,
 1207| const nodemask_t *from_nodes, const nodemask_t *to_nodes, int flags);
 1208|
 1209|
 1210|
 1211|extern int mpol_parse_str(char *str, struct mempolicy **mpol, int no_context);
 1212|
 1213|extern int mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol,
 1214|   int no_context);
 1215|
 1216|
 1217|
 1218|static inline int vma_migratable(struct vm_area_struct *vma)
 1219|{
 1220| if (vma->vm_flags & (0x00004000|0x00400000|0x00000400|0x00080000))
 1221|  return 0;
 1222|
 1223|
 1224|
 1225|
 1226|
 1227| if (vma->vm_file &&
 1228|  gfp_zone(mapping_gfp_mask(vma->vm_file->f_mapping))
 1229|        < policy_zone)
 1230|   return 0;
 1231| return 1;
 1232|}
 1233|
 1234|
 1235|
 1236|
 1237|
 1238|
 1239|struct shmem_inode_info {
 1240| spinlock_t lock;
 1241| unsigned long flags;
 1242| unsigned long alloced;
 1243| unsigned long swapped;
 1244| unsigned long next_index;
 1245| struct shared_policy policy;
 1246| struct page *i_indirect;
 1247| swp_entry_t i_direct[16];
 1248| struct list_head swaplist;
 1249| struct inode vfs_inode;
 1250|};
 1251|
 1252|struct shmem_sb_info {
 1253| unsigned long max_blocks;
 1254| struct percpu_counter used_blocks;
 1255| unsigned long max_inodes;
 1256| unsigned long free_inodes;
 1257| spinlock_t stat_lock;
 1258| uid_t uid;
 1259| gid_t gid;
 1260| mode_t mode;
 1261| struct mempolicy *mpol;
 1262|};
 1263|
 1264|static inline struct shmem_inode_info *SHMEM_I(struct inode *inode)
 1265|{
 1266| return ({ const typeof( ((struct shmem_inode_info *)0)->vfs_inode ) *__mptr = (inode); (struct shmem_inode_info *)( (char *)__mptr - 1 );});
 1267|}
 1268|
 1269|extern int init_tmpfs(void);
 1270|extern int shmem_fill_super(struct super_block *sb, void *data, int silent);
 1271|
 1272|
 1273|
 1274|
 1275|
 1276|
 1277|
 1278|extern struct device_type part_type;
 1279|extern struct kobject *block_depr;
 1280|extern struct class block_class;
 1281|
 1282|enum {
 1283|
 1284|
 1285| DOS_EXTENDED_PARTITION = 5,
 1286| LINUX_EXTENDED_PARTITION = 0x85,
 1287| WIN98_EXTENDED_PARTITION = 0x0f,
 1288|
 1289| SUN_WHOLE_DISK = DOS_EXTENDED_PARTITION,
 1290|
 1291| LINUX_SWAP_PARTITION = 0x82,
 1292| LINUX_DATA_PARTITION = 0x83,
 1293| LINUX_LVM_PARTITION = 0x8e,
 1294| LINUX_RAID_PARTITION = 0xfd,
 1295|
 1296| SOLARIS_X86_PARTITION = LINUX_SWAP_PARTITION,
 1297| NEW_SOLARIS_X86_PARTITION = 0xbf,
 1298|
 1299| DM6_AUX1PARTITION = 0x51,
 1300| DM6_AUX3PARTITION = 0x53,
 1301| DM6_PARTITION = 0x54,
 1302| EZD_PARTITION = 0x55,
 1303|
 1304| FREEBSD_PARTITION = 0xa5,
 1305| OPENBSD_PARTITION = 0xa6,
 1306| NETBSD_PARTITION = 0xa9,
 1307| BSDI_PARTITION = 0xb7,
 1308| MINIX_PARTITION = 0x81,
 1309| UNIXWARE_PARTITION = 0x63,
 1310|};
 1311|
 1312|
 1313|
 1314|
 1315|
 1316|struct klist_node;
 1317|struct klist {
 1318| spinlock_t k_lock;
 1319| struct list_head k_list;
 1320| void (*get)(struct klist_node *);
 1321| void (*put)(struct klist_node *);
 1322|} ;
 1323|extern void klist_init(struct klist *k, void (*get)(struct klist_node *),
 1324|         void (*put)(struct klist_node *));
 1325|
 1326|struct klist_node {
 1327| void *n_klist;
 1328| struct list_head n_node;
 1329| struct kref n_ref;
 1330|};
 1331|
 1332|extern void klist_add_tail(struct klist_node *n, struct klist *k);
 1333|extern void klist_add_head(struct klist_node *n, struct klist *k);
 1334|extern void klist_add_after(struct klist_node *n, struct klist_node *pos);
 1335|extern void klist_add_before(struct klist_node *n, struct klist_node *pos);
 1336|
 1337|extern void klist_del(struct klist_node *n);
 1338|extern void klist_remove(struct klist_node *n);
 1339|
 1340|extern int klist_node_attached(struct klist_node *n);
 1341|
 1342|
 1343|struct klist_iter {
 1344| struct klist *i_klist;
 1345| struct klist_node *i_cur;
 1346|};
 1347|
 1348|
 1349|extern void klist_iter_init(struct klist *k, struct klist_iter *i);
 1350|extern void klist_iter_init_node(struct klist *k, struct klist_iter *i,
 1351|     struct klist_node *n);
 1352|extern void klist_iter_exit(struct klist_iter *i);
 1353|extern struct klist_node *klist_next(struct klist_iter *i);
 1354|
 1355|
 1356|
 1357|
 1358|
 1359|
 1360|
 1361|
 1362|
 1363|
 1364|struct dev_archdata {
 1365|
 1366| void *acpi_handle;
 1367|
 1368|
 1369|struct dma_map_ops *dma_ops;
 1370|
 1371|
 1372| void *iommu;
 1373|
 1374|};
 1375|
 1376|struct pdev_archdata {
 1377|};
 1378|
 1379|struct device;
 1380|struct device_private;
 1381|struct device_driver;
 1382|struct driver_private;
 1383|struct class;
 1384|struct subsys_private;
 1385|struct bus_type;
 1386|struct device_node;
 1387|
 1388|struct bus_attribute {
 1389| struct attribute attr;
 1390| ssize_t (*show)(struct bus_type *bus, char *buf);
 1391| ssize_t (*store)(struct bus_type *bus, const char *buf, size_t count);
 1392|};
 1393|
 1394|
 1395|
 1396|
 1397|extern int bus_create_file(struct bus_type *,
 1398|     struct bus_attribute *);
 1399|extern void bus_remove_file(struct bus_type *, struct bus_attribute *);
 1400|
 1401|struct bus_type {
 1402| const char *name;
 1403| struct bus_attribute *bus_attrs;
 1404| struct device_attribute *dev_attrs;
 1405| struct driver_attribute *drv_attrs;
 1406|
 1407| int (*match)(struct device *dev, struct device_driver *drv);
 1408| int (*uevent)(struct device *dev, struct kobj_uevent_env *env);
 1409| int (*probe)(struct device *dev);
 1410| int (*remove)(struct device *dev);
 1411| void (*shutdown)(struct device *dev);
 1412|
 1413| int (*suspend)(struct device *dev, pm_message_t state);
 1414| int (*resume)(struct device *dev);
 1415|
 1416| const struct dev_pm_ops *pm;
 1417|
 1418| struct subsys_private *p;
 1419|};
 1420|
 1421|extern int bus_register(struct bus_type *bus);
 1422|extern void bus_unregister(struct bus_type *bus);
 1423|
 1424|extern int bus_rescan_devices(struct bus_type *bus);
 1425|
 1426|
 1427|
 1428|int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data,
 1429|       int (*fn)(struct device *dev, void *data));
 1430|struct device *bus_find_device(struct bus_type *bus, struct device *start,
 1431|          void *data,
 1432|          int (*match)(struct device *dev, void *data));
 1433|struct device *bus_find_device_by_name(struct bus_type *bus,
 1434|           struct device *start,
 1435|           const char *name);
 1436|
 1437|int bus_for_each_drv(struct bus_type *bus, struct device_driver *start,
 1438|       void *data, int (*fn)(struct device_driver *, void *));
 1439|
 1440|void bus_sort_breadthfirst(struct bus_type *bus,
 1441|      int (*compare)(const struct device *a,
 1442|       const struct device *b));
 1443|
 1444|
 1445|
 1446|
 1447|
 1448|
 1449|struct notifier_block;
 1450|
 1451|extern int bus_register_notifier(struct bus_type *bus,
 1452|     struct notifier_block *nb);
 1453|extern int bus_unregister_notifier(struct bus_type *bus,
 1454|       struct notifier_block *nb);
 1455|extern struct kset *bus_get_kset(struct bus_type *bus);
 1456|extern struct klist *bus_get_device_klist(struct bus_type *bus);
 1457|
 1458|struct device_driver {
 1459| const char *name;
 1460| struct bus_type *bus;
 1461|
 1462| struct module *owner;
 1463| const char *mod_name;
 1464|
 1465| bool suppress_bind_attrs;
 1466|
 1467|
 1468|
 1469|
 1470|
 1471| int (*probe) (struct device *dev);
 1472| int (*remove) (struct device *dev);
 1473| void (*shutdown) (struct device *dev);
 1474| int (*suspend) (struct device *dev, pm_message_t state);
 1475| int (*resume) (struct device *dev);
 1476| const struct attribute_group **groups;
 1477|
 1478| const struct dev_pm_ops *pm;
 1479|
 1480| struct driver_private *p;
 1481|};
 1482|
 1483|
 1484|extern int driver_register(struct device_driver *drv);
 1485|extern void driver_unregister(struct device_driver *drv);
 1486|
 1487|extern struct device_driver *get_driver(struct device_driver *drv);
 1488|extern void put_driver(struct device_driver *drv);
 1489|extern struct device_driver *driver_find(const char *name,
 1490|      struct bus_type *bus);
 1491|extern int driver_probe_done(void);
 1492|extern void wait_for_device_probe(void);
 1493|
 1494|
 1495|
 1496|
 1497|struct driver_attribute {
 1498| struct attribute attr;
 1499| ssize_t (*show)(struct device_driver *driver, char *buf);
 1500| ssize_t (*store)(struct device_driver *driver, const char *buf,
 1501|    size_t count);
 1502|};
 1503|
 1504|
 1505|
 1506|
 1507|
 1508|extern int driver_create_file(struct device_driver *driver,
 1509|     const struct driver_attribute *attr);
 1510|extern void driver_remove_file(struct device_driver *driver,
 1511|          const struct driver_attribute *attr);
 1512|
 1513|extern int driver_add_kobj(struct device_driver *drv,
 1514|     struct kobject *kobj,
 1515|     const char *fmt, ...);
 1516|
 1517|extern int driver_for_each_device(struct device_driver *drv,
 1518|            struct device *start,
 1519|            void *data,
 1520|            int (*fn)(struct device *dev,
 1521|        void *));
 1522|struct device *driver_find_device(struct device_driver *drv,
 1523|      struct device *start, void *data,
 1524|      int (*match)(struct device *dev, void *data));
 1525|
 1526|
 1527|
 1528|
 1529|struct class {
 1530| const char *name;
 1531| struct module *owner;
 1532|
 1533| struct class_attribute *class_attrs;
 1534| struct device_attribute *dev_attrs;
 1535| struct kobject *dev_kobj;
 1536|
 1537| int (*dev_uevent)(struct device *dev, struct kobj_uevent_env *env);
 1538| char *(*devnode)(struct device *dev, mode_t *mode);
 1539|
 1540| void (*class_release)(struct class *class);
 1541| void (*dev_release)(struct device *dev);
 1542|
 1543| int (*suspend)(struct device *dev, pm_message_t state);
 1544| int (*resume)(struct device *dev);
 1545|
 1546| const struct kobj_ns_type_operations *ns_type;
 1547| const void *(*namespace)(struct device *dev);
 1548|
 1549| const struct dev_pm_ops *pm;
 1550|
 1551| struct subsys_private *p;
 1552|};
 1553|
 1554|struct class_dev_iter {
 1555| struct klist_iter ki;
 1556| const struct device_type *type;
 1557|};
 1558|
 1559|extern struct kobject *sysfs_dev_block_kobj;
 1560|extern struct kobject *sysfs_dev_char_kobj;
 1561|extern int __class_register(struct class *class,
 1562|      struct lock_class_key *key);
 1563|extern void class_unregister(struct class *class);
 1564|struct class_compat;
 1565|struct class_compat *class_compat_register(const char *name);
 1566|void class_compat_unregister(struct class_compat *cls);
 1567|int class_compat_create_link(struct class_compat *cls, struct device *dev,
 1568|        struct device *device_link);
 1569|void class_compat_remove_link(struct class_compat *cls, struct device *dev,
 1570|         struct device *device_link);
 1571|
 1572|extern void class_dev_iter_init(struct class_dev_iter *iter,
 1573|    struct class *class,
 1574|    struct device *start,
 1575|    const struct device_type *type);
 1576|extern struct device *class_dev_iter_next(struct class_dev_iter *iter);
 1577|extern void class_dev_iter_exit(struct class_dev_iter *iter);
 1578|
 1579|extern int class_for_each_device(struct class *class, struct device *start,
 1580|     void *data,
 1581|     int (*fn)(struct device *dev, void *data));
 1582|extern struct device *class_find_device(struct class *class,
 1583|     struct device *start, void *data,
 1584|     int (*match)(struct device *, void *));
 1585|
 1586|struct class_attribute {
 1587| struct attribute attr;
 1588| ssize_t (*show)(struct class *class, struct class_attribute *attr,
 1589|   char *buf);
 1590| ssize_t (*store)(struct class *class, struct class_attribute *attr,
 1591|   const char *buf, size_t count);
 1592|};
 1593|
 1594|
 1595|
 1596|
 1597|extern int class_create_file(struct class *class,
 1598|       const struct class_attribute *attr);
 1599|extern void class_remove_file(struct class *class,
 1600|         const struct class_attribute *attr);
 1601|
 1602|
 1603|
 1604|struct class_attribute_string {
 1605| struct class_attribute attr;
 1606| char *str;
 1607|};
 1608|extern ssize_t show_class_attr_string(struct class *class, struct class_attribute *attr,
 1609|                        char *buf);
 1610|
 1611|struct class_interface {
 1612| struct list_head node;
 1613| struct class *class;
 1614|
 1615| int (*add_dev) (struct device *, struct class_interface *);
 1616| void (*remove_dev) (struct device *, struct class_interface *);
 1617|};
 1618|
 1619|extern int class_interface_register(struct class_interface *);
 1620|extern void class_interface_unregister(struct class_interface *);
 1621|
 1622|extern struct class * __class_create(struct module *owner,
 1623|        const char *name,
 1624|        struct lock_class_key *key);
 1625|extern void class_destroy(struct class *cls);
 1626|struct device_type {
 1627| const char *name;
 1628| const struct attribute_group **groups;
 1629| int (*uevent)(struct device *dev, struct kobj_uevent_env *env);
 1630| char *(*devnode)(struct device *dev, mode_t *mode);
 1631| void (*release)(struct device *dev);
 1632|
 1633| const struct dev_pm_ops *pm;
 1634|};
 1635|
 1636|
 1637|struct device_attribute {
 1638| struct attribute attr;
 1639| ssize_t (*show)(struct device *dev, struct device_attribute *attr,
 1640|   char *buf);
 1641| ssize_t (*store)(struct device *dev, struct device_attribute *attr,
 1642|    const char *buf, size_t count);
 1643|};
 1644|
 1645|
 1646|
 1647|
 1648|extern int device_create_file(struct device *device,
 1649|     const struct device_attribute *entry);
 1650|extern void device_remove_file(struct device *dev,
 1651|          const struct device_attribute *attr);
 1652|extern int device_create_bin_file(struct device *dev,
 1653|     const struct bin_attribute *attr);
 1654|extern void device_remove_bin_file(struct device *dev,
 1655|       const struct bin_attribute *attr);
 1656|extern int device_schedule_callback_owner(struct device *dev,
 1657|  void (*func)(struct device *dev), struct module *owner);
 1658|
 1659|
 1660|
 1661|
 1662|
 1663|
 1664|typedef void (*dr_release_t)(struct device *dev, void *res);
 1665|typedef int (*dr_match_t)(struct device *dev, void *res, void *match_data);
 1666|
 1667|
 1668|extern void *__devres_alloc(dr_release_t release, size_t size, gfp_t gfp,
 1669|        const char *name);
 1670|
 1671|
 1672|
 1673|
 1674|
 1675|extern void devres_free(void *res);
 1676|extern void devres_add(struct device *dev, void *res);
 1677|extern void *devres_find(struct device *dev, dr_release_t release,
 1678|    dr_match_t match, void *match_data);
 1679|extern void *devres_get(struct device *dev, void *new_res,
 1680|   dr_match_t match, void *match_data);
 1681|extern void *devres_remove(struct device *dev, dr_release_t release,
 1682|      dr_match_t match, void *match_data);
 1683|extern int devres_destroy(struct device *dev, dr_release_t release,
 1684|     dr_match_t match, void *match_data);
 1685|
 1686|
 1687|extern void * devres_open_group(struct device *dev, void *id,
 1688|          gfp_t gfp);
 1689|extern void devres_close_group(struct device *dev, void *id);
 1690|extern void devres_remove_group(struct device *dev, void *id);
 1691|extern int devres_release_group(struct device *dev, void *id);
 1692|
 1693|
 1694|extern void *devm_kzalloc(struct device *dev, size_t size, gfp_t gfp);
 1695|extern void devm_kfree(struct device *dev, void *p);
 1696|
 1697|struct device_dma_parameters {
 1698|
 1699|
 1700|
 1701|
 1702| unsigned int max_segment_size;
 1703| unsigned long segment_boundary_mask;
 1704|};
 1705|
 1706|struct device {
 1707| struct device *parent;
 1708|
 1709| struct device_private *p;
 1710|
 1711| struct kobject kobj;
 1712| const char *init_name;
 1713| struct device_type *type;
 1714|
 1715| struct mutex mutex;
 1716|
 1717|
 1718|
 1719| struct bus_type *bus;
 1720| struct device_driver *driver;
 1721|
 1722| void *platform_data;
 1723|
 1724| struct dev_pm_info power;
 1725|
 1726|
 1727| int numa_node;
 1728|
 1729| u64 *dma_mask;
 1730| u64 coherent_dma_mask;
 1731|
 1732|
 1733|
 1734|
 1735|
 1736| struct device_dma_parameters *dma_parms;
 1737|
 1738| struct list_head dma_pools;
 1739|
 1740| struct dma_coherent_mem *dma_mem;
 1741|
 1742|
 1743| struct dev_archdata archdata;
 1744|
 1745|
 1746|
 1747|
 1748| dev_t devt;
 1749|
 1750| spinlock_t devres_lock;
 1751| struct list_head devres_head;
 1752|
 1753| struct klist_node knode_class;
 1754| struct class *class;
 1755| const struct attribute_group **groups;
 1756|
 1757| void (*release)(struct device *dev);
 1758|};
 1759|
 1760|
 1761|struct wakeup_source {
 1762| char *name;
 1763| struct list_head entry;
 1764| spinlock_t lock;
 1765| struct timer_list timer;
 1766| unsigned long timer_expires;
 1767| ktime_t total_time;
 1768| ktime_t max_time;
 1769| ktime_t last_time;
 1770| unsigned long event_count;
 1771| unsigned long active_count;
 1772| unsigned long relax_count;
 1773| unsigned long hit_count;
 1774| unsigned int active:1;
 1775|};
 1776|
 1777|
 1778|
 1779|
 1780|
 1781|
 1782|
 1783|static inline void device_set_wakeup_capable(struct device *dev, bool capable)
 1784|{
 1785| dev->power.can_wakeup = capable;
 1786|}
 1787|
 1788|static inline bool device_can_wakeup(struct device *dev)
 1789|{
 1790| return dev->power.can_wakeup;
 1791|}
 1792|
 1793|
 1794|
 1795|static inline bool device_may_wakeup(struct device *dev)
 1796|{
 1797| return dev->power.can_wakeup && !!dev->power.wakeup;
 1798|}
 1799|
 1800|
 1801|extern struct wakeup_source *wakeup_source_create(const char *name);
 1802|extern void wakeup_source_destroy(struct wakeup_source *ws);
 1803|extern void wakeup_source_add(struct wakeup_source *ws);
 1804|extern void wakeup_source_remove(struct wakeup_source *ws);
 1805|extern struct wakeup_source *wakeup_source_register(const char *name);
 1806|extern void wakeup_source_unregister(struct wakeup_source *ws);
 1807|extern int device_wakeup_enable(struct device *dev);
 1808|extern int device_wakeup_disable(struct device *dev);
 1809|extern int device_init_wakeup(struct device *dev, bool val);
 1810|extern int device_set_wakeup_enable(struct device *dev, bool enable);
 1811|extern void __pm_stay_awake(struct wakeup_source *ws);
 1812|extern void pm_stay_awake(struct device *dev);
 1813|extern void __pm_relax(struct wakeup_source *ws);
 1814|extern void pm_relax(struct device *dev);
 1815|extern void __pm_wakeup_event(struct wakeup_source *ws, unsigned int msec);
 1816|extern void pm_wakeup_event(struct device *dev, unsigned int msec);
 1817|
 1818|static inline const char *dev_name(const struct device *dev)
 1819|{
 1820|
 1821| if (dev->init_name)
 1822|  return dev->init_name;
 1823|
 1824| return kobject_name(&dev->kobj);
 1825|}
 1826|
 1827|extern int dev_set_name(struct device *dev, const char *name, ...)
 1828|   ;
 1829|
 1830|
 1831|static inline int dev_to_node(struct device *dev)
 1832|{
 1833| return dev->numa_node;
 1834|}
 1835|static inline void set_dev_node(struct device *dev, int node)
 1836|{
 1837| dev->numa_node = node;
 1838|}
 1839|static inline unsigned int dev_get_uevent_suppress(const struct device *dev)
 1840|{
 1841| return dev->kobj.uevent_suppress;
 1842|}
 1843|
 1844|static inline void dev_set_uevent_suppress(struct device *dev, int val)
 1845|{
 1846| dev->kobj.uevent_suppress = val;
 1847|}
 1848|
 1849|static inline int device_is_registered(struct device *dev)
 1850|{
 1851| return dev->kobj.state_in_sysfs;
 1852|}
 1853|
 1854|static inline void device_enable_async_suspend(struct device *dev)
 1855|{
 1856| if (dev->power.status == DPM_ON)
 1857|  dev->power.async_suspend = true;
 1858|}
 1859|
 1860|static inline void device_disable_async_suspend(struct device *dev)
 1861|{
 1862| if (dev->power.status == DPM_ON)
 1863|  dev->power.async_suspend = false;
 1864|}
 1865|
 1866|static inline bool device_async_suspend_enabled(struct device *dev)
 1867|{
 1868| return !!dev->power.async_suspend;
 1869|}
 1870|
 1871|static inline void device_lock(struct device *dev)
 1872|{
 1873| mutex_lock_nested(&dev->mutex, 0);
 1874|}
 1875|
 1876|static inline int device_trylock(struct device *dev)
 1877|{
 1878| return mutex_trylock(&dev->mutex);
 1879|}
 1880|
 1881|static inline void device_unlock(struct device *dev)
 1882|{
 1883| mutex_unlock(&dev->mutex);
 1884|}
 1885|
 1886|void driver_init(void);
 1887|
 1888|
 1889|
 1890|
 1891|extern int device_register(struct device *dev);
 1892|extern void device_unregister(struct device *dev);
 1893|extern void device_initialize(struct device *dev);
 1894|extern int device_add(struct device *dev);
 1895|extern void device_del(struct device *dev);
 1896|extern int device_for_each_child(struct device *dev, void *data,
 1897|       int (*fn)(struct device *dev, void *data));
 1898|extern struct device *device_find_child(struct device *dev, void *data,
 1899|    int (*match)(struct device *dev, void *data));
 1900|extern int device_rename(struct device *dev, const char *new_name);
 1901|extern int device_move(struct device *dev, struct device *new_parent,
 1902|         enum dpm_order dpm_order);
 1903|extern const char *device_get_devnode(struct device *dev,
 1904|          mode_t *mode, const char **tmp);
 1905|extern void *dev_get_drvdata(const struct device *dev);
 1906|extern void dev_set_drvdata(struct device *dev, void *data);
 1907|
 1908|
 1909|
 1910|
 1911|extern struct device *__root_device_register(const char *name,
 1912|          struct module *owner);
 1913|static inline struct device *root_device_register(const char *name)
 1914|{
 1915| return __root_device_register(name, ((struct module *)0));
 1916|}
 1917|extern void root_device_unregister(struct device *root);
 1918|
 1919|static inline void *dev_get_platdata(const struct device *dev)
 1920|{
 1921| return dev->platform_data;
 1922|}
 1923|
 1924|
 1925|
 1926|
 1927|
 1928|extern int device_bind_driver(struct device *dev);
 1929|extern void device_release_driver(struct device *dev);
 1930|extern int device_attach(struct device *dev);
 1931|extern int driver_attach(struct device_driver *drv);
 1932|extern int device_reprobe(struct device *dev);
 1933|
 1934|
 1935|
 1936|
 1937|extern struct device *device_create_vargs(struct class *cls,
 1938|       struct device *parent,
 1939|       dev_t devt,
 1940|       void *drvdata,
 1941|       const char *fmt,
 1942|       int vargs);
 1943|extern struct device *device_create(struct class *cls, struct device *parent,
 1944|        dev_t devt, void *drvdata,
 1945|        const char *fmt, ...)
 1946|        ;
 1947|extern void device_destroy(struct class *cls, dev_t devt);
 1948|
 1949|
 1950|
 1951|
 1952|
 1953|
 1954|
 1955|extern int (*platform_notify)(struct device *dev);
 1956|
 1957|extern int (*platform_notify_remove)(struct device *dev);
 1958|
 1959|
 1960|
 1961|
 1962|
 1963|
 1964|extern struct device *get_device(struct device *dev);
 1965|extern void put_device(struct device *dev);
 1966|
 1967|extern void wait_for_device_probe(void);
 1968|
 1969|
 1970|extern int devtmpfs_create_node(struct device *dev);
 1971|extern int devtmpfs_delete_node(struct device *dev);
 1972|extern int devtmpfs_mount(const char *mntdir);
 1973|
 1974|
 1975|
 1976|
 1977|
 1978|
 1979|
 1980|extern void device_shutdown(void);
 1981|
 1982|
 1983|extern void sysdev_shutdown(void);
 1984|
 1985|
 1986|extern const char *dev_driver_string(const struct device *dev);
 1987|
 1988|
 1989|
 1990|
 1991|extern int dev_printk(const char *level, const struct device *dev,
 1992|        const char *fmt, ...)
 1993| ;
 1994|extern int dev_emerg(const struct device *dev, const char *fmt, ...)
 1995| ;
 1996|extern int dev_alert(const struct device *dev, const char *fmt, ...)
 1997| ;
 1998|extern int dev_crit(const struct device *dev, const char *fmt, ...)
 1999| ;
 2000|extern int dev_err(const struct device *dev, const char *fmt, ...)
 2001| ;
 2002|extern int dev_warn(const struct device *dev, const char *fmt, ...)
 2003| ;
 2004|extern int dev_notice(const struct device *dev, const char *fmt, ...)
 2005| ;
 2006|extern int _dev_info(const struct device *dev, const char *fmt, ...)
 2007| ;
 2008|extern long sysfs_deprecated;
 2009|
 2010|
 2011|
 2012|
 2013|
 2014|struct partition {
 2015| unsigned char boot_ind;
 2016| unsigned char head;
 2017| unsigned char sector;
 2018| unsigned char cyl;
 2019| unsigned char sys_ind;
 2020| unsigned char end_head;
 2021| unsigned char end_sector;
 2022| unsigned char end_cyl;
 2023| __le32 start_sect;
 2024| __le32 nr_sects;
 2025|} ;
 2026|
 2027|struct disk_stats {
 2028| unsigned long sectors[2];
 2029| unsigned long ios[2];
 2030| unsigned long merges[2];
 2031| unsigned long ticks[2];
 2032| unsigned long io_ticks;
 2033| unsigned long time_in_queue;
 2034|};
 2035|
 2036|
 2037|
 2038|
 2039|struct partition_meta_info {
 2040| u8 uuid[16];
 2041| u8 volname[64];
 2042|};
 2043|
 2044|struct hd_struct {
 2045| sector_t start_sect;
 2046| sector_t nr_sects;
 2047| sector_t alignment_offset;
 2048| unsigned int discard_alignment;
 2049| struct device __dev;
 2050| struct kobject *holder_dir;
 2051| int policy, partno;
 2052| struct partition_meta_info *info;
 2053|
 2054| int make_it_fail;
 2055|
 2056| unsigned long stamp;
 2057| int in_flight[2];
 2058|
 2059| struct disk_stats *dkstats;
 2060|
 2061|
 2062|
 2063| struct rcu_head rcu_head;
 2064|};
 2065|struct blk_scsi_cmd_filter {
 2066| unsigned long read_ok[((256) / (sizeof(long) * 8))];
 2067| unsigned long write_ok[((256) / (sizeof(long) * 8))];
 2068| struct kobject kobj;
 2069|};
 2070|
 2071|struct disk_part_tbl {
 2072| struct rcu_head rcu_head;
 2073| int len;
 2074| struct hd_struct *last_lookup;
 2075| struct hd_struct *part[];
 2076|};
 2077|
 2078|struct gendisk {
 2079|
 2080|
 2081|
 2082| int major;
 2083| int first_minor;
 2084| int minors;
 2085|
 2086|
 2087| char disk_name[32];
 2088| char *(*devnode)(struct gendisk *gd, mode_t *mode);
 2089|
 2090|
 2091|
 2092|
 2093|
 2094| struct disk_part_tbl *part_tbl;
 2095| struct hd_struct part0;
 2096|
 2097| const struct block_device_operations *fops;
 2098| struct request_queue *queue;
 2099| void *private_data;
 2100|
 2101| int flags;
 2102| struct device *driverfs_dev;
 2103| struct kobject *slave_dir;
 2104|
 2105| struct timer_rand_state *random;
 2106|
 2107| atomic_t sync_io;
 2108| struct work_struct async_notify;
 2109|
 2110| struct blk_integrity *integrity;
 2111|
 2112| int node_id;
 2113|};
 2114|
 2115|static inline struct gendisk *part_to_disk(struct hd_struct *part)
 2116|{
 2117| if (__builtin_expect(!!(part), 1)) {
 2118|  if (part->partno)
 2119|   return ({ const typeof( ((struct gendisk *)0)->part0.__dev ) *__mptr = (((&((part)->__dev))->parent)); (struct gendisk *)( (char *)__mptr - 1 );});
 2120|  else
 2121|   return ({ const typeof( ((struct gendisk *)0)->part0.__dev ) *__mptr = (((&((part)->__dev)))); (struct gendisk *)( (char *)__mptr - 1 );});
 2122| }
 2123| return ((void *)0);
 2124|}
 2125|
 2126|static inline void part_pack_uuid(const u8 *uuid_str, u8 *to)
 2127|{
 2128| int i;
 2129| for (i = 0; i < 16; ++i) {
 2130|  *to++ = (hex_to_bin(*uuid_str) << 4) |
 2131|   (hex_to_bin(*(uuid_str + 1)));
 2132|  uuid_str += 2;
 2133|  switch (i) {
 2134|  case 3:
 2135|  case 5:
 2136|  case 7:
 2137|  case 9:
 2138|   uuid_str++;
 2139|   continue;
 2140|  }
 2141| }
 2142|}
 2143|
 2144|static inline char *part_unpack_uuid(const u8 *uuid, char *out)
 2145|{
 2146| sprintf(out, "%pU", uuid);
 2147| return out;
 2148|}
 2149|
 2150|static inline int disk_max_parts(struct gendisk *disk)
 2151|{
 2152| if (disk->flags & 64)
 2153|  return 256;
 2154| return disk->minors;
 2155|}
 2156|
 2157|static inline bool disk_partitionable(struct gendisk *disk)
 2158|{
 2159| return disk_max_parts(disk) > 1;
 2160|}
 2161|
 2162|static inline dev_t disk_devt(struct gendisk *disk)
 2163|{
 2164| return (&(disk)->part0.__dev)->devt;
 2165|}
 2166|
 2167|static inline dev_t part_devt(struct hd_struct *part)
 2168|{
 2169| return (&((part)->__dev))->devt;
 2170|}
 2171|
 2172|extern struct hd_struct *disk_get_part(struct gendisk *disk, int partno);
 2173|
 2174|static inline void disk_put_part(struct hd_struct *part)
 2175|{
 2176| if (__builtin_expect(!!(part), 1))
 2177|  put_device((&((part)->__dev)));
 2178|}
 2179|struct disk_part_iter {
 2180| struct gendisk *disk;
 2181| struct hd_struct *part;
 2182| int idx;
 2183| unsigned int flags;
 2184|};
 2185|
 2186|extern void disk_part_iter_init(struct disk_part_iter *piter,
 2187|     struct gendisk *disk, unsigned int flags);
 2188|extern struct hd_struct *disk_part_iter_next(struct disk_part_iter *piter);
 2189|extern void disk_part_iter_exit(struct disk_part_iter *piter);
 2190|
 2191|extern struct hd_struct *disk_map_sector_rcu(struct gendisk *disk,
 2192|          sector_t sector);
 2193|static inline void part_stat_set_all(struct hd_struct *part, int value)
 2194|{
 2195| int i;
 2196|
 2197| for (((i)) = -1; ((i)) = cpumask_next(((i)), (cpu_possible_mask)), ((i)) < nr_cpu_ids;)
 2198|  memset(({ do { const void *__vpp_verify = (typeof(((part->dkstats))))((void *)0); (void)__vpp_verify; } while (0); ({ unsigned long __ptr; __asm__ ("" : "=r"(__ptr) : "0"((typeof(*((part->dkstats))) *)((part->dkstats)))); (typeof((typeof(*((part->dkstats))) *)((part->dkstats)))) (__ptr + (((__per_cpu_offset[(i)])))); }); }), value,
 2199|    sizeof(struct disk_stats));
 2200|}
 2201|
 2202|static inline int init_part_stats(struct hd_struct *part)
 2203|{
 2204| part->dkstats = (typeof(struct disk_stats) *)__alloc_percpu(sizeof(struct disk_stats), __alignof__(struct disk_stats));
 2205| if (!part->dkstats)
 2206|  return 0;
 2207| return 1;
 2208|}
 2209|
 2210|static inline void free_part_stats(struct hd_struct *part)
 2211|{
 2212| free_percpu(part->dkstats);
 2213|}
 2214|static inline void part_inc_in_flight(struct hd_struct *part, int rw)
 2215|{
 2216| part->in_flight[rw]++;
 2217| if (part->partno)
 2218|  part_to_disk(part)->part0.in_flight[rw]++;
 2219|}
 2220|
 2221|static inline void part_dec_in_flight(struct hd_struct *part, int rw)
 2222|{
 2223| part->in_flight[rw]--;
 2224| if (part->partno)
 2225|  part_to_disk(part)->part0.in_flight[rw]--;
 2226|}
 2227|
 2228|static inline int part_in_flight(struct hd_struct *part)
 2229|{
 2230| return part->in_flight[0] + part->in_flight[1];
 2231|}
 2232|
 2233|static inline struct partition_meta_info *alloc_part_info(struct gendisk *disk)
 2234|{
 2235| if (disk)
 2236|  return kzalloc_node(sizeof(struct partition_meta_info),
 2237|        ((( gfp_t)0x10u) | (( gfp_t)0x40u) | (( gfp_t)0x80u)), disk->node_id);
 2238| return kzalloc(sizeof(struct partition_meta_info), ((( gfp_t)0x10u) | (( gfp_t)0x40u) | (( gfp_t)0x80u)));
 2239|}
 2240|
 2241|static inline void free_part_info(struct hd_struct *part)
 2242|{
 2243| kfree(part->info);
 2244|}
 2245|
 2246|
 2247|extern void part_round_stats(int cpu, struct hd_struct *part);
 2248|
 2249|
 2250|extern void add_disk(struct gendisk *disk);
 2251|extern void del_gendisk(struct gendisk *gp);
 2252|extern void unlink_gendisk(struct gendisk *gp);
 2253|extern struct gendisk *get_gendisk(dev_t dev, int *partno);
 2254|extern struct block_device *bdget_disk(struct gendisk *disk, int partno);
 2255|
 2256|extern void set_device_ro(struct block_device *bdev, int flag);
 2257|extern void set_disk_ro(struct gendisk *disk, int flag);
 2258|
 2259|static inline int get_disk_ro(struct gendisk *disk)
 2260|{
 2261| return disk->part0.policy;
 2262|}
 2263|
 2264|
 2265|extern void add_disk_randomness(struct gendisk *disk);
 2266|extern void rand_initialize_disk(struct gendisk *disk);
 2267|
 2268|static inline sector_t get_start_sect(struct block_device *bdev)
 2269|{
 2270| return bdev->bd_part->start_sect;
 2271|}
 2272|static inline sector_t get_capacity(struct gendisk *disk)
 2273|{
 2274| return disk->part0.nr_sects;
 2275|}
 2276|static inline void set_capacity(struct gendisk *disk, sector_t size)
 2277|{
 2278| disk->part0.nr_sects = size;
 2279|}
 2280|
 2281|
 2282|
 2283|
 2284|
 2285|
 2286|struct solaris_x86_slice {
 2287| __le16 s_tag;
 2288| __le16 s_flag;
 2289| __le32 s_start;
 2290| __le32 s_size;
 2291|};
 2292|
 2293|struct solaris_x86_vtoc {
 2294| unsigned int v_bootinfo[3];
 2295| __le32 v_sanity;
 2296| __le32 v_version;
 2297| char v_volume[8];
 2298| __le16 v_sectorsz;
 2299| __le16 v_nparts;
 2300| unsigned int v_reserved[10];
 2301| struct solaris_x86_slice
 2302|  v_slice[16];
 2303| unsigned int timestamp[16];
 2304| char v_asciilabel[128];
 2305|};
 2306|struct bsd_disklabel {
 2307| __le32 d_magic;
 2308| __s16 d_type;
 2309| __s16 d_subtype;
 2310| char d_typename[16];
 2311| char d_packname[16];
 2312| __u32 d_secsize;
 2313| __u32 d_nsectors;
 2314| __u32 d_ntracks;
 2315| __u32 d_ncylinders;
 2316| __u32 d_secpercyl;
 2317| __u32 d_secperunit;
 2318| __u16 d_sparespertrack;
 2319| __u16 d_sparespercyl;
 2320| __u32 d_acylinders;
 2321| __u16 d_rpm;
 2322| __u16 d_interleave;
 2323| __u16 d_trackskew;
 2324| __u16 d_cylskew;
 2325| __u32 d_headswitch;
 2326| __u32 d_trkseek;
 2327| __u32 d_flags;
 2328|
 2329| __u32 d_drivedata[5];
 2330|
 2331| __u32 d_spare[5];
 2332| __le32 d_magic2;
 2333| __le16 d_checksum;
 2334|
 2335|
 2336| __le16 d_npartitions;
 2337| __le32 d_bbsize;
 2338| __le32 d_sbsize;
 2339| struct bsd_partition {
 2340|  __le32 p_size;
 2341|  __le32 p_offset;
 2342|  __le32 p_fsize;
 2343|  __u8 p_fstype;
 2344|  __u8 p_frag;
 2345|  __le16 p_cpg;
 2346| } d_partitions[16];
 2347|};
 2348|struct unixware_slice {
 2349| __le16 s_label;
 2350| __le16 s_flags;
 2351| __le32 start_sect;
 2352| __le32 nr_sects;
 2353|};
 2354|
 2355|struct unixware_disklabel {
 2356| __le32 d_type;
 2357| __le32 d_magic;
 2358| __le32 d_version;
 2359| char d_serial[12];
 2360| __le32 d_ncylinders;
 2361| __le32 d_ntracks;
 2362| __le32 d_nsectors;
 2363| __le32 d_secsize;
 2364| __le32 d_part_start;
 2365| __le32 d_unknown1[12];
 2366|  __le32 d_alt_tbl;
 2367|  __le32 d_alt_len;
 2368|  __le32 d_phys_cyl;
 2369|  __le32 d_phys_trk;
 2370|  __le32 d_phys_sec;
 2371|  __le32 d_phys_bytes;
 2372|  __le32 d_unknown2;
 2373| __le32 d_unknown3;
 2374| __le32 d_pad[8];
 2375|
 2376| struct unixware_vtoc {
 2377|  __le32 v_magic;
 2378|  __le32 v_version;
 2379|  char v_name[8];
 2380|  __le16 v_nslices;
 2381|  __le16 v_unknown1;
 2382|  __le32 v_reserved[10];
 2383|  struct unixware_slice
 2384|   v_slice[16];
 2385| } vtoc;
 2386|
 2387|};
 2388|extern int blk_alloc_devt(struct hd_struct *part, dev_t *devt);
 2389|extern void blk_free_devt(dev_t devt);
 2390|extern dev_t blk_lookup_devt(const char *name, int partno);
 2391|extern char *disk_name (struct gendisk *hd, int partno, char *buf);
 2392|
 2393|extern int disk_expand_part_tbl(struct gendisk *disk, int target);
 2394|extern int rescan_partitions(struct gendisk *disk, struct block_device *bdev);
 2395|extern struct hd_struct * add_partition(struct gendisk *disk,
 2396|           int partno, sector_t start,
 2397|           sector_t len, int flags,
 2398|           struct partition_meta_info
 2399|             *info);
 2400|extern void delete_partition(struct gendisk *, int);
 2401|extern void printk_all_partitions(void);
 2402|
 2403|extern struct gendisk *alloc_disk_node(int minors, int node_id);
 2404|extern struct gendisk *alloc_disk(int minors);
 2405|extern struct kobject *get_disk(struct gendisk *disk);
 2406|extern void put_disk(struct gendisk *disk);
 2407|extern void blk_register_region(dev_t devt, unsigned long range,
 2408|   struct module *module,
 2409|   struct kobject *(*probe)(dev_t, int *, void *),
 2410|   int (*lock)(dev_t, void *),
 2411|   void *data);
 2412|extern void blk_unregister_region(dev_t devt, unsigned long range);
 2413|
 2414|extern ssize_t part_size_show(struct device *dev,
 2415|         struct device_attribute *attr, char *buf);
 2416|extern ssize_t part_stat_show(struct device *dev,
 2417|         struct device_attribute *attr, char *buf);
 2418|extern ssize_t part_inflight_show(struct device *dev,
 2419|         struct device_attribute *attr, char *buf);
 2420|
 2421|extern ssize_t part_fail_show(struct device *dev,
 2422|         struct device_attribute *attr, char *buf);
 2423|extern ssize_t part_fail_store(struct device *dev,
 2424|          struct device_attribute *attr,
 2425|          const char *buf, size_t count);
 2426|
 2427|
 2428|
 2429|
 2430|
 2431|
 2432|struct kmem_cache;
 2433|
 2434|typedef void * (mempool_alloc_t)(gfp_t gfp_mask, void *pool_data);
 2435|typedef void (mempool_free_t)(void *element, void *pool_data);
 2436|
 2437|typedef struct mempool_s {
 2438| spinlock_t lock;
 2439| int min_nr;
 2440| int curr_nr;
 2441| void **elements;
 2442|
 2443| void *pool_data;
 2444| mempool_alloc_t *alloc;
 2445| mempool_free_t *free;
 2446| wait_queue_head_t wait;
 2447|} mempool_t;
 2448|
 2449|extern mempool_t *mempool_create(int min_nr, mempool_alloc_t *alloc_fn,
 2450|   mempool_free_t *free_fn, void *pool_data);
 2451|extern mempool_t *mempool_create_node(int min_nr, mempool_alloc_t *alloc_fn,
 2452|   mempool_free_t *free_fn, void *pool_data, int nid);
 2453|
 2454|extern int mempool_resize(mempool_t *pool, int new_min_nr, gfp_t gfp_mask);
 2455|extern void mempool_destroy(mempool_t *pool);
 2456|extern void * mempool_alloc(mempool_t *pool, gfp_t gfp_mask);
 2457|extern void mempool_free(void *element, mempool_t *pool);
 2458|
 2459|
 2460|
 2461|
 2462|
 2463|void *mempool_alloc_slab(gfp_t gfp_mask, void *pool_data);
 2464|void mempool_free_slab(void *element, void *pool_data);
 2465|static inline mempool_t *
 2466|mempool_create_slab_pool(int min_nr, struct kmem_cache *kc)
 2467|{
 2468| return mempool_create(min_nr, mempool_alloc_slab, mempool_free_slab,
 2469|         (void *) kc);
 2470|}
 2471|
 2472|
 2473|
 2474|
 2475|
 2476|void *mempool_kmalloc(gfp_t gfp_mask, void *pool_data);
 2477|void mempool_kfree(void *element, void *pool_data);
 2478|static inline mempool_t *mempool_create_kmalloc_pool(int min_nr, size_t size)
 2479|{
 2480| return mempool_create(min_nr, mempool_kmalloc, mempool_kfree,
 2481|         (void *) size);
 2482|}
 2483|
 2484|
 2485|
 2486|
 2487|
 2488|void *mempool_alloc_pages(gfp_t gfp_mask, void *pool_data);
 2489|void mempool_free_pages(void *element, void *pool_data);
 2490|static inline mempool_t *mempool_create_page_pool(int min_nr, int order)
 2491|{
 2492| return mempool_create(min_nr, mempool_alloc_pages, mempool_free_pages,
 2493|         (void *)(long)order);
 2494|}
 2495|
 2496|
 2497|
 2498|
 2499|
 2500|
 2501|
 2502|
 2503|
 2504|
 2505|struct cfq_queue;
 2506|struct cfq_io_context {
 2507| void *key;
 2508|
 2509| struct cfq_queue *cfqq[2];
 2510|
 2511| struct io_context *ioc;
 2512|
 2513| unsigned long last_end_request;
 2514|
 2515| unsigned long ttime_total;
 2516| unsigned long ttime_samples;
 2517| unsigned long ttime_mean;
 2518|
 2519| struct list_head queue_list;
 2520| struct hlist_node cic_list;
 2521|
 2522| void (*dtor)(struct io_context *);
 2523| void (*exit)(struct io_context *);
 2524|
 2525| struct rcu_head rcu_head;
 2526|};
 2527|
 2528|
 2529|
 2530|
 2531|
 2532|struct io_context {
 2533| atomic_long_t refcount;
 2534| atomic_t nr_tasks;
 2535|
 2536|
 2537| spinlock_t lock;
 2538|
 2539| unsigned short ioprio;
 2540| unsigned short ioprio_changed;
 2541|
 2542|
 2543| unsigned short cgroup_changed;
 2544|
 2545|
 2546|
 2547|
 2548|
 2549| int nr_batch_requests;
 2550| unsigned long last_waited;
 2551|
 2552| struct radix_tree_root radix_root;
 2553| struct hlist_head cic_list;
 2554| void *ioc_data;
 2555|};
 2556|
 2557|static inline struct io_context *ioc_task_link(struct io_context *ioc)
 2558|{
 2559|
 2560|
 2561|
 2562|
 2563| if (ioc && atomic64_add_unless(((atomic64_t *)(&ioc->refcount)), 1, 0)) {
 2564|  atomic_inc(&ioc->nr_tasks);
 2565|  return ioc;
 2566| }
 2567|
 2568| return ((void *)0);
 2569|}
 2570|
 2571|struct task_struct;
 2572|
 2573|int put_io_context(struct io_context *ioc);
 2574|void exit_io_context(struct task_struct *task);
 2575|struct io_context *get_io_context(gfp_t gfp_flags, int node);
 2576|struct io_context *alloc_io_context(gfp_t gfp_flags, int node);
 2577|enum {
 2578| IOPRIO_CLASS_NONE,
 2579| IOPRIO_CLASS_RT,
 2580| IOPRIO_CLASS_BE,
 2581| IOPRIO_CLASS_IDLE,
 2582|};
 2583|
 2584|
 2585|
 2586|
 2587|
 2588|
 2589|enum {
 2590| IOPRIO_WHO_PROCESS = 1,
 2591| IOPRIO_WHO_PGRP,
 2592| IOPRIO_WHO_USER,
 2593|};
 2594|
 2595|
 2596|
 2597|
 2598|
 2599|
 2600|static inline int task_ioprio(struct io_context *ioc)
 2601|{
 2602| if (((((ioc->ioprio)) >> (13)) != IOPRIO_CLASS_NONE))
 2603|  return ((ioc->ioprio) & ((1UL << (13)) - 1));
 2604|
 2605| return (4);
 2606|}
 2607|
 2608|static inline int task_ioprio_class(struct io_context *ioc)
 2609|{
 2610| if (((((ioc->ioprio)) >> (13)) != IOPRIO_CLASS_NONE))
 2611|  return ((ioc->ioprio) >> (13));
 2612|
 2613| return IOPRIO_CLASS_BE;
 2614|}
 2615|
 2616|static inline int task_nice_ioprio(struct task_struct *task)
 2617|{
 2618| return (task_nice(task) + 20) / 5;
 2619|}
 2620|
 2621|
 2622|
 2623|
 2624|
 2625|static inline int task_nice_ioclass(struct task_struct *task)
 2626|{
 2627| if (task->policy == 5)
 2628|  return IOPRIO_CLASS_IDLE;
 2629| else if (task->policy == 1 || task->policy == 2)
 2630|  return IOPRIO_CLASS_RT;
 2631| else
 2632|  return IOPRIO_CLASS_BE;
 2633|}
 2634|
 2635|
 2636|
 2637|
 2638|extern int ioprio_best(unsigned short aprio, unsigned short bprio);
 2639|
 2640|extern int set_task_ioprio(struct task_struct *task, int ioprio);
 2641|
 2642|
 2643|
 2644|
 2645|
 2646|
 2647|enum xen_domain_type {
 2648| XEN_NATIVE,
 2649| XEN_PV_DOMAIN,
 2650| XEN_HVM_DOMAIN,
 2651|};
 2652|
 2653|
 2654|extern enum xen_domain_type xen_domain_type;
 2655|typedef unsigned char * __guest_handle_uchar;
 2656|typedef unsigned int * __guest_handle_uint;
 2657|typedef unsigned long * __guest_handle_ulong;
 2658|typedef char * __guest_handle_char;
 2659|typedef int * __guest_handle_int;
 2660|typedef long * __guest_handle_long;
 2661|typedef void * __guest_handle_void;
 2662|struct trap_info {
 2663|    uint8_t vector;
 2664|    uint8_t flags;
 2665|    uint16_t cs;
 2666|    unsigned long address;
 2667|};
 2668|typedef struct trap_info * __guest_handle_trap_info;
 2669|
 2670|struct arch_shared_info {
 2671|    unsigned long max_pfn;
 2672|
 2673|    unsigned long pfn_to_mfn_frame_list_list;
 2674|    unsigned long nmi_reason;
 2675|};
 2676|
 2677|
 2678|
 2679|
 2680|
 2681|struct iret_context {
 2682|
 2683|    uint64_t rax, r11, rcx, flags, rip, cs, rflags, rsp, ss;
 2684|
 2685|};
 2686|struct cpu_user_regs {
 2687|    uint64_t r15;
 2688|    uint64_t r14;
 2689|    uint64_t r13;
 2690|    uint64_t r12;
 2691|    union { uint64_t rbp, ebp; uint32_t _ebp; };
 2692|    union { uint64_t rbx, ebx; uint32_t _ebx; };
 2693|    uint64_t r11;
 2694|    uint64_t r10;
 2695|    uint64_t r9;
 2696|    uint64_t r8;
 2697|    union { uint64_t rax, eax; uint32_t _eax; };
 2698|    union { uint64_t rcx, ecx; uint32_t _ecx; };
 2699|    union { uint64_t rdx, edx; uint32_t _edx; };
 2700|    union { uint64_t rsi, esi; uint32_t _esi; };
 2701|    union { uint64_t rdi, edi; uint32_t _edi; };
 2702|    uint32_t error_code;
 2703|    uint32_t entry_vector;
 2704|    union { uint64_t rip, eip; uint32_t _eip; };
 2705|    uint16_t cs, _pad0[1];
 2706|    uint8_t saved_upcall_mask;
 2707|    uint8_t _pad1[3];
 2708|    union { uint64_t rflags, eflags; uint32_t _eflags; };
 2709|    union { uint64_t rsp, esp; uint32_t _esp; };
 2710|    uint16_t ss, _pad2[3];
 2711|    uint16_t es, _pad3[3];
 2712|    uint16_t ds, _pad4[3];
 2713|    uint16_t fs, _pad5[3];
 2714|    uint16_t gs, _pad6[3];
 2715|};
 2716|typedef struct cpu_user_regs * __guest_handle_cpu_user_regs;
 2717|
 2718|
 2719|
 2720|
 2721|
 2722|
 2723|struct arch_vcpu_info {
 2724|    unsigned long cr2;
 2725|    unsigned long pad;
 2726|};
 2727|
 2728|typedef unsigned long xen_callback_t;
 2729|
 2730|
 2731|
 2732|
 2733|
 2734|
 2735|
 2736|struct vcpu_guest_context {
 2737|
 2738|    struct { char x[512]; } fpu_ctxt;
 2739|
 2740|
 2741|
 2742|    unsigned long flags;
 2743|    struct cpu_user_regs user_regs;
 2744|    struct trap_info trap_ctxt[256];
 2745|    unsigned long ldt_base, ldt_ents;
 2746|    unsigned long gdt_frames[16], gdt_ents;
 2747|    unsigned long kernel_ss, kernel_sp;
 2748|
 2749|    unsigned long ctrlreg[8];
 2750|    unsigned long debugreg[8];
 2751|
 2752|
 2753|
 2754|
 2755|
 2756|
 2757|    unsigned long event_callback_eip;
 2758|    unsigned long failsafe_callback_eip;
 2759|    unsigned long syscall_callback_eip;
 2760|
 2761|    unsigned long vm_assist;
 2762|
 2763|
 2764|    uint64_t fs_base;
 2765|    uint64_t gs_base_kernel;
 2766|    uint64_t gs_base_user;
 2767|
 2768|};
 2769|typedef struct vcpu_guest_context * __guest_handle_vcpu_guest_context;
 2770|struct pvclock_vcpu_time_info {
 2771| u32 version;
 2772| u32 pad0;
 2773| u64 tsc_timestamp;
 2774| u64 system_time;
 2775| u32 tsc_to_system_mul;
 2776| s8 tsc_shift;
 2777| u8 flags;
 2778| u8 pad[2];
 2779|} ;
 2780|
 2781|struct pvclock_wall_clock {
 2782| u32 version;
 2783| u32 sec;
 2784| u32 nsec;
 2785|} ;
 2786|struct mmuext_op {
 2787| unsigned int cmd;
 2788| union {
 2789|
 2790|  unsigned long mfn;
 2791|
 2792|  unsigned long linear_addr;
 2793| } arg1;
 2794| union {
 2795|
 2796|  unsigned int nr_ents;
 2797|
 2798|  void *vcpumask;
 2799| } arg2;
 2800|};
 2801|typedef struct mmuext_op * __guest_handle_mmuext_op;
 2802|typedef uint16_t domid_t;
 2803|struct mmu_update {
 2804|    uint64_t ptr;
 2805|    uint64_t val;
 2806|};
 2807|typedef struct mmu_update * __guest_handle_mmu_update;
 2808|
 2809|
 2810|
 2811|
 2812|
 2813|struct multicall_entry {
 2814|    unsigned long op;
 2815|    long result;
 2816|    unsigned long args[6];
 2817|};
 2818|typedef struct multicall_entry * __guest_handle_multicall_entry;
 2819|
 2820|
 2821|
 2822|
 2823|
 2824|
 2825|
 2826|struct vcpu_time_info {
 2827| uint32_t version;
 2828| uint32_t pad0;
 2829| uint64_t tsc_timestamp;
 2830| uint64_t system_time;
 2831|
 2832|
 2833|
 2834|
 2835|
 2836|
 2837| uint32_t tsc_to_system_mul;
 2838| int8_t tsc_shift;
 2839| int8_t pad1[3];
 2840|};
 2841|
 2842|struct vcpu_info {
 2843| uint8_t evtchn_upcall_pending;
 2844| uint8_t evtchn_upcall_mask;
 2845| unsigned long evtchn_pending_sel;
 2846| struct arch_vcpu_info arch;
 2847| struct pvclock_vcpu_time_info time;
 2848|};
 2849|
 2850|
 2851|
 2852|
 2853|
 2854|struct shared_info {
 2855| struct vcpu_info vcpu_info[32];
 2856| unsigned long evtchn_pending[sizeof(unsigned long) * 8];
 2857| unsigned long evtchn_mask[sizeof(unsigned long) * 8];
 2858|
 2859|
 2860|
 2861|
 2862|
 2863| struct pvclock_wall_clock wc;
 2864|
 2865| struct arch_shared_info arch;
 2866|
 2867|};
 2868|struct start_info {
 2869|
 2870| char magic[32];
 2871| unsigned long nr_pages;
 2872| unsigned long shared_info;
 2873| uint32_t flags;
 2874| unsigned long store_mfn;
 2875| uint32_t store_evtchn;
 2876| union {
 2877|  struct {
 2878|   unsigned long mfn;
 2879|   uint32_t evtchn;
 2880|  } domU;
 2881|  struct {
 2882|   uint32_t info_off;
 2883|   uint32_t info_size;
 2884|  } dom0;
 2885| } console;
 2886|
 2887| unsigned long pt_base;
 2888| unsigned long nr_pt_frames;
 2889| unsigned long mfn_list;
 2890| unsigned long mod_start;
 2891| unsigned long mod_len;
 2892| int8_t cmd_line[1024];
 2893|};
 2894|
 2895|
 2896|
 2897|
 2898|
 2899|typedef uint64_t cpumap_t;
 2900|
 2901|typedef uint8_t xen_domain_handle_t[16];
 2902|
 2903|
 2904|
 2905|
 2906|
 2907|
 2908|
 2909|struct tmem_op {
 2910| uint32_t cmd;
 2911| int32_t pool_id;
 2912| union {
 2913|  struct {
 2914|   uint64_t uuid[2];
 2915|   uint32_t flags;
 2916|  } new;
 2917|  struct {
 2918|   uint64_t oid[3];
 2919|   uint32_t index;
 2920|   uint32_t tmem_offset;
 2921|   uint32_t pfn_offset;
 2922|   uint32_t len;
 2923|   __guest_handle_void gmfn;
 2924|  } gen;
 2925| } u;
 2926|};
 2927|extern struct shared_info *HYPERVISOR_shared_info;
 2928|extern struct start_info *xen_start_info;
 2929|static inline unsigned char readb(const volatile void *addr) { unsigned char ret; asm volatile("mov" "b" " %1,%0":"=q" (ret) :"m" (*(volatile unsigned char *)addr) :"memory"); return ret; }
 2930|static inline unsigned short readw(const volatile void *addr) { unsigned short ret; asm volatile("mov" "w" " %1,%0":"=r" (ret) :"m" (*(volatile unsigned short *)addr) :"memory"); return ret; }
 2931|static inline unsigned int readl(const volatile void *addr) { unsigned int ret; asm volatile("mov" "l" " %1,%0":"=r" (ret) :"m" (*(volatile unsigned int *)addr) :"memory"); return ret; }
 2932|
 2933|static inline unsigned char __readb(const volatile void *addr) { unsigned char ret; asm volatile("mov" "b" " %1,%0":"=q" (ret) :"m" (*(volatile unsigned char *)addr) ); return ret; }
 2934|static inline unsigned short __readw(const volatile void *addr) { unsigned short ret; asm volatile("mov" "w" " %1,%0":"=r" (ret) :"m" (*(volatile unsigned short *)addr) ); return ret; }
 2935|static inline unsigned int __readl(const volatile void *addr) { unsigned int ret; asm volatile("mov" "l" " %1,%0":"=r" (ret) :"m" (*(volatile unsigned int *)addr) ); return ret; }
 2936|
 2937|static inline void writeb(unsigned char val, volatile void *addr) { asm volatile("mov" "b" " %0,%1": :"q" (val), "m" (*(volatile unsigned char *)addr) :"memory"); }
 2938|static inline void writew(unsigned short val, volatile void *addr) { asm volatile("mov" "w" " %0,%1": :"r" (val), "m" (*(volatile unsigned short *)addr) :"memory"); }
 2939|static inline void writel(unsigned int val, volatile void *addr) { asm volatile("mov" "l" " %0,%1": :"r" (val), "m" (*(volatile unsigned int *)addr) :"memory"); }
 2940|
 2941|static inline void __writeb(unsigned char val, volatile void *addr) { asm volatile("mov" "b" " %0,%1": :"q" (val), "m" (*(volatile unsigned char *)addr) ); }
 2942|static inline void __writew(unsigned short val, volatile void *addr) { asm volatile("mov" "w" " %0,%1": :"r" (val), "m" (*(volatile unsigned short *)addr) ); }
 2943|static inline void __writel(unsigned int val, volatile void *addr) { asm volatile("mov" "l" " %0,%1": :"r" (val), "m" (*(volatile unsigned int *)addr) ); }
 2944|static inline unsigned long readq(const volatile void *addr) { unsigned long ret; asm volatile("mov" "q" " %1,%0":"=r" (ret) :"m" (*(volatile unsigned long *)addr) :"memory"); return ret; }
 2945|static inline void writeq(unsigned long val, volatile void *addr) { asm volatile("mov" "q" " %0,%1": :"r" (val), "m" (*(volatile unsigned long *)addr) :"memory"); }
 2946|static inline phys_addr_t virt_to_phys(volatile void *address)
 2947|{
 2948| return __phys_addr((unsigned long)(address));
 2949|}
 2950|static inline void *phys_to_virt(phys_addr_t address)
 2951|{
 2952| return ((void *)((unsigned long)(address)+((unsigned long)(0xffff880000000000UL))));
 2953|}
 2954|static inline unsigned int isa_virt_to_bus(volatile void *address)
 2955|{
 2956| return (unsigned int)virt_to_phys(address);
 2957|}
 2958|extern void *ioremap_nocache(resource_size_t offset, unsigned long size);
 2959|extern void *ioremap_cache(resource_size_t offset, unsigned long size);
 2960|extern void *ioremap_prot(resource_size_t offset, unsigned long size,
 2961|    unsigned long prot_val);
 2962|
 2963|
 2964|
 2965|
 2966|static inline void *ioremap(resource_size_t offset, unsigned long size)
 2967|{
 2968| return ioremap_nocache(offset, size);
 2969|}
 2970|
 2971|extern void iounmap(volatile void *addr);
 2972|
 2973|extern void set_iounmap_nonlazy(void);
 2974|
 2975|
 2976|
 2977|extern unsigned int ioread8(void *);
 2978|extern unsigned int ioread16(void *);
 2979|extern unsigned int ioread16be(void *);
 2980|extern unsigned int ioread32(void *);
 2981|extern unsigned int ioread32be(void *);
 2982|
 2983|extern void iowrite8(u8, void *);
 2984|extern void iowrite16(u16, void *);
 2985|extern void iowrite16be(u16, void *);
 2986|extern void iowrite32(u32, void *);
 2987|extern void iowrite32be(u32, void *);
 2988|extern void ioread8_rep(void *port, void *buf, unsigned long count);
 2989|extern void ioread16_rep(void *port, void *buf, unsigned long count);
 2990|extern void ioread32_rep(void *port, void *buf, unsigned long count);
 2991|
 2992|extern void iowrite8_rep(void *port, const void *buf, unsigned long count);
 2993|extern void iowrite16_rep(void *port, const void *buf, unsigned long count);
 2994|extern void iowrite32_rep(void *port, const void *buf, unsigned long count);
 2995|
 2996|
 2997|extern void *ioport_map(unsigned long port, unsigned int nr);
 2998|extern void ioport_unmap(void *);
 2999|
 3000|
 3001|
 3002|
 3003|
 3004|
 3005|struct pci_dev;
 3006|extern void *pci_iomap(struct pci_dev *dev, int bar, unsigned long max);
 3007|extern void pci_iounmap(struct pci_dev *dev, void *);
 3008|
 3009|
 3010|
 3011|
 3012|
 3013|
 3014|
 3015|
 3016|struct vm_area_struct;
 3017|
 3018|extern bool vmap_lazy_unmap;
 3019|struct vm_struct {
 3020| struct vm_struct *next;
 3021| void *addr;
 3022| unsigned long size;
 3023| unsigned long flags;
 3024| struct page **pages;
 3025| unsigned int nr_pages;
 3026| phys_addr_t phys_addr;
 3027| void *caller;
 3028|};
 3029|
 3030|
 3031|
 3032|
 3033|extern void vm_unmap_ram(const void *mem, unsigned int count);
 3034|extern void *vm_map_ram(struct page **pages, unsigned int count,
 3035|    int node, pgprot_t prot);
 3036|extern void vm_unmap_aliases(void);
 3037|
 3038|
 3039|extern void vmalloc_init(void);
 3040|
 3041|
 3042|
 3043|
 3044|
 3045|
 3046|extern void *vmalloc(unsigned long size);
 3047|extern void *vzalloc(unsigned long size);
 3048|extern void *vmalloc_user(unsigned long size);
 3049|extern void *vmalloc_node(unsigned long size, int node);
 3050|extern void *vzalloc_node(unsigned long size, int node);
 3051|extern void *vmalloc_exec(unsigned long size);
 3052|extern void *vmalloc_32(unsigned long size);
 3053|extern void *vmalloc_32_user(unsigned long size);
 3054|extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
 3055|extern void *__vmalloc_area(struct vm_struct *area, gfp_t gfp_mask,
 3056|    pgprot_t prot);
 3057|extern void vfree(const void *addr);
 3058|
 3059|extern void *vmap(struct page **pages, unsigned int count,
 3060|   unsigned long flags, pgprot_t prot);
 3061|extern void vunmap(const void *addr);
 3062|
 3063|extern int remap_vmalloc_range(struct vm_area_struct *vma, void *addr,
 3064|       unsigned long pgoff);
 3065|void vmalloc_sync_all(void);
 3066|
 3067|
 3068|
 3069|
 3070|
 3071|static inline size_t get_vm_area_size(const struct vm_struct *area)
 3072|{
 3073|
 3074| return area->size - ((1UL) << 12);
 3075|}
 3076|
 3077|extern struct vm_struct *get_vm_area(unsigned long size, unsigned long flags);
 3078|extern struct vm_struct *get_vm_area_caller(unsigned long size,
 3079|     unsigned long flags, void *caller);
 3080|extern struct vm_struct *__get_vm_area(unsigned long size, unsigned long flags,
 3081|     unsigned long start, unsigned long end);
 3082|extern struct vm_struct *__get_vm_area_caller(unsigned long size,
 3083|     unsigned long flags,
 3084|     unsigned long start, unsigned long end,
 3085|     void *caller);
 3086|extern struct vm_struct *get_vm_area_node(unsigned long size,
 3087|       unsigned long flags, int node,
 3088|       gfp_t gfp_mask);
 3089|extern struct vm_struct *remove_vm_area(const void *addr);
 3090|
 3091|extern int map_vm_area(struct vm_struct *area, pgprot_t prot,
 3092|   struct page ***pages);
 3093|extern int map_kernel_range_noflush(unsigned long start, unsigned long size,
 3094|        pgprot_t prot, struct page **pages);
 3095|extern void unmap_kernel_range_noflush(unsigned long addr, unsigned long size);
 3096|extern void unmap_kernel_range(unsigned long addr, unsigned long size);
 3097|
 3098|
 3099|extern struct vm_struct *alloc_vm_area(size_t size);
 3100|extern void free_vm_area(struct vm_struct *area);
 3101|
 3102|
 3103|extern long vread(char *buf, char *addr, unsigned long count);
 3104|extern long vwrite(char *buf, char *addr, unsigned long count);
 3105|
 3106|
 3107|
 3108|
 3109|extern rwlock_t vmlist_lock;
 3110|extern struct vm_struct *vmlist;
 3111|extern void vm_area_register_early(struct vm_struct *vm, size_t align);
 3112|
 3113|
 3114|struct vm_struct **pcpu_get_vm_areas(const unsigned long *offsets,
 3115|         const size_t *sizes, int nr_vms,
 3116|         size_t align, gfp_t gfp_mask);
 3117|
 3118|void pcpu_free_vm_areas(struct vm_struct **vms, int nr_vms);
 3119|
 3120|
 3121|
 3122|
 3123|
 3124|
 3125|static inline void
 3126|memset_io(volatile void *addr, unsigned char val, size_t count)
 3127|{
 3128| memset((void *)addr, val, count);
 3129|}
 3130|
 3131|static inline void
 3132|memcpy_fromio(void *dst, const volatile void *src, size_t count)
 3133|{
 3134| memcpy(dst, (const void *)src, count);
 3135|}
 3136|
 3137|static inline void
 3138|memcpy_toio(volatile void *dst, const void *src, size_t count)
 3139|{
 3140| memcpy((void *)dst, src, count);
 3141|}
 3142|static inline void flush_write_buffers(void)
 3143|{
 3144|
 3145|
 3146|
 3147|}
 3148|
 3149|
 3150|
 3151|extern void native_io_delay(void);
 3152|
 3153|extern int io_delay_type;
 3154|extern void io_delay_init(void);
 3155|static inline void outb(unsigned char value, int port) { asm volatile("out" "b" " %" "b" "0, %w1" : : "a"(value), "Nd"(port)); } static inline unsigned char inb(int port) { unsigned char value; asm volatile("in" "b" " %w1, %" "b" "0" : "=a"(value) : "Nd"(port)); return value; } static inline void outb_p(unsigned char value, int port) { outb(value, port); slow_down_io(); } static inline unsigned char inb_p(int port) { unsigned char value = inb(port); slow_down_io(); return value; } static inline void outsb(int port, const void *addr, unsigned long count) { asm volatile("rep; outs" "b" : "+S"(addr), "+c"(count) : "d"(port)); } static inline void insb(int port, void *addr, unsigned long count) { asm volatile("rep; ins" "b" : "+D"(addr), "+c"(count) : "d"(port)); }
 3156|static inline void outw(unsigned short value, int port) { asm volatile("out" "w" " %" "w" "0, %w1" : : "a"(value), "Nd"(port)); } static inline unsigned short inw(int port) { unsigned short value; asm volatile("in" "w" " %w1, %" "w" "0" : "=a"(value) : "Nd"(port)); return value; } static inline void outw_p(unsigned short value, int port) { outw(value, port); slow_down_io(); } static inline unsigned short inw_p(int port) { unsigned short value = inw(port); slow_down_io(); return value; } static inline void outsw(int port, const void *addr, unsigned long count) { asm volatile("rep; outs" "w" : "+S"(addr), "+c"(count) : "d"(port)); } static inline void insw(int port, void *addr, unsigned long count) { asm volatile("rep; ins" "w" : "+D"(addr), "+c"(count) : "d"(port)); }
 3157|static inline void outl(unsigned int value, int port) { asm volatile("out" "l" " %" "" "0, %w1" : : "a"(value), "Nd"(port)); } static inline unsigned int inl(int port) { unsigned int value; asm volatile("in" "l" " %w1, %" "" "0" : "=a"(value) : "Nd"(port)); return value; } static inline void outl_p(unsigned int value, int port) { outl(value, port); slow_down_io(); } static inline unsigned int inl_p(int port) { unsigned int value = inl(port); slow_down_io(); return value; } static inline void outsl(int port, const void *addr, unsigned long count) { asm volatile("rep; outs" "l" : "+S"(addr), "+c"(count) : "d"(port)); } static inline void insl(int port, void *addr, unsigned long count) { asm volatile("rep; ins" "l" : "+D"(addr), "+c"(count) : "d"(port)); }
 3158|
 3159|extern void *xlate_dev_mem_ptr(unsigned long phys);
 3160|extern void unxlate_dev_mem_ptr(unsigned long phys, void *addr);
 3161|
 3162|extern int ioremap_change_attr(unsigned long vaddr, unsigned long size,
 3163|    unsigned long prot_val);
 3164|extern void *ioremap_wc(resource_size_t offset, unsigned long size);
 3165|
 3166|
 3167|
 3168|
 3169|
 3170|
 3171|extern void early_ioremap_init(void);
 3172|extern void early_ioremap_reset(void);
 3173|extern void *early_ioremap(resource_size_t phys_addr,
 3174|       unsigned long size);
 3175|extern void *early_memremap(resource_size_t phys_addr,
 3176|        unsigned long size);
 3177|extern void early_iounmap(void *addr, unsigned long size);
 3178|extern void fixup_early_ioremap(void);
 3179|extern bool is_early_ioremap_ptep(pte_t *ptep);
 3180|
 3181|
 3182|struct bio_vec;
 3183|
 3184|extern bool xen_biovec_phys_mergeable(const struct bio_vec *vec1,
 3185|          const struct bio_vec *vec2);
 3186|static inline unsigned int bio_cur_bytes(struct bio *bio)
 3187|{
 3188| if (bio->bi_vcnt)
 3189|  return (&(((bio))->bi_io_vec[((bio)->bi_idx)]))->bv_len;
 3190| else
 3191|  return bio->bi_size;
 3192|}
 3193|
 3194|static inline void *bio_data(struct bio *bio)
 3195|{
 3196| if (bio->bi_vcnt)
 3197|  return lowmem_page_address((&((((bio)))->bi_io_vec[(((bio))->bi_idx)]))->bv_page) + (&((((bio)))->bi_io_vec[(((bio))->bi_idx)]))->bv_offset;
 3198|
 3199| return ((void *)0);
 3200|}
 3201|
 3202|static inline int bio_has_allocated_vec(struct bio *bio)
 3203|{
 3204| return bio->bi_io_vec && bio->bi_io_vec != bio->bi_inline_vecs;
 3205|}
 3206|struct bio_integrity_payload {
 3207| struct bio *bip_bio;
 3208|
 3209| sector_t bip_sector;
 3210|
 3211| void *bip_buf;
 3212| bio_end_io_t *bip_end_io;
 3213|
 3214| unsigned int bip_size;
 3215|
 3216| unsigned short bip_slab;
 3217| unsigned short bip_vcnt;
 3218| unsigned short bip_idx;
 3219|
 3220| struct work_struct bip_work;
 3221| struct bio_vec bip_vec[0];
 3222|};
 3223|struct bio_pair {
 3224| struct bio bio1, bio2;
 3225| struct bio_vec bv1, bv2;
 3226|
 3227| struct bio_integrity_payload bip1, bip2;
 3228| struct bio_vec iv1, iv2;
 3229|
 3230| atomic_t cnt;
 3231| int error;
 3232|};
 3233|extern struct bio_pair *bio_split(struct bio *bi, int first_sectors);
 3234|extern void bio_pair_release(struct bio_pair *dbio);
 3235|
 3236|extern struct bio_set *bioset_create(unsigned int, unsigned int);
 3237|extern void bioset_free(struct bio_set *);
 3238|
 3239|extern struct bio *bio_alloc(gfp_t, int);
 3240|extern struct bio *bio_kmalloc(gfp_t, int);
 3241|extern struct bio *bio_alloc_bioset(gfp_t, int, struct bio_set *);
 3242|extern void bio_put(struct bio *);
 3243|extern void bio_free(struct bio *, struct bio_set *);
 3244|
 3245|extern void bio_endio(struct bio *, int);
 3246|struct request_queue;
 3247|extern int bio_phys_segments(struct request_queue *, struct bio *);
 3248|
 3249|extern void __bio_clone(struct bio *, struct bio *);
 3250|extern struct bio *bio_clone(struct bio *, gfp_t);
 3251|
 3252|extern void bio_init(struct bio *);
 3253|
 3254|extern int bio_add_page(struct bio *, struct page *, unsigned int,unsigned int);
 3255|extern int bio_add_pc_page(struct request_queue *, struct bio *, struct page *,
 3256|      unsigned int, unsigned int);
 3257|extern int bio_get_nr_vecs(struct block_device *);
 3258|extern sector_t bio_sector_offset(struct bio *, unsigned short, unsigned int);
 3259|extern struct bio *bio_map_user(struct request_queue *, struct block_device *,
 3260|    unsigned long, unsigned int, int, gfp_t);
 3261|struct sg_iovec;
 3262|struct rq_map_data;
 3263|extern struct bio *bio_map_user_iov(struct request_queue *,
 3264|        struct block_device *,
 3265|        struct sg_iovec *, int, int, gfp_t);
 3266|extern void bio_unmap_user(struct bio *);
 3267|extern struct bio *bio_map_kern(struct request_queue *, void *, unsigned int,
 3268|    gfp_t);
 3269|extern struct bio *bio_copy_kern(struct request_queue *, void *, unsigned int,
 3270|     gfp_t, int);
 3271|extern void bio_set_pages_dirty(struct bio *bio);
 3272|extern void bio_check_pages_dirty(struct bio *bio);
 3273|
 3274|
 3275|
 3276|
 3277|
 3278|
 3279|
 3280|static inline void bio_flush_dcache_pages(struct bio *bi)
 3281|{
 3282|}
 3283|
 3284|
 3285|extern struct bio *bio_copy_user(struct request_queue *, struct rq_map_data *,
 3286|     unsigned long, unsigned int, int, gfp_t);
 3287|extern struct bio *bio_copy_user_iov(struct request_queue *,
 3288|         struct rq_map_data *, struct sg_iovec *,
 3289|         int, int, gfp_t);
 3290|extern int bio_uncopy_user(struct bio *);
 3291|void zero_fill_bio(struct bio *bio);
 3292|extern struct bio_vec *bvec_alloc_bs(gfp_t, int, unsigned long *, struct bio_set *);
 3293|extern void bvec_free_bs(struct bio_set *, struct bio_vec *, unsigned int);
 3294|extern unsigned int bvec_nr_vecs(unsigned short idx);
 3295|
 3296|
 3297|
 3298|
 3299|static inline void bio_set_completion_cpu(struct bio *bio, unsigned int cpu)
 3300|{
 3301| bio->bi_comp_cpu = cpu;
 3302|}
 3303|struct bio_set {
 3304| struct kmem_cache *bio_slab;
 3305| unsigned int front_pad;
 3306|
 3307| mempool_t *bio_pool;
 3308|
 3309| mempool_t *bio_integrity_pool;
 3310|
 3311| mempool_t *bvec_pool;
 3312|};
 3313|
 3314|struct biovec_slab {
 3315| int nr_vecs;
 3316| char *name;
 3317| struct kmem_cache *slab;
 3318|};
 3319|
 3320|extern struct bio_set *fs_bio_set;
 3321|extern struct biovec_slab bvec_slabs[6] ;
 3322|static inline char *bvec_kmap_irq(struct bio_vec *bvec, unsigned long *flags)
 3323|{
 3324| return lowmem_page_address(bvec->bv_page) + bvec->bv_offset;
 3325|}
 3326|
 3327|static inline void bvec_kunmap_irq(char *buffer, unsigned long *flags)
 3328|{
 3329| *flags = 0;
 3330|}
 3331|
 3332|
 3333|static inline char *__bio_kmap_irq(struct bio *bio, unsigned short idx,
 3334|       unsigned long *flags)
 3335|{
 3336| return bvec_kmap_irq((&((bio)->bi_io_vec[(idx)])), flags);
 3337|}
 3338|static inline int bio_has_data(struct bio *bio)
 3339|{
 3340| return bio && bio->bi_io_vec != ((void *)0);
 3341|}
 3342|struct bio_list {
 3343| struct bio *head;
 3344| struct bio *tail;
 3345|};
 3346|
 3347|static inline int bio_list_empty(const struct bio_list *bl)
 3348|{
 3349| return bl->head == ((void *)0);
 3350|}
 3351|
 3352|static inline void bio_list_init(struct bio_list *bl)
 3353|{
 3354| bl->head = bl->tail = ((void *)0);
 3355|}
 3356|
 3357|
 3358|
 3359|
 3360|static inline unsigned bio_list_size(const struct bio_list *bl)
 3361|{
 3362| unsigned sz = 0;
 3363| struct bio *bio;
 3364|
 3365| for (bio = (bl)->head; bio; bio = bio->bi_next)
 3366|  sz++;
 3367|
 3368| return sz;
 3369|}
 3370|
 3371|static inline void bio_list_add(struct bio_list *bl, struct bio *bio)
 3372|{
 3373| bio->bi_next = ((void *)0);
 3374|
 3375| if (bl->tail)
 3376|  bl->tail->bi_next = bio;
 3377| else
 3378|  bl->head = bio;
 3379|
 3380| bl->tail = bio;
 3381|}
 3382|
 3383|static inline void bio_list_add_head(struct bio_list *bl, struct bio *bio)
 3384|{
 3385| bio->bi_next = bl->head;
 3386|
 3387| bl->head = bio;
 3388|
 3389| if (!bl->tail)
 3390|  bl->tail = bio;
 3391|}
 3392|
 3393|static inline void bio_list_merge(struct bio_list *bl, struct bio_list *bl2)
 3394|{
 3395| if (!bl2->head)
 3396|  return;
 3397|
 3398| if (bl->tail)
 3399|  bl->tail->bi_next = bl2->head;
 3400| else
 3401|  bl->head = bl2->head;
 3402|
 3403| bl->tail = bl2->tail;
 3404|}
 3405|
 3406|static inline void bio_list_merge_head(struct bio_list *bl,
 3407|           struct bio_list *bl2)
 3408|{
 3409| if (!bl2->head)
 3410|  return;
 3411|
 3412| if (bl->head)
 3413|  bl2->tail->bi_next = bl->head;
 3414| else
 3415|  bl->tail = bl2->tail;
 3416|
 3417| bl->head = bl2->head;
 3418|}
 3419|
 3420|static inline struct bio *bio_list_peek(struct bio_list *bl)
 3421|{
 3422| return bl->head;
 3423|}
 3424|
 3425|static inline struct bio *bio_list_pop(struct bio_list *bl)
 3426|{
 3427| struct bio *bio = bl->head;
 3428|
 3429| if (bio) {
 3430|  bl->head = bl->head->bi_next;
 3431|  if (!bl->head)
 3432|   bl->tail = ((void *)0);
 3433|
 3434|  bio->bi_next = ((void *)0);
 3435| }
 3436|
 3437| return bio;
 3438|}
 3439|
 3440|static inline struct bio *bio_list_get(struct bio_list *bl)
 3441|{
 3442| struct bio *bio = bl->head;
 3443|
 3444| bl->head = bl->tail = ((void *)0);
 3445|
 3446| return bio;
 3447|}
 3448|extern struct bio_integrity_payload *bio_integrity_alloc_bioset(struct bio *, gfp_t, unsigned int, struct bio_set *);
 3449|extern struct bio_integrity_payload *bio_integrity_alloc(struct bio *, gfp_t, unsigned int);
 3450|extern void bio_integrity_free(struct bio *, struct bio_set *);
 3451|extern int bio_integrity_add_page(struct bio *, struct page *, unsigned int, unsigned int);
 3452|extern int bio_integrity_enabled(struct bio *bio);
 3453|extern int bio_integrity_set_tag(struct bio *, void *, unsigned int);
 3454|extern int bio_integrity_get_tag(struct bio *, void *, unsigned int);
 3455|extern int bio_integrity_prep(struct bio *);
 3456|extern void bio_integrity_endio(struct bio *, int);
 3457|extern void bio_integrity_advance(struct bio *, unsigned int);
 3458|extern void bio_integrity_trim(struct bio *, unsigned int, unsigned int);
 3459|extern void bio_integrity_split(struct bio *, struct bio_pair *, int);
 3460|extern int bio_integrity_clone(struct bio *, struct bio *, gfp_t, struct bio_set *);
 3461|extern int bioset_integrity_create(struct bio_set *, int);
 3462|extern void bioset_integrity_free(struct bio_set *);
 3463|extern void bio_integrity_init(void);
 3464|
 3465|
 3466|
 3467|struct sg_io_v4 {
 3468| __s32 guard;
 3469| __u32 protocol;
 3470| __u32 subprotocol;
 3471|
 3472|
 3473| __u32 request_len;
 3474| __u64 request;
 3475| __u64 request_tag;
 3476| __u32 request_attr;
 3477| __u32 request_priority;
 3478| __u32 request_extra;
 3479| __u32 max_response_len;
 3480| __u64 response;
 3481|
 3482|
 3483| __u32 dout_iovec_count;
 3484|
 3485| __u32 dout_xfer_len;
 3486| __u32 din_iovec_count;
 3487| __u32 din_xfer_len;
 3488| __u64 dout_xferp;
 3489| __u64 din_xferp;
 3490|
 3491| __u32 timeout;
 3492| __u32 flags;
 3493| __u64 usr_ptr;
 3494| __u32 spare_in;
 3495|
 3496| __u32 driver_status;
 3497| __u32 transport_status;
 3498| __u32 device_status;
 3499| __u32 retry_delay;
 3500| __u32 info;
 3501| __u32 duration;
 3502| __u32 response_len;
 3503| __s32 din_resid;
 3504| __s32 dout_resid;
 3505| __u64 generated_tag;
 3506| __u32 spare_out;
 3507|
 3508| __u32 padding;
 3509|};
 3510|
 3511|
 3512|
 3513|
 3514|struct bsg_class_device {
 3515| struct device *class_dev;
 3516| struct device *parent;
 3517| int minor;
 3518| struct request_queue *queue;
 3519| struct kref ref;
 3520| void (*release)(struct device *);
 3521|};
 3522|
 3523|extern int bsg_register_queue(struct request_queue *q,
 3524|         struct device *parent, const char *name,
 3525|         void (*release)(struct device *));
 3526|extern void bsg_unregister_queue(struct request_queue *);
 3527|
 3528|
 3529|
 3530|
 3531|
 3532|
 3533|
 3534|
 3535|
 3536|
 3537|struct scatterlist {
 3538|
 3539| unsigned long sg_magic;
 3540|
 3541| unsigned long page_link;
 3542| unsigned int offset;
 3543| unsigned int length;
 3544| dma_addr_t dma_address;
 3545|
 3546| unsigned int dma_length;
 3547|
 3548|};
 3549|
 3550|struct scsi_ioctl_command;
 3551|
 3552|struct request_queue;
 3553|struct elevator_queue;
 3554|struct request_pm_state;
 3555|struct blk_trace;
 3556|struct request;
 3557|struct sg_io_hdr;
 3558|
 3559|
 3560|
 3561|
 3562|struct request;
 3563|typedef void (rq_end_io_fn)(struct request *, int);
 3564|
 3565|struct request_list {
 3566|
 3567|
 3568|
 3569|
 3570| int count[2];
 3571| int starved[2];
 3572| int elvpriv;
 3573| mempool_t *rq_pool;
 3574| wait_queue_head_t wait[2];
 3575|};
 3576|
 3577|
 3578|
 3579|
 3580|enum rq_cmd_type_bits {
 3581| REQ_TYPE_FS = 1,
 3582| REQ_TYPE_BLOCK_PC,
 3583| REQ_TYPE_SENSE,
 3584| REQ_TYPE_PM_SUSPEND,
 3585| REQ_TYPE_PM_RESUME,
 3586| REQ_TYPE_PM_SHUTDOWN,
 3587| REQ_TYPE_SPECIAL,
 3588|
 3589|
 3590|
 3591|
 3592|
 3593| REQ_TYPE_ATA_TASKFILE,
 3594| REQ_TYPE_ATA_PC,
 3595|};
 3596|struct request {
 3597| struct list_head queuelist;
 3598| struct call_single_data csd;
 3599|
 3600| struct request_queue *q;
 3601|
 3602| unsigned int cmd_flags;
 3603| enum rq_cmd_type_bits cmd_type;
 3604| unsigned long atomic_flags;
 3605|
 3606| int cpu;
 3607|
 3608|
 3609| unsigned int __data_len;
 3610| sector_t __sector;
 3611|
 3612| struct bio *bio;
 3613| struct bio *biotail;
 3614|
 3615| struct hlist_node hash;
 3616|
 3617|
 3618|
 3619|
 3620|
 3621| union {
 3622|  struct rb_node rb_node;
 3623|  void *completion_data;
 3624| };
 3625|
 3626|
 3627|
 3628|
 3629|
 3630| void *elevator_private;
 3631| void *elevator_private2;
 3632| void *elevator_private3;
 3633|
 3634| struct gendisk *rq_disk;
 3635| unsigned long start_time;
 3636|
 3637|
 3638|
 3639|
 3640|
 3641|
 3642|
 3643| unsigned short nr_phys_segments;
 3644|
 3645| unsigned short nr_integrity_segments;
 3646|
 3647|
 3648| unsigned short ioprio;
 3649|
 3650| int ref_count;
 3651|
 3652| void *special;
 3653| char *buffer;
 3654|
 3655| int tag;
 3656| int errors;
 3657|
 3658|
 3659|
 3660|
 3661| unsigned char __cmd[16];
 3662| unsigned char *cmd;
 3663| unsigned short cmd_len;
 3664|
 3665| unsigned int extra_len;
 3666| unsigned int sense_len;
 3667| unsigned int resid_len;
 3668| void *sense;
 3669|
 3670| unsigned long deadline;
 3671| struct list_head timeout_list;
 3672| unsigned int timeout;
 3673| int retries;
 3674|
 3675|
 3676|
 3677|
 3678| rq_end_io_fn *end_io;
 3679| void *end_io_data;
 3680|
 3681|
 3682| struct request *next_rq;
 3683|};
 3684|
 3685|static inline unsigned short req_get_ioprio(struct request *req)
 3686|{
 3687| return req->ioprio;
 3688|}
 3689|
 3690|
 3691|
 3692|
 3693|
 3694|struct request_pm_state
 3695|{
 3696|
 3697| int pm_step;
 3698|
 3699| u32 pm_state;
 3700| void* data;
 3701|};
 3702|
 3703|
 3704|
 3705|
 3706|
 3707|
 3708|
 3709|
 3710|typedef int (elevator_merge_fn) (struct request_queue *, struct request **,
 3711|     struct bio *);
 3712|
 3713|typedef void (elevator_merge_req_fn) (struct request_queue *, struct request *, struct request *);
 3714|
 3715|typedef void (elevator_merged_fn) (struct request_queue *, struct request *, int);
 3716|
 3717|typedef int (elevator_allow_merge_fn) (struct request_queue *, struct request *, struct bio *);
 3718|
 3719|typedef void (elevator_bio_merged_fn) (struct request_queue *,
 3720|      struct request *, struct bio *);
 3721|
 3722|typedef int (elevator_dispatch_fn) (struct request_queue *, int);
 3723|
 3724|typedef void (elevator_add_req_fn) (struct request_queue *, struct request *);
 3725|typedef int (elevator_queue_empty_fn) (struct request_queue *);
 3726|typedef struct request *(elevator_request_list_fn) (struct request_queue *, struct request *);
 3727|typedef void (elevator_completed_req_fn) (struct request_queue *, struct request *);
 3728|typedef int (elevator_may_queue_fn) (struct request_queue *, int);
 3729|
 3730|typedef int (elevator_set_req_fn) (struct request_queue *, struct request *, gfp_t);
 3731|typedef void (elevator_put_req_fn) (struct request *);
 3732|typedef void (elevator_activate_req_fn) (struct request_queue *, struct request *);
 3733|typedef void (elevator_deactivate_req_fn) (struct request_queue *, struct request *);
 3734|
 3735|typedef void *(elevator_init_fn) (struct request_queue *);
 3736|typedef void (elevator_exit_fn) (struct elevator_queue *);
 3737|
 3738|struct elevator_ops
 3739|{
 3740| elevator_merge_fn *elevator_merge_fn;
 3741| elevator_merged_fn *elevator_merged_fn;
 3742| elevator_merge_req_fn *elevator_merge_req_fn;
 3743| elevator_allow_merge_fn *elevator_allow_merge_fn;
 3744| elevator_bio_merged_fn *elevator_bio_merged_fn;
 3745|
 3746| elevator_dispatch_fn *elevator_dispatch_fn;
 3747| elevator_add_req_fn *elevator_add_req_fn;
 3748| elevator_activate_req_fn *elevator_activate_req_fn;
 3749| elevator_deactivate_req_fn *elevator_deactivate_req_fn;
 3750|
 3751| elevator_queue_empty_fn *elevator_queue_empty_fn;
 3752| elevator_completed_req_fn *elevator_completed_req_fn;
 3753|
 3754| elevator_request_list_fn *elevator_former_req_fn;
 3755| elevator_request_list_fn *elevator_latter_req_fn;
 3756|
 3757| elevator_set_req_fn *elevator_set_req_fn;
 3758| elevator_put_req_fn *elevator_put_req_fn;
 3759|
 3760| elevator_may_queue_fn *elevator_may_queue_fn;
 3761|
 3762| elevator_init_fn *elevator_init_fn;
 3763| elevator_exit_fn *elevator_exit_fn;
 3764| void (*trim)(struct io_context *);
 3765|};
 3766|
 3767|
 3768|
 3769|struct elv_fs_entry {
 3770| struct attribute attr;
 3771| ssize_t (*show)(struct elevator_queue *, char *);
 3772| ssize_t (*store)(struct elevator_queue *, const char *, size_t);
 3773|};
 3774|
 3775|
 3776|
 3777|
 3778|struct elevator_type
 3779|{
 3780| struct list_head list;
 3781| struct elevator_ops ops;
 3782| struct elv_fs_entry *elevator_attrs;
 3783| char elevator_name[(16)];
 3784| struct module *elevator_owner;
 3785|};
 3786|
 3787|
 3788|
 3789|
 3790|struct elevator_queue
 3791|{
 3792| struct elevator_ops *ops;
 3793| void *elevator_data;
 3794| struct kobject kobj;
 3795| struct elevator_type *elevator_type;
 3796| struct mutex sysfs_lock;
 3797| struct hlist_head *hash;
 3798| unsigned int registered:1;
 3799|};
 3800|
 3801|
 3802|
 3803|
 3804|extern void elv_dispatch_sort(struct request_queue *, struct request *);
 3805|extern void elv_dispatch_add_tail(struct request_queue *, struct request *);
 3806|extern void elv_add_request(struct request_queue *, struct request *, int, int);
 3807|extern void __elv_add_request(struct request_queue *, struct request *, int, int);
 3808|extern void elv_insert(struct request_queue *, struct request *, int);
 3809|extern int elv_merge(struct request_queue *, struct request **, struct bio *);
 3810|extern void elv_merge_requests(struct request_queue *, struct request *,
 3811|          struct request *);
 3812|extern void elv_merged_request(struct request_queue *, struct request *, int);
 3813|extern void elv_bio_merged(struct request_queue *q, struct request *,
 3814|    struct bio *);
 3815|extern void elv_requeue_request(struct request_queue *, struct request *);
 3816|extern int elv_queue_empty(struct request_queue *);
 3817|extern struct request *elv_former_request(struct request_queue *, struct request *);
 3818|extern struct request *elv_latter_request(struct request_queue *, struct request *);
 3819|extern int elv_register_queue(struct request_queue *q);
 3820|extern void elv_unregister_queue(struct request_queue *q);
 3821|extern int elv_may_queue(struct request_queue *, int);
 3822|extern void elv_abort_queue(struct request_queue *);
 3823|extern void elv_completed_request(struct request_queue *, struct request *);
 3824|extern int elv_set_request(struct request_queue *, struct request *, gfp_t);
 3825|extern void elv_put_request(struct request_queue *, struct request *);
 3826|extern void elv_drain_elevator(struct request_queue *);
 3827|
 3828|
 3829|
 3830|
 3831|extern void elv_register(struct elevator_type *);
 3832|extern void elv_unregister(struct elevator_type *);
 3833|
 3834|
 3835|
 3836|
 3837|extern ssize_t elv_iosched_show(struct request_queue *, char *);
 3838|extern ssize_t elv_iosched_store(struct request_queue *, const char *, size_t);
 3839|
 3840|extern int elevator_init(struct request_queue *, char *);
 3841|extern void elevator_exit(struct elevator_queue *);
 3842|extern int elevator_change(struct request_queue *, const char *);
 3843|extern int elv_rq_merge_ok(struct request *, struct bio *);
 3844|
 3845|
 3846|
 3847|
 3848|extern struct request *elv_rb_former_request(struct request_queue *, struct request *);
 3849|extern struct request *elv_rb_latter_request(struct request_queue *, struct request *);
 3850|
 3851|
 3852|
 3853|
 3854|extern struct request *elv_rb_add(struct rb_root *, struct request *);
 3855|extern void elv_rb_del(struct rb_root *, struct request *);
 3856|extern struct request *elv_rb_find(struct rb_root *, sector_t);
 3857|enum {
 3858| ELV_MQUEUE_MAY,
 3859| ELV_MQUEUE_NO,
 3860| ELV_MQUEUE_MUST,
 3861|};
 3862|
 3863|typedef void (request_fn_proc) (struct request_queue *q);
 3864|typedef int (make_request_fn) (struct request_queue *q, struct bio *bio);
 3865|typedef int (prep_rq_fn) (struct request_queue *, struct request *);
 3866|typedef void (unprep_rq_fn) (struct request_queue *, struct request *);
 3867|typedef void (unplug_fn) (struct request_queue *);
 3868|
 3869|struct bio_vec;
 3870|struct bvec_merge_data {
 3871| struct block_device *bi_bdev;
 3872| sector_t bi_sector;
 3873| unsigned bi_size;
 3874| unsigned long bi_rw;
 3875|};
 3876|typedef int (merge_bvec_fn) (struct request_queue *, struct bvec_merge_data *,
 3877|        struct bio_vec *);
 3878|typedef void (softirq_done_fn)(struct request *);
 3879|typedef int (dma_drain_needed_fn)(struct request *);
 3880|typedef int (lld_busy_fn) (struct request_queue *q);
 3881|
 3882|enum blk_eh_timer_return {
 3883| BLK_EH_NOT_HANDLED,
 3884| BLK_EH_HANDLED,
 3885| BLK_EH_RESET_TIMER,
 3886|};
 3887|
 3888|typedef enum blk_eh_timer_return (rq_timed_out_fn)(struct request *);
 3889|
 3890|enum blk_queue_state {
 3891| Queue_down,
 3892| Queue_up,
 3893|};
 3894|
 3895|struct blk_queue_tag {
 3896| struct request **tag_index;
 3897| unsigned long *tag_map;
 3898| int busy;
 3899| int max_depth;
 3900| int real_max_depth;
 3901| atomic_t refcnt;
 3902|};
 3903|
 3904|
 3905|
 3906|
 3907|struct queue_limits {
 3908| unsigned long bounce_pfn;
 3909| unsigned long seg_boundary_mask;
 3910|
 3911| unsigned int max_hw_sectors;
 3912| unsigned int max_sectors;
 3913| unsigned int max_segment_size;
 3914| unsigned int physical_block_size;
 3915| unsigned int alignment_offset;
 3916| unsigned int io_min;
 3917| unsigned int io_opt;
 3918| unsigned int max_discard_sectors;
 3919| unsigned int discard_granularity;
 3920| unsigned int discard_alignment;
 3921|
 3922| unsigned short logical_block_size;
 3923| unsigned short max_segments;
 3924| unsigned short max_integrity_segments;
 3925|
 3926| unsigned char misaligned;
 3927| unsigned char discard_misaligned;
 3928| unsigned char no_cluster;
 3929| signed char discard_zeroes_data;
 3930|};
 3931|
 3932|struct request_queue
 3933|{
 3934|
 3935|
 3936|
 3937| struct list_head queue_head;
 3938| struct request *last_merge;
 3939| struct elevator_queue *elevator;
 3940|
 3941|
 3942|
 3943|
 3944| struct request_list rq;
 3945|
 3946| request_fn_proc *request_fn;
 3947| make_request_fn *make_request_fn;
 3948| prep_rq_fn *prep_rq_fn;
 3949| unprep_rq_fn *unprep_rq_fn;
 3950| unplug_fn *unplug_fn;
 3951| merge_bvec_fn *merge_bvec_fn;
 3952| softirq_done_fn *softirq_done_fn;
 3953| rq_timed_out_fn *rq_timed_out_fn;
 3954| dma_drain_needed_fn *dma_drain_needed;
 3955| lld_busy_fn *lld_busy_fn;
 3956|
 3957|
 3958|
 3959|
 3960| sector_t end_sector;
 3961| struct request *boundary_rq;
 3962|
 3963|
 3964|
 3965|
 3966| struct timer_list unplug_timer;
 3967| int unplug_thresh;
 3968| unsigned long unplug_delay;
 3969| struct work_struct unplug_work;
 3970|
 3971| struct backing_dev_info backing_dev_info;
 3972|
 3973|
 3974|
 3975|
 3976|
 3977| void *queuedata;
 3978|
 3979|
 3980|
 3981|
 3982| gfp_t bounce_gfp;
 3983|
 3984|
 3985|
 3986|
 3987| unsigned long queue_flags;
 3988|
 3989|
 3990|
 3991|
 3992|
 3993|
 3994| spinlock_t __queue_lock;
 3995| spinlock_t *queue_lock;
 3996|
 3997|
 3998|
 3999|
 4000| struct kobject kobj;
 4001|
 4002|
 4003|
 4004|
 4005| unsigned long nr_requests;
 4006| unsigned int nr_congestion_on;
 4007| unsigned int nr_congestion_off;
 4008| unsigned int nr_batching;
 4009|
 4010| void *dma_drain_buffer;
 4011| unsigned int dma_drain_size;
 4012| unsigned int dma_pad_mask;
 4013| unsigned int dma_alignment;
 4014|
 4015| struct blk_queue_tag *queue_tags;
 4016| struct list_head tag_busy_list;
 4017|
 4018| unsigned int nr_sorted;
 4019| unsigned int in_flight[2];
 4020|
 4021| unsigned int rq_timeout;
 4022| struct timer_list timeout;
 4023| struct list_head timeout_list;
 4024|
 4025| struct queue_limits limits;
 4026|
 4027|
 4028|
 4029|
 4030| unsigned int sg_timeout;
 4031| unsigned int sg_reserved_size;
 4032| int node;
 4033|
 4034| struct blk_trace *blk_trace;
 4035|
 4036|
 4037|
 4038|
 4039| unsigned int flush_flags;
 4040| unsigned int flush_seq;
 4041| int flush_err;
 4042| struct request flush_rq;
 4043| struct request *orig_flush_rq;
 4044| struct list_head pending_flushes;
 4045|
 4046| struct mutex sysfs_lock;
 4047|
 4048|
 4049| struct bsg_class_device bsg_dev;
 4050|
 4051|
 4052|
 4053|
 4054|
 4055|
 4056|};
 4057|static inline int queue_is_locked(struct request_queue *q)
 4058|{
 4059|
 4060| spinlock_t *lock = q->queue_lock;
 4061| return lock && spin_is_locked(lock);
 4062|
 4063|
 4064|
 4065|}
 4066|
 4067|static inline void queue_flag_set_unlocked(unsigned int flag,
 4068|        struct request_queue *q)
 4069|{
 4070| __set_bit(flag, &q->queue_flags);
 4071|}
 4072|
 4073|static inline int queue_flag_test_and_clear(unsigned int flag,
 4074|         struct request_queue *q)
 4075|{
 4076| ({ static bool __warned; int __ret_warn_once = !!(!queue_is_locked(q)); if (__builtin_expect(!!(__ret_warn_once), 0)) if (({ int __ret_warn_on = !!(!__warned); if (__builtin_expect(!!(__ret_warn_on), 0)) warn_slowpath_null("/home/l/latest/linux/include/linux/blkdev.h", 430); __builtin_expect(!!(__ret_warn_on), 0); })) __warned = true; __builtin_expect(!!(__ret_warn_once), 0); });
 4077|
 4078| if ((__builtin_constant_p((flag)) ? constant_test_bit((flag), (&q->queue_flags)) : variable_test_bit((flag), (&q->queue_flags)))) {
 4079|  __clear_bit(flag, &q->queue_flags);
 4080|  return 1;
 4081| }
 4082|
 4083| return 0;
 4084|}
 4085|
 4086|static inline int queue_flag_test_and_set(unsigned int flag,
 4087|       struct request_queue *q)
 4088|{
 4089| ({ static bool __warned; int __ret_warn_once = !!(!queue_is_locked(q)); if (__builtin_expect(!!(__ret_warn_once), 0)) if (({ int __ret_warn_on = !!(!__warned); if (__builtin_expect(!!(__ret_warn_on), 0)) warn_slowpath_null("/home/l/latest/linux/include/linux/blkdev.h", 443); __builtin_expect(!!(__ret_warn_on), 0); })) __warned = true; __builtin_expect(!!(__ret_warn_once), 0); });
 4090|
 4091| if (!(__builtin_constant_p((flag)) ? constant_test_bit((flag), (&q->queue_flags)) : variable_test_bit((flag), (&q->queue_flags)))) {
 4092|  __set_bit(flag, &q->queue_flags);
 4093|  return 0;
 4094| }
 4095|
 4096| return 1;
 4097|}
 4098|
 4099|static inline void queue_flag_set(unsigned int flag, struct request_queue *q)
 4100|{
 4101| ({ static bool __warned; int __ret_warn_once = !!(!queue_is_locked(q)); if (__builtin_expect(!!(__ret_warn_once), 0)) if (({ int __ret_warn_on = !!(!__warned); if (__builtin_expect(!!(__ret_warn_on), 0)) warn_slowpath_null("/home/l/latest/linux/include/linux/blkdev.h", 455); __builtin_expect(!!(__ret_warn_on), 0); })) __warned = true; __builtin_expect(!!(__ret_warn_once), 0); });
 4102| __set_bit(flag, &q->queue_flags);
 4103|}
 4104|
 4105|static inline void queue_flag_clear_unlocked(unsigned int flag,
 4106|          struct request_queue *q)
 4107|{
 4108| __clear_bit(flag, &q->queue_flags);
 4109|}
 4110|
 4111|static inline int queue_in_flight(struct request_queue *q)
 4112|{
 4113| return q->in_flight[0] + q->in_flight[1];
 4114|}
 4115|
 4116|static inline void queue_flag_clear(unsigned int flag, struct request_queue *q)
 4117|{
 4118| ({ static bool __warned; int __ret_warn_once = !!(!queue_is_locked(q)); if (__builtin_expect(!!(__ret_warn_once), 0)) if (({ int __ret_warn_on = !!(!__warned); if (__builtin_expect(!!(__ret_warn_on), 0)) warn_slowpath_null("/home/l/latest/linux/include/linux/blkdev.h", 472); __builtin_expect(!!(__ret_warn_on), 0); })) __warned = true; __builtin_expect(!!(__ret_warn_once), 0); });
 4119| __clear_bit(flag, &q->queue_flags);
 4120|}
 4121|static inline bool rw_is_sync(unsigned int rw_flags)
 4122|{
 4123| return !(rw_flags & (1 << __REQ_WRITE)) || (rw_flags & (1 << __REQ_SYNC));
 4124|}
 4125|
 4126|static inline bool rq_is_sync(struct request *rq)
 4127|{
 4128| return rw_is_sync(rq->cmd_flags);
 4129|}
 4130|
 4131|static inline int blk_queue_full(struct request_queue *q, int sync)
 4132|{
 4133| if (sync)
 4134|  return (__builtin_constant_p((3)) ? constant_test_bit((3), (&q->queue_flags)) : variable_test_bit((3), (&q->queue_flags)));
 4135| return (__builtin_constant_p((4)) ? constant_test_bit((4), (&q->queue_flags)) : variable_test_bit((4), (&q->queue_flags)));
 4136|}
 4137|
 4138|static inline void blk_set_queue_full(struct request_queue *q, int sync)
 4139|{
 4140| if (sync)
 4141|  queue_flag_set(3, q);
 4142| else
 4143|  queue_flag_set(4, q);
 4144|}
 4145|
 4146|static inline void blk_clear_queue_full(struct request_queue *q, int sync)
 4147|{
 4148| if (sync)
 4149|  queue_flag_clear(3, q);
 4150| else
 4151|  queue_flag_clear(4, q);
 4152|}
 4153|extern unsigned long blk_max_low_pfn, blk_max_pfn;
 4154|extern int init_emergency_isa_pool(void);
 4155|extern void blk_queue_bounce(struct request_queue *q, struct bio **bio);
 4156|struct rq_map_data {
 4157| struct page **pages;
 4158| int page_order;
 4159| int nr_entries;
 4160| unsigned long offset;
 4161| int null_mapped;
 4162| int from_user;
 4163|};
 4164|
 4165|struct req_iterator {
 4166| int i;
 4167| struct bio *bio;
 4168|};
 4169|static inline void rq_flush_dcache_pages(struct request *rq)
 4170|{
 4171|}
 4172|
 4173|
 4174|extern int blk_register_queue(struct gendisk *disk);
 4175|extern void blk_unregister_queue(struct gendisk *disk);
 4176|extern void register_disk(struct gendisk *dev);
 4177|extern void generic_make_request(struct bio *bio);
 4178|extern void blk_rq_init(struct request_queue *q, struct request *rq);
 4179|extern void blk_put_request(struct request *);
 4180|extern void __blk_put_request(struct request_queue *, struct request *);
 4181|extern struct request *blk_get_request(struct request_queue *, int, gfp_t);
 4182|extern struct request *blk_make_request(struct request_queue *, struct bio *,
 4183|     gfp_t);
 4184|extern void blk_insert_request(struct request_queue *, struct request *, int, void *);
 4185|extern void blk_requeue_request(struct request_queue *, struct request *);
 4186|extern void blk_add_request_payload(struct request *rq, struct page *page,
 4187|  unsigned int len);
 4188|extern int blk_rq_check_limits(struct request_queue *q, struct request *rq);
 4189|extern int blk_lld_busy(struct request_queue *q);
 4190|extern int blk_rq_prep_clone(struct request *rq, struct request *rq_src,
 4191|        struct bio_set *bs, gfp_t gfp_mask,
 4192|        int (*bio_ctr)(struct bio *, struct bio *, void *),
 4193|        void *data);
 4194|extern void blk_rq_unprep_clone(struct request *rq);
 4195|extern int blk_insert_cloned_request(struct request_queue *q,
 4196|         struct request *rq);
 4197|extern void blk_plug_device(struct request_queue *);
 4198|extern void blk_plug_device_unlocked(struct request_queue *);
 4199|extern int blk_remove_plug(struct request_queue *);
 4200|extern void blk_recount_segments(struct request_queue *, struct bio *);
 4201|extern int scsi_cmd_ioctl(struct request_queue *, struct gendisk *, fmode_t,
 4202|     unsigned int, void *);
 4203|extern int sg_scsi_ioctl(struct request_queue *, struct gendisk *, fmode_t,
 4204|    struct scsi_ioctl_command *);
 4205|
 4206|
 4207|
 4208|
 4209|
 4210|
 4211|static inline void blk_clear_queue_congested(struct request_queue *q, int sync)
 4212|{
 4213| clear_bdi_congested(&q->backing_dev_info, sync);
 4214|}
 4215|
 4216|
 4217|
 4218|
 4219|
 4220|static inline void blk_set_queue_congested(struct request_queue *q, int sync)
 4221|{
 4222| set_bdi_congested(&q->backing_dev_info, sync);
 4223|}
 4224|
 4225|extern void blk_start_queue(struct request_queue *q);
 4226|extern void blk_stop_queue(struct request_queue *q);
 4227|extern void blk_sync_queue(struct request_queue *q);
 4228|extern void __blk_stop_queue(struct request_queue *q);
 4229|extern void __blk_run_queue(struct request_queue *);
 4230|extern void blk_run_queue(struct request_queue *);
 4231|extern int blk_rq_map_user(struct request_queue *, struct request *,
 4232|      struct rq_map_data *, void *, unsigned long,
 4233|      gfp_t);
 4234|extern int blk_rq_unmap_user(struct bio *);
 4235|extern int blk_rq_map_kern(struct request_queue *, struct request *, void *, unsigned int, gfp_t);
 4236|extern int blk_rq_map_user_iov(struct request_queue *, struct request *,
 4237|          struct rq_map_data *, struct sg_iovec *, int,
 4238|          unsigned int, gfp_t);
 4239|extern int blk_execute_rq(struct request_queue *, struct gendisk *,
 4240|     struct request *, int);
 4241|extern void blk_execute_rq_nowait(struct request_queue *, struct gendisk *,
 4242|      struct request *, int, rq_end_io_fn *);
 4243|extern void blk_unplug(struct request_queue *q);
 4244|
 4245|static inline struct request_queue *bdev_get_queue(struct block_device *bdev)
 4246|{
 4247| return bdev->bd_disk->queue;
 4248|}
 4249|static inline sector_t blk_rq_pos(const struct request *rq)
 4250|{
 4251| return rq->__sector;
 4252|}
 4253|
 4254|static inline unsigned int blk_rq_bytes(const struct request *rq)
 4255|{
 4256| return rq->__data_len;
 4257|}
 4258|
 4259|static inline int blk_rq_cur_bytes(const struct request *rq)
 4260|{
 4261| return rq->bio ? bio_cur_bytes(rq->bio) : 0;
 4262|}
 4263|
 4264|extern unsigned int blk_rq_err_bytes(const struct request *rq);
 4265|
 4266|static inline unsigned int blk_rq_sectors(const struct request *rq)
 4267|{
 4268| return blk_rq_bytes(rq) >> 9;
 4269|}
 4270|
 4271|static inline unsigned int blk_rq_cur_sectors(const struct request *rq)
 4272|{
 4273| return blk_rq_cur_bytes(rq) >> 9;
 4274|}
 4275|
 4276|
 4277|
 4278|
 4279|extern struct request *blk_peek_request(struct request_queue *q);
 4280|extern void blk_start_request(struct request *rq);
 4281|extern struct request *blk_fetch_request(struct request_queue *q);
 4282|extern bool blk_update_request(struct request *rq, int error,
 4283|          unsigned int nr_bytes);
 4284|extern bool blk_end_request(struct request *rq, int error,
 4285|       unsigned int nr_bytes);
 4286|extern void blk_end_request_all(struct request *rq, int error);
 4287|extern bool blk_end_request_cur(struct request *rq, int error);
 4288|extern bool blk_end_request_err(struct request *rq, int error);
 4289|extern bool __blk_end_request(struct request *rq, int error,
 4290|         unsigned int nr_bytes);
 4291|extern void __blk_end_request_all(struct request *rq, int error);
 4292|extern bool __blk_end_request_cur(struct request *rq, int error);
 4293|extern bool __blk_end_request_err(struct request *rq, int error);
 4294|
 4295|extern void blk_complete_request(struct request *);
 4296|extern void __blk_complete_request(struct request *);
 4297|extern void blk_abort_request(struct request *);
 4298|extern void blk_abort_queue(struct request_queue *);
 4299|extern void blk_unprep_request(struct request *);
 4300|
 4301|
 4302|
 4303|
 4304|extern struct request_queue *blk_init_queue_node(request_fn_proc *rfn,
 4305|     spinlock_t *lock, int node_id);
 4306|extern struct request_queue *blk_init_allocated_queue_node(struct request_queue *,
 4307|          request_fn_proc *,
 4308|          spinlock_t *, int node_id);
 4309|extern struct request_queue *blk_init_queue(request_fn_proc *, spinlock_t *);
 4310|extern struct request_queue *blk_init_allocated_queue(struct request_queue *,
 4311|            request_fn_proc *, spinlock_t *);
 4312|extern void blk_cleanup_queue(struct request_queue *);
 4313|extern void blk_queue_make_request(struct request_queue *, make_request_fn *);
 4314|extern void blk_queue_bounce_limit(struct request_queue *, u64);
 4315|extern void blk_queue_max_hw_sectors(struct request_queue *, unsigned int);
 4316|extern void blk_queue_max_segments(struct request_queue *, unsigned short);
 4317|extern void blk_queue_max_segment_size(struct request_queue *, unsigned int);
 4318|extern void blk_queue_max_discard_sectors(struct request_queue *q,
 4319|  unsigned int max_discard_sectors);
 4320|extern void blk_queue_logical_block_size(struct request_queue *, unsigned short);
 4321|extern void blk_queue_physical_block_size(struct request_queue *, unsigned int);
 4322|extern void blk_queue_alignment_offset(struct request_queue *q,
 4323|           unsigned int alignment);
 4324|extern void blk_limits_io_min(struct queue_limits *limits, unsigned int min);
 4325|extern void blk_queue_io_min(struct request_queue *q, unsigned int min);
 4326|extern void blk_limits_io_opt(struct queue_limits *limits, unsigned int opt);
 4327|extern void blk_queue_io_opt(struct request_queue *q, unsigned int opt);
 4328|extern void blk_set_default_limits(struct queue_limits *lim);
 4329|extern int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
 4330|       sector_t offset);
 4331|extern int bdev_stack_limits(struct queue_limits *t, struct block_device *bdev,
 4332|       sector_t offset);
 4333|extern void disk_stack_limits(struct gendisk *disk, struct block_device *bdev,
 4334|         sector_t offset);
 4335|extern void blk_queue_stack_limits(struct request_queue *t, struct request_queue *b);
 4336|extern void blk_queue_dma_pad(struct request_queue *, unsigned int);
 4337|extern void blk_queue_update_dma_pad(struct request_queue *, unsigned int);
 4338|extern int blk_queue_dma_drain(struct request_queue *q,
 4339|          dma_drain_needed_fn *dma_drain_needed,
 4340|          void *buf, unsigned int size);
 4341|extern void blk_queue_lld_busy(struct request_queue *q, lld_busy_fn *fn);
 4342|extern void blk_queue_segment_boundary(struct request_queue *, unsigned long);
 4343|extern void blk_queue_prep_rq(struct request_queue *, prep_rq_fn *pfn);
 4344|extern void blk_queue_unprep_rq(struct request_queue *, unprep_rq_fn *ufn);
 4345|extern void blk_queue_merge_bvec(struct request_queue *, merge_bvec_fn *);
 4346|extern void blk_queue_dma_alignment(struct request_queue *, int);
 4347|extern void blk_queue_update_dma_alignment(struct request_queue *, int);
 4348|extern void blk_queue_softirq_done(struct request_queue *, softirq_done_fn *);
 4349|extern void blk_queue_rq_timed_out(struct request_queue *, rq_timed_out_fn *);
 4350|extern void blk_queue_rq_timeout(struct request_queue *, unsigned int);
 4351|extern void blk_queue_flush(struct request_queue *q, unsigned int flush);
 4352|extern struct backing_dev_info *blk_get_backing_dev_info(struct block_device *bdev);
 4353|
 4354|extern int blk_rq_map_sg(struct request_queue *, struct request *, struct scatterlist *);
 4355|extern void blk_dump_rq_flags(struct request *, char *);
 4356|extern void generic_unplug_device(struct request_queue *);
 4357|extern long nr_blockdev_pages(void);
 4358|
 4359|int blk_get_queue(struct request_queue *);
 4360|struct request_queue *blk_alloc_queue(gfp_t);
 4361|struct request_queue *blk_alloc_queue_node(gfp_t, int);
 4362|extern void blk_put_queue(struct request_queue *);
 4363|
 4364|
 4365|
 4366|
 4367|
 4368|extern int blk_queue_start_tag(struct request_queue *, struct request *);
 4369|extern struct request *blk_queue_find_tag(struct request_queue *, int);
 4370|extern void blk_queue_end_tag(struct request_queue *, struct request *);
 4371|extern int blk_queue_init_tags(struct request_queue *, int, struct blk_queue_tag *);
 4372|extern void blk_queue_free_tags(struct request_queue *);
 4373|extern int blk_queue_resize_tags(struct request_queue *, int);
 4374|extern void blk_queue_invalidate_tags(struct request_queue *);
 4375|extern struct blk_queue_tag *blk_init_tags(int);
 4376|extern void blk_free_tags(struct blk_queue_tag *);
 4377|
 4378|static inline struct request *blk_map_queue_find_tag(struct blk_queue_tag *bqt,
 4379|      int tag)
 4380|{
 4381| if (__builtin_expect(!!(bqt == ((void *)0) || tag >= bqt->real_max_depth), 0))
 4382|  return ((void *)0);
 4383| return bqt->tag_index[tag];
 4384|}
 4385|
 4386|
 4387|
 4388|extern int blkdev_issue_flush(struct block_device *, gfp_t, sector_t *);
 4389|extern int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
 4390|  sector_t nr_sects, gfp_t gfp_mask, unsigned long flags);
 4391|extern int blkdev_issue_zeroout(struct block_device *bdev, sector_t sector,
 4392|   sector_t nr_sects, gfp_t gfp_mask);
 4393|static inline int sb_issue_discard(struct super_block *sb, sector_t block,
 4394|  sector_t nr_blocks, gfp_t gfp_mask, unsigned long flags)
 4395|{
 4396| return blkdev_issue_discard(sb->s_bdev, block << (sb->s_blocksize_bits - 9),
 4397|        nr_blocks << (sb->s_blocksize_bits - 9),
 4398|        gfp_mask, flags);
 4399|}
 4400|static inline int sb_issue_zeroout(struct super_block *sb, sector_t block,
 4401|  sector_t nr_blocks, gfp_t gfp_mask)
 4402|{
 4403| return blkdev_issue_zeroout(sb->s_bdev,
 4404|        block << (sb->s_blocksize_bits - 9),
 4405|        nr_blocks << (sb->s_blocksize_bits - 9),
 4406|        gfp_mask);
 4407|}
 4408|
 4409|extern int blk_verify_command(unsigned char *cmd, fmode_t has_write_perm);
 4410|
 4411|enum blk_default_limits {
 4412| BLK_MAX_SEGMENTS = 128,
 4413| BLK_SAFE_MAX_SECTORS = 255,
 4414| BLK_DEF_MAX_SECTORS = 1024,
 4415| BLK_MAX_SEGMENT_SIZE = 65536,
 4416| BLK_SEG_BOUNDARY_MASK = 0xFFFFFFFFUL,
 4417|};
 4418|
 4419|
 4420|
 4421|static inline unsigned long queue_bounce_pfn(struct request_queue *q)
 4422|{
 4423| return q->limits.bounce_pfn;
 4424|}
 4425|
 4426|static inline unsigned long queue_segment_boundary(struct request_queue *q)
 4427|{
 4428| return q->limits.seg_boundary_mask;
 4429|}
 4430|
 4431|static inline unsigned int queue_max_sectors(struct request_queue *q)
 4432|{
 4433| return q->limits.max_sectors;
 4434|}
 4435|
 4436|static inline unsigned int queue_max_hw_sectors(struct request_queue *q)
 4437|{
 4438| return q->limits.max_hw_sectors;
 4439|}
 4440|
 4441|static inline unsigned short queue_max_segments(struct request_queue *q)
 4442|{
 4443| return q->limits.max_segments;
 4444|}
 4445|
 4446|static inline unsigned int queue_max_segment_size(struct request_queue *q)
 4447|{
 4448| return q->limits.max_segment_size;
 4449|}
 4450|
 4451|static inline unsigned short queue_logical_block_size(struct request_queue *q)
 4452|{
 4453| int retval = 512;
 4454|
 4455| if (q && q->limits.logical_block_size)
 4456|  retval = q->limits.logical_block_size;
 4457|
 4458| return retval;
 4459|}
 4460|
 4461|static inline unsigned short bdev_logical_block_size(struct block_device *bdev)
 4462|{
 4463| return queue_logical_block_size(bdev_get_queue(bdev));
 4464|}
 4465|
 4466|static inline unsigned int queue_physical_block_size(struct request_queue *q)
 4467|{
 4468| return q->limits.physical_block_size;
 4469|}
 4470|
 4471|static inline unsigned int bdev_physical_block_size(struct block_device *bdev)
 4472|{
 4473| return queue_physical_block_size(bdev_get_queue(bdev));
 4474|}
 4475|
 4476|static inline unsigned int queue_io_min(struct request_queue *q)
 4477|{
 4478| return q->limits.io_min;
 4479|}
 4480|
 4481|static inline int bdev_io_min(struct block_device *bdev)
 4482|{
 4483| return queue_io_min(bdev_get_queue(bdev));
 4484|}
 4485|
 4486|static inline unsigned int queue_io_opt(struct request_queue *q)
 4487|{
 4488| return q->limits.io_opt;
 4489|}
 4490|
 4491|static inline int bdev_io_opt(struct block_device *bdev)
 4492|{
 4493| return queue_io_opt(bdev_get_queue(bdev));
 4494|}
 4495|
 4496|static inline int queue_alignment_offset(struct request_queue *q)
 4497|{
 4498| if (q->limits.misaligned)
 4499|  return -1;
 4500|
 4501| return q->limits.alignment_offset;
 4502|}
 4503|
 4504|static inline int queue_limit_alignment_offset(struct queue_limits *lim, sector_t sector)
 4505|{
 4506| unsigned int granularity = ({ typeof(lim->physical_block_size) _max1 = (lim->physical_block_size); typeof(lim->io_min) _max2 = (lim->io_min); (void) (&_max1 == &_max2); _max1 > _max2 ? _max1 : _max2; });
 4507| unsigned int alignment = (sector << 9) & (granularity - 1);
 4508|
 4509| return (granularity + lim->alignment_offset - alignment)
 4510|  & (granularity - 1);
 4511|}
 4512|
 4513|static inline int bdev_alignment_offset(struct block_device *bdev)
 4514|{
 4515| struct request_queue *q = bdev_get_queue(bdev);
 4516|
 4517| if (q->limits.misaligned)
 4518|  return -1;
 4519|
 4520| if (bdev != bdev->bd_contains)
 4521|  return bdev->bd_part->alignment_offset;
 4522|
 4523| return q->limits.alignment_offset;
 4524|}
 4525|
 4526|static inline int queue_discard_alignment(struct request_queue *q)
 4527|{
 4528| if (q->limits.discard_misaligned)
 4529|  return -1;
 4530|
 4531| return q->limits.discard_alignment;
 4532|}
 4533|
 4534|static inline int queue_limit_discard_alignment(struct queue_limits *lim, sector_t sector)
 4535|{
 4536| unsigned int alignment = (sector << 9) & (lim->discard_granularity - 1);
 4537|
 4538| return (lim->discard_granularity + lim->discard_alignment - alignment)
 4539|  & (lim->discard_granularity - 1);
 4540|}
 4541|
 4542|static inline unsigned int queue_discard_zeroes_data(struct request_queue *q)
 4543|{
 4544| if (q->limits.discard_zeroes_data == 1)
 4545|  return 1;
 4546|
 4547| return 0;
 4548|}
 4549|
 4550|static inline unsigned int bdev_discard_zeroes_data(struct block_device *bdev)
 4551|{
 4552| return queue_discard_zeroes_data(bdev_get_queue(bdev));
 4553|}
 4554|
 4555|static inline int queue_dma_alignment(struct request_queue *q)
 4556|{
 4557| return q ? q->dma_alignment : 511;
 4558|}
 4559|
 4560|static inline int blk_rq_aligned(struct request_queue *q, unsigned long addr,
 4561|     unsigned int len)
 4562|{
 4563| unsigned int alignment = queue_dma_alignment(q) | q->dma_pad_mask;
 4564| return !(addr & alignment) && !(len & alignment);
 4565|}
 4566|
 4567|
 4568|static inline unsigned int blksize_bits(unsigned int size)
 4569|{
 4570| unsigned int bits = 8;
 4571| do {
 4572|  bits++;
 4573|  size >>= 1;
 4574| } while (size > 256);
 4575| return bits;
 4576|}
 4577|
 4578|static inline unsigned int block_size(struct block_device *bdev)
 4579|{
 4580| return bdev->bd_block_size;
 4581|}
 4582|
 4583|typedef struct {struct page *v;} Sector;
 4584|
 4585|unsigned char *read_dev_sector(struct block_device *, sector_t, Sector *);
 4586|
 4587|static inline void put_dev_sector(Sector p)
 4588|{
 4589| put_page(p.v);
 4590|}
 4591|
 4592|struct work_struct;
 4593|int kblockd_schedule_work(struct request_queue *q, struct work_struct *work);
 4594|int kblockd_schedule_delayed_work(struct request_queue *q, struct delayed_work *dwork, unsigned long delay);
 4595|static inline void set_start_time_ns(struct request *req) {}
 4596|static inline void set_io_start_time_ns(struct request *req) {}
 4597|static inline uint64_t rq_start_time_ns(struct request *req)
 4598|{
 4599| return 0;
 4600|}
 4601|static inline uint64_t rq_io_start_time_ns(struct request *req)
 4602|{
 4603| return 0;
 4604|}
 4605|static inline int blk_throtl_bio(struct request_queue *q, struct bio **bio)
 4606|{
 4607| return 0;
 4608|}
 4609|
 4610|static inline int blk_throtl_init(struct request_queue *q) { return 0; }
 4611|static inline int blk_throtl_exit(struct request_queue *q) { return 0; }
 4612|static inline void throtl_schedule_delayed_work(struct request_queue *q, unsigned long delay) {}
 4613|static inline void throtl_shutdown_timer_wq(struct request_queue *q) {}
 4614|struct blk_integrity_exchg {
 4615| void *prot_buf;
 4616| void *data_buf;
 4617| sector_t sector;
 4618| unsigned int data_size;
 4619| unsigned short sector_size;
 4620| const char *disk_name;
 4621|};
 4622|
 4623|typedef void (integrity_gen_fn) (struct blk_integrity_exchg *);
 4624|typedef int (integrity_vrfy_fn) (struct blk_integrity_exchg *);
 4625|typedef void (integrity_set_tag_fn) (void *, void *, unsigned int);
 4626|typedef void (integrity_get_tag_fn) (void *, void *, unsigned int);
 4627|
 4628|struct blk_integrity {
 4629| integrity_gen_fn *generate_fn;
 4630| integrity_vrfy_fn *verify_fn;
 4631| integrity_set_tag_fn *set_tag_fn;
 4632| integrity_get_tag_fn *get_tag_fn;
 4633|
 4634| unsigned short flags;
 4635| unsigned short tuple_size;
 4636| unsigned short sector_size;
 4637| unsigned short tag_size;
 4638|
 4639| const char *name;
 4640|
 4641| struct kobject kobj;
 4642|};
 4643|
 4644|extern int blk_integrity_register(struct gendisk *, struct blk_integrity *);
 4645|extern void blk_integrity_unregister(struct gendisk *);
 4646|extern int blk_integrity_compare(struct gendisk *, struct gendisk *);
 4647|extern int blk_rq_map_integrity_sg(struct request_queue *, struct bio *,
 4648|       struct scatterlist *);
 4649|extern int blk_rq_count_integrity_sg(struct request_queue *, struct bio *);
 4650|extern int blk_integrity_merge_rq(struct request_queue *, struct request *,
 4651|      struct request *);
 4652|extern int blk_integrity_merge_bio(struct request_queue *, struct request *,
 4653|       struct bio *);
 4654|
 4655|static inline
 4656|struct blk_integrity *bdev_get_integrity(struct block_device *bdev)
 4657|{
 4658| return bdev->bd_disk->integrity;
 4659|}
 4660|
 4661|static inline struct blk_integrity *blk_get_integrity(struct gendisk *disk)
 4662|{
 4663| return disk->integrity;
 4664|}
 4665|
 4666|static inline int blk_integrity_rq(struct request *rq)
 4667|{
 4668| if (rq->bio == ((void *)0))
 4669|  return 0;
 4670|
 4671| return (rq->bio->bi_integrity != ((void *)0));
 4672|}
 4673|
 4674|static inline void blk_queue_max_integrity_segments(struct request_queue *q,
 4675|          unsigned int segs)
 4676|{
 4677| q->limits.max_integrity_segments = segs;
 4678|}
 4679|
 4680|static inline unsigned short
 4681|queue_max_integrity_segments(struct request_queue *q)
 4682|{
 4683| return q->limits.max_integrity_segments;
 4684|}
 4685|struct block_device_operations {
 4686| int (*open) (struct block_device *, fmode_t);
 4687| int (*release) (struct gendisk *, fmode_t);
 4688| int (*ioctl) (struct block_device *, fmode_t, unsigned, unsigned long);
 4689| int (*compat_ioctl) (struct block_device *, fmode_t, unsigned, unsigned long);
 4690| int (*direct_access) (struct block_device *, sector_t,
 4691|      void **, unsigned long *);
 4692| int (*media_changed) (struct gendisk *);
 4693| void (*unlock_native_capacity) (struct gendisk *);
 4694| int (*revalidate_disk) (struct gendisk *);
 4695| int (*getgeo)(struct block_device *, struct hd_geometry *);
 4696|
 4697| void (*swap_slot_free_notify) (struct block_device *, unsigned long);
 4698| struct module *owner;
 4699|};
 4700|
 4701|extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
 4702|     unsigned long);
 4703|struct fsnotify_group;
 4704|struct fsnotify_event;
 4705|struct fsnotify_mark;
 4706|struct fsnotify_event_private_data;
 4707|struct fsnotify_ops {
 4708| bool (*should_send_event)(struct fsnotify_group *group, struct inode *inode,
 4709|      struct fsnotify_mark *inode_mark,
 4710|      struct fsnotify_mark *vfsmount_mark,
 4711|      __u32 mask, void *data, int data_type);
 4712| int (*handle_event)(struct fsnotify_group *group,
 4713|       struct fsnotify_mark *inode_mark,
 4714|       struct fsnotify_mark *vfsmount_mark,
 4715|       struct fsnotify_event *event);
 4716| void (*free_group_priv)(struct fsnotify_group *group);
 4717| void (*freeing_mark)(struct fsnotify_mark *mark, struct fsnotify_group *group);
 4718| void (*free_event_priv)(struct fsnotify_event_private_data *priv);
 4719|};
 4720|
 4721|
 4722|
 4723|
 4724|
 4725|
 4726|
 4727|struct fsnotify_group {
 4728| atomic_t refcnt;
 4729|
 4730| const struct fsnotify_ops *ops;
 4731|
 4732|
 4733| struct mutex notification_mutex;
 4734| struct list_head notification_list;
 4735| wait_queue_head_t notification_waitq;
 4736| unsigned int q_len;
 4737| unsigned int max_events;
 4738|
 4739|
 4740|
 4741|
 4742|
 4743|
 4744|
 4745| unsigned int priority;
 4746|
 4747|
 4748| spinlock_t mark_lock;
 4749| atomic_t num_marks;
 4750|
 4751|
 4752| struct list_head marks_list;
 4753|
 4754|
 4755| union {
 4756|  void *private;
 4757|
 4758|  struct inotify_group_private_data {
 4759|   spinlock_t idr_lock;
 4760|   struct idr idr;
 4761|   u32 last_wd;
 4762|   struct fasync_struct *fa;
 4763|   struct user_struct *user;
 4764|  } inotify_data;
 4765|
 4766|
 4767|  struct fanotify_group_private_data {
 4768|
 4769|
 4770|   struct mutex access_mutex;
 4771|   struct list_head access_list;
 4772|   wait_queue_head_t access_waitq;
 4773|   bool bypass_perm;
 4774|
 4775|   bool readonly_fallback;
 4776|   int f_flags;
 4777|   unsigned int max_marks;
 4778|   struct user_struct *user;
 4779|  } fanotify_data;
 4780|
 4781| };
 4782|};
 4783|struct fsnotify_event_holder {
 4784| struct fsnotify_event *event;
 4785| struct list_head event_list;
 4786|};
 4787|
 4788|
 4789|
 4790|
 4791|
 4792|struct fsnotify_event_private_data {
 4793| struct fsnotify_group *group;
 4794| struct list_head event_list;
 4795|};
 4796|
 4797|
 4798|
 4799|
 4800|
 4801|
 4802|struct fsnotify_event {
 4803|
 4804|
 4805|
 4806|
 4807|
 4808| struct fsnotify_event_holder holder;
 4809| spinlock_t lock;
 4810|
 4811| struct inode *to_tell;
 4812| union {
 4813|  struct path path;
 4814|  struct inode *inode;
 4815| };
 4816|
 4817|
 4818|
 4819|
 4820| int data_type;
 4821| atomic_t refcnt;
 4822| __u32 mask;
 4823|
 4824| u32 sync_cookie;
 4825| const unsigned char *file_name;
 4826| size_t name_len;
 4827| struct pid *tgid;
 4828|
 4829|
 4830| __u32 response;
 4831|
 4832|
 4833| struct list_head private_data_list;
 4834|};
 4835|
 4836|
 4837|
 4838|
 4839|struct fsnotify_inode_mark {
 4840| struct inode *inode;
 4841| struct hlist_node i_list;
 4842| struct list_head free_i_list;
 4843|};
 4844|
 4845|
 4846|
 4847|
 4848|struct fsnotify_vfsmount_mark {
 4849| struct vfsmount *mnt;
 4850| struct hlist_node m_list;
 4851| struct list_head free_m_list;
 4852|};
 4853|struct fsnotify_mark {
 4854| __u32 mask;
 4855|
 4856|
 4857| atomic_t refcnt;
 4858| struct fsnotify_group *group;
 4859| struct list_head g_list;
 4860| spinlock_t lock;
 4861| union {
 4862|  struct fsnotify_inode_mark i;
 4863|  struct fsnotify_vfsmount_mark m;
 4864| };
 4865| struct list_head free_g_list;
 4866| __u32 ignored_mask;
 4867|
 4868|
 4869|
 4870|
 4871|
 4872| unsigned int flags;
 4873| struct list_head destroy_list;
 4874| void (*free_mark)(struct fsnotify_mark *mark);
 4875|};
 4876|
 4877|
 4878|
 4879|
 4880|
 4881|
 4882|extern int fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is,
 4883|      const unsigned char *name, u32 cookie);
 4884|extern int __fsnotify_parent(struct path *path, struct dentry *dentry, __u32 mask);
 4885|extern void __fsnotify_inode_delete(struct inode *inode);
 4886|extern void __fsnotify_vfsmount_delete(struct vfsmount *mnt);
 4887|extern u32 fsnotify_get_cookie(void);
 4888|
 4889|static inline int fsnotify_inode_watches_children(struct inode *inode)
 4890|{
 4891|
 4892| if (!(inode->i_fsnotify_mask & 0x08000000))
 4893|  return 0;
 4894|
 4895|
 4896| return inode->i_fsnotify_mask & (0x00000001 | 0x00000002 | 0x00000004 | 0x00000008 | 0x00000010 | 0x00000020 | 0x00000040 | 0x00000080 | 0x00000100 | 0x00000200);
 4897|}
 4898|
 4899|
 4900|
 4901|
 4902|
 4903|static inline void __fsnotify_update_dcache_flags(struct dentry *dentry)
 4904|{
 4905| struct dentry *parent;
 4906|
 4907| assert_spin_locked(&dcache_lock);
 4908| assert_spin_locked(&dentry->d_lock);
 4909|
 4910| parent = dentry->d_parent;
 4911| if (parent->d_inode && fsnotify_inode_watches_children(parent->d_inode))
 4912|  dentry->d_flags |= 0x0080;
 4913| else
 4914|  dentry->d_flags &= ~0x0080;
 4915|}
 4916|
 4917|
 4918|
 4919|
 4920|
 4921|static inline void __fsnotify_d_instantiate(struct dentry *dentry, struct inode *inode)
 4922|{
 4923| if (!inode)
 4924|  return;
 4925|
 4926| assert_spin_locked(&dcache_lock);
 4927|
 4928| spin_lock(&dentry->d_lock);
 4929| __fsnotify_update_dcache_flags(dentry);
 4930| spin_unlock(&dentry->d_lock);
 4931|}
 4932|
 4933|
 4934|
 4935|
 4936|extern struct fsnotify_group *fsnotify_alloc_group(const struct fsnotify_ops *ops);
 4937|
 4938|extern void fsnotify_put_group(struct fsnotify_group *group);
 4939|
 4940|
 4941|extern void fsnotify_get_event(struct fsnotify_event *event);
 4942|extern void fsnotify_put_event(struct fsnotify_event *event);
 4943|
 4944|extern struct fsnotify_event_private_data *fsnotify_remove_priv_from_event(struct fsnotify_group *group,
 4945|            struct fsnotify_event *event);
 4946|
 4947|
 4948|extern struct fsnotify_event *fsnotify_add_notify_event(struct fsnotify_group *group,
 4949|       struct fsnotify_event *event,
 4950|       struct fsnotify_event_private_data *priv,
 4951|       struct fsnotify_event *(*merge)(struct list_head *,
 4952|           struct fsnotify_event *));
 4953|
 4954|extern bool fsnotify_notify_queue_is_empty(struct fsnotify_group *group);
 4955|
 4956|extern struct fsnotify_event *fsnotify_peek_notify_event(struct fsnotify_group *group);
 4957|
 4958|extern struct fsnotify_event *fsnotify_remove_notify_event(struct fsnotify_group *group);
 4959|
 4960|
 4961|
 4962|
 4963|extern void fsnotify_recalc_vfsmount_mask(struct vfsmount *mnt);
 4964|
 4965|extern void fsnotify_recalc_inode_mask(struct inode *inode);
 4966|extern void fsnotify_init_mark(struct fsnotify_mark *mark, void (*free_mark)(struct fsnotify_mark *mark));
 4967|
 4968|extern struct fsnotify_mark *fsnotify_find_inode_mark(struct fsnotify_group *group, struct inode *inode);
 4969|
 4970|extern struct fsnotify_mark *fsnotify_find_vfsmount_mark(struct fsnotify_group *group, struct vfsmount *mnt);
 4971|
 4972|extern void fsnotify_duplicate_mark(struct fsnotify_mark *new, struct fsnotify_mark *old);
 4973|
 4974|extern void fsnotify_set_mark_ignored_mask_locked(struct fsnotify_mark *mark, __u32 mask);
 4975|
 4976|extern void fsnotify_set_mark_mask_locked(struct fsnotify_mark *mark, __u32 mask);
 4977|
 4978|extern int fsnotify_add_mark(struct fsnotify_mark *mark, struct fsnotify_group *group,
 4979|        struct inode *inode, struct vfsmount *mnt, int allow_dups);
 4980|
 4981|extern void fsnotify_destroy_mark(struct fsnotify_mark *mark);
 4982|
 4983|extern void fsnotify_clear_vfsmount_marks_by_group(struct fsnotify_group *group);
 4984|
 4985|extern void fsnotify_clear_inode_marks_by_group(struct fsnotify_group *group);
 4986|
 4987|extern void fsnotify_clear_marks_by_group_flags(struct fsnotify_group *group, unsigned int flags);
 4988|
 4989|extern void fsnotify_clear_marks_by_group(struct fsnotify_group *group);
 4990|extern void fsnotify_unmount_inodes(struct list_head *list);
 4991|
 4992|
 4993|extern struct fsnotify_event *fsnotify_create_event(struct inode *to_tell, __u32 mask,
 4994|          void *data, int data_is,
 4995|          const unsigned char *name,
 4996|          u32 cookie, gfp_t gfp);
 4997|
 4998|
 4999|extern struct fsnotify_event *fsnotify_clone_event(struct fsnotify_event *old_event);
 5000|extern int fsnotify_replace_event(struct fsnotify_event_holder *old_holder,
 5001|      struct fsnotify_event *new_event);
 5002|
 5003|static inline void fsnotify_get_mark(struct fsnotify_mark *mark)
 5004|{
 5005| atomic_inc(&mark->refcnt);
 5006|}
 5007|
 5008|static inline void fsnotify_put_mark(struct fsnotify_mark *mark)
 5009|{
 5010| if (atomic_dec_and_test(&mark->refcnt))
 5011|  mark->free_mark(mark);
 5012|}
 5013|enum {
 5014| Audit_equal,
 5015| Audit_not_equal,
 5016| Audit_bitmask,
 5017| Audit_bittest,
 5018| Audit_lt,
 5019| Audit_gt,
 5020| Audit_le,
 5021| Audit_ge,
 5022| Audit_bad
 5023|};
 5024|struct audit_status {
 5025| __u32 mask;
 5026| __u32 enabled;
 5027| __u32 failure;
 5028| __u32 pid;
 5029| __u32 rate_limit;
 5030| __u32 backlog_limit;
 5031| __u32 lost;
 5032| __u32 backlog;
 5033|};
 5034|
 5035|struct audit_tty_status {
 5036| __u32 enabled;
 5037|};
 5038|
 5039|
 5040|
 5041|
 5042|
 5043|struct audit_rule_data {
 5044| __u32 flags;
 5045| __u32 action;
 5046| __u32 field_count;
 5047| __u32 mask[64];
 5048| __u32 fields[64];
 5049| __u32 values[64];
 5050| __u32 fieldflags[64];
 5051| __u32 buflen;
 5052| char buf[0];
 5053|};
 5054|
 5055|
 5056|
 5057|
 5058|
 5059|struct audit_rule {
 5060| __u32 flags;
 5061| __u32 action;
 5062| __u32 field_count;
 5063| __u32 mask[64];
 5064| __u32 fields[64];
 5065| __u32 values[64];
 5066|};
 5067|
 5068|
 5069|
 5070|
 5071|struct audit_sig_info {
 5072| uid_t uid;
 5073| pid_t pid;
 5074| char ctx[0];
 5075|};
 5076|
 5077|struct audit_buffer;
 5078|struct audit_context;
 5079|struct inode;
 5080|struct netlink_skb_parms;
 5081|struct linux_binprm;
 5082|struct mq_attr;
 5083|struct mqstat;
 5084|struct audit_watch;
 5085|struct audit_tree;
 5086|
 5087|struct audit_krule {
 5088| int vers_ops;
 5089| u32 flags;
 5090| u32 listnr;
 5091| u32 action;
 5092| u32 mask[64];
 5093| u32 buflen;
 5094| u32 field_count;
 5095| char *filterkey;
 5096| struct audit_field *fields;
 5097| struct audit_field *arch_f;
 5098| struct audit_field *inode_f;
 5099| struct audit_watch *watch;
 5100| struct audit_tree *tree;
 5101| struct list_head rlist;
 5102| struct list_head list;
 5103| u64 prio;
 5104|};
 5105|
 5106|struct audit_field {
 5107| u32 type;
 5108| u32 val;
 5109| u32 op;
 5110| char *lsm_str;
 5111| void *lsm_rule;
 5112|};
 5113|
 5114|
 5115|
 5116|
 5117|
 5118|extern int audit_register_class(int class, unsigned *list);
 5119|extern int audit_classify_syscall(int abi, unsigned syscall);
 5120|extern int audit_classify_arch(int arch);
 5121|
 5122|
 5123|
 5124|extern void audit_finish_fork(struct task_struct *child);
 5125|extern int audit_alloc(struct task_struct *task);
 5126|extern void audit_free(struct task_struct *task);
 5127|extern void audit_syscall_entry(int arch,
 5128|    int major, unsigned long a0, unsigned long a1,
 5129|    unsigned long a2, unsigned long a3);
 5130|extern void audit_syscall_exit(int failed, long return_code);
 5131|extern void __audit_getname(const char *name);
 5132|extern void audit_putname(const char *name);
 5133|extern void __audit_inode(const char *name, const struct dentry *dentry);
 5134|extern void __audit_inode_child(const struct dentry *dentry,
 5135|    const struct inode *parent);
 5136|extern void __audit_ptrace(struct task_struct *t);
 5137|
 5138|static inline int audit_dummy_context(void)
 5139|{
 5140| void *p = get_current()->audit_context;
 5141| return !p || *(int *)p;
 5142|}
 5143|static inline void audit_getname(const char *name)
 5144|{
 5145| if (__builtin_expect(!!(!audit_dummy_context()), 0))
 5146|  __audit_getname(name);
 5147|}
 5148|static inline void audit_inode(const char *name, const struct dentry *dentry) {
 5149| if (__builtin_expect(!!(!audit_dummy_context()), 0))
 5150|  __audit_inode(name, dentry);
 5151|}
 5152|static inline void audit_inode_child(const struct dentry *dentry,
 5153|         const struct inode *parent) {
 5154| if (__builtin_expect(!!(!audit_dummy_context()), 0))
 5155|  __audit_inode_child(dentry, parent);
 5156|}
 5157|void audit_core_dumps(long signr);
 5158|
 5159|static inline void audit_ptrace(struct task_struct *t)
 5160|{
 5161| if (__builtin_expect(!!(!audit_dummy_context()), 0))
 5162|  __audit_ptrace(t);
 5163|}
 5164|
 5165|
 5166|extern unsigned int audit_serial(void);
 5167|extern int auditsc_get_stamp(struct audit_context *ctx,
 5168|         struct timespec *t, unsigned int *serial);
 5169|extern int audit_set_loginuid(struct task_struct *task, uid_t loginuid);
 5170|
 5171|
 5172|extern void audit_log_task_context(struct audit_buffer *ab);
 5173|extern void __audit_ipc_obj(struct kern_ipc_perm *ipcp);
 5174|extern void __audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, mode_t mode);
 5175|extern int audit_bprm(struct linux_binprm *bprm);
 5176|extern void audit_socketcall(int nargs, unsigned long *args);
 5177|extern int audit_sockaddr(int len, void *addr);
 5178|extern void __audit_fd_pair(int fd1, int fd2);
 5179|extern int audit_set_macxattr(const char *name);
 5180|extern void __audit_mq_open(int oflag, mode_t mode, struct mq_attr *attr);
 5181|extern void __audit_mq_sendrecv(mqd_t mqdes, size_t msg_len, unsigned int msg_prio, const struct timespec *abs_timeout);
 5182|extern void __audit_mq_notify(mqd_t mqdes, const struct sigevent *notification);
 5183|extern void __audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat);
 5184|extern int __audit_log_bprm_fcaps(struct linux_binprm *bprm,
 5185|      const struct cred *new,
 5186|      const struct cred *old);
 5187|extern void __audit_log_capset(pid_t pid, const struct cred *new, const struct cred *old);
 5188|extern void __audit_mmap_fd(int fd, int flags);
 5189|
 5190|static inline void audit_ipc_obj(struct kern_ipc_perm *ipcp)
 5191|{
 5192| if (__builtin_expect(!!(!audit_dummy_context()), 0))
 5193|  __audit_ipc_obj(ipcp);
 5194|}
 5195|static inline void audit_fd_pair(int fd1, int fd2)
 5196|{
 5197| if (__builtin_expect(!!(!audit_dummy_context()), 0))
 5198|  __audit_fd_pair(fd1, fd2);
 5199|}
 5200|static inline void audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, mode_t mode)
 5201|{
 5202| if (__builtin_expect(!!(!audit_dummy_context()), 0))
 5203|  __audit_ipc_set_perm(qbytes, uid, gid, mode);
 5204|}
 5205|static inline void audit_mq_open(int oflag, mode_t mode, struct mq_attr *attr)
 5206|{
 5207| if (__builtin_expect(!!(!audit_dummy_context()), 0))
 5208|  __audit_mq_open(oflag, mode, attr);
 5209|}
 5210|static inline void audit_mq_sendrecv(mqd_t mqdes, size_t msg_len, unsigned int msg_prio, const struct timespec *abs_timeout)
 5211|{
 5212| if (__builtin_expect(!!(!audit_dummy_context()), 0))
 5213|  __audit_mq_sendrecv(mqdes, msg_len, msg_prio, abs_timeout);
 5214|}
 5215|static inline void audit_mq_notify(mqd_t mqdes, const struct sigevent *notification)
 5216|{
 5217| if (__builtin_expect(!!(!audit_dummy_context()), 0))
 5218|  __audit_mq_notify(mqdes, notification);
 5219|}
 5220|static inline void audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat)
 5221|{
 5222| if (__builtin_expect(!!(!audit_dummy_context()), 0))
 5223|  __audit_mq_getsetattr(mqdes, mqstat);
 5224|}
 5225|
 5226|static inline int audit_log_bprm_fcaps(struct linux_binprm *bprm,
 5227|           const struct cred *new,
 5228|           const struct cred *old)
 5229|{
 5230| if (__builtin_expect(!!(!audit_dummy_context()), 0))
 5231|  return __audit_log_bprm_fcaps(bprm, new, old);
 5232| return 0;
 5233|}
 5234|
 5235|static inline void audit_log_capset(pid_t pid, const struct cred *new,
 5236|       const struct cred *old)
 5237|{
 5238| if (__builtin_expect(!!(!audit_dummy_context()), 0))
 5239|  __audit_log_capset(pid, new, old);
 5240|}
 5241|
 5242|static inline void audit_mmap_fd(int fd, int flags)
 5243|{
 5244| if (__builtin_expect(!!(!audit_dummy_context()), 0))
 5245|  __audit_mmap_fd(fd, flags);
 5246|}
 5247|
 5248|extern int audit_n_rules;
 5249|extern int audit_signals;
 5250|extern void audit_log(struct audit_context *ctx, gfp_t gfp_mask,
 5251|          int type, const char *fmt, ...)
 5252|          ;
 5253|
 5254|extern struct audit_buffer *audit_log_start(struct audit_context *ctx, gfp_t gfp_mask, int type);
 5255|extern void audit_log_format(struct audit_buffer *ab,
 5256|          const char *fmt, ...)
 5257|       ;
 5258|extern void audit_log_end(struct audit_buffer *ab);
 5259|extern int audit_string_contains_control(const char *string,
 5260|         size_t len);
 5261|extern void audit_log_n_hex(struct audit_buffer *ab,
 5262|       const unsigned char *buf,
 5263|       size_t len);
 5264|extern void audit_log_n_string(struct audit_buffer *ab,
 5265|            const char *buf,
 5266|            size_t n);
 5267|
 5268|extern void audit_log_n_untrustedstring(struct audit_buffer *ab,
 5269|       const char *string,
 5270|       size_t n);
 5271|extern void audit_log_untrustedstring(struct audit_buffer *ab,
 5272|            const char *string);
 5273|extern void audit_log_d_path(struct audit_buffer *ab,
 5274|          const char *prefix,
 5275|          struct path *path);
 5276|extern void audit_log_key(struct audit_buffer *ab,
 5277|       char *key);
 5278|extern void audit_log_lost(const char *message);
 5279|extern int audit_update_lsm_rules(void);
 5280|
 5281|
 5282|extern int audit_filter_user(struct netlink_skb_parms *cb);
 5283|extern int audit_filter_type(int type);
 5284|extern int audit_receive_filter(int type, int pid, int uid, int seq,
 5285|    void *data, size_t datasz, uid_t loginuid,
 5286|    u32 sessionid, u32 sid);
 5287|extern int audit_enabled;
 5288|
 5289|
 5290|
 5291|
 5292|
 5293|
 5294|static inline void fsnotify_d_instantiate(struct dentry *dentry,
 5295|       struct inode *inode)
 5296|{
 5297| __fsnotify_d_instantiate(dentry, inode);
 5298|}
 5299|
 5300|
 5301|static inline int fsnotify_parent(struct path *path, struct dentry *dentry, __u32 mask)
 5302|{
 5303| if (!dentry)
 5304|  dentry = path->dentry;
 5305|
 5306| return __fsnotify_parent(path, dentry, mask);
 5307|}
 5308|
 5309|
 5310|static inline int fsnotify_perm(struct file *file, int mask)
 5311|{
 5312| struct path *path = &file->f_path;
 5313| struct inode *inode = path->dentry->d_inode;
 5314| __u32 fsnotify_mask = 0;
 5315| int ret;
 5316|
 5317| if (file->f_mode & (( fmode_t)0x1000000))
 5318|  return 0;
 5319| if (!(mask & (4 | 32)))
 5320|  return 0;
 5321| if (mask & 32)
 5322|  fsnotify_mask = 0x00010000;
 5323| else if (mask & 4)
 5324|  fsnotify_mask = 0x00020000;
 5325| else
 5326|  do { asm volatile("1:\tud2\n" ".pushsection __bug_table,\"a\"\n" "2:\t.long 1b - 2b, %c0 - 2b\n" "\t.word %c1, 0\n" "\t.org 2b+%c2\n" ".popsection" : : "i" ("/home/l/latest/linux/include/linux/fsnotify.h"), "i" (54), "i" (sizeof(struct bug_entry))); __builtin_unreachable(); } while (0);
 5327|
 5328| ret = fsnotify_parent(path, ((void *)0), fsnotify_mask);
 5329| if (ret)
 5330|  return ret;
 5331|
 5332| return fsnotify(inode, fsnotify_mask, path, 1, ((void *)0), 0);
 5333|}
 5334|
 5335|
 5336|
 5337|
 5338|
 5339|static inline void fsnotify_d_move(struct dentry *dentry)
 5340|{
 5341|
 5342|
 5343|
 5344|
 5345| __fsnotify_update_dcache_flags(dentry);
 5346|}
 5347|
 5348|
 5349|
 5350|
 5351|static inline void fsnotify_link_count(struct inode *inode)
 5352|{
 5353| fsnotify(inode, 0x00000004, inode, 2, ((void *)0), 0);
 5354|}
 5355|
 5356|
 5357|
 5358|
 5359|static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir,
 5360|     const unsigned char *old_name,
 5361|     int isdir, struct inode *target, struct dentry *moved)
 5362|{
 5363| struct inode *source = moved->d_inode;
 5364| u32 fs_cookie = fsnotify_get_cookie();
 5365| __u32 old_dir_mask = (0x08000000 | 0x00000040);
 5366| __u32 new_dir_mask = (0x08000000 | 0x00000080);
 5367| const unsigned char *new_name = moved->d_name.name;
 5368|
 5369| if (old_dir == new_dir)
 5370|  old_dir_mask |= 0x10000000;
 5371|
 5372| if (isdir) {
 5373|  old_dir_mask |= 0x40000000;
 5374|  new_dir_mask |= 0x40000000;
 5375| }
 5376|
 5377| fsnotify(old_dir, old_dir_mask, old_dir, 2, old_name, fs_cookie);
 5378| fsnotify(new_dir, new_dir_mask, new_dir, 2, new_name, fs_cookie);
 5379|
 5380| if (target)
 5381|  fsnotify_link_count(target);
 5382|
 5383| if (source)
 5384|  fsnotify(source, 0x00000800, moved->d_inode, 2, ((void *)0), 0);
 5385| audit_inode_child(moved, new_dir);
 5386|}
 5387|
 5388|
 5389|
 5390|
 5391|static inline void fsnotify_inode_delete(struct inode *inode)
 5392|{
 5393| __fsnotify_inode_delete(inode);
 5394|}
 5395|
 5396|
 5397|
 5398|
 5399|static inline void fsnotify_vfsmount_delete(struct vfsmount *mnt)
 5400|{
 5401| __fsnotify_vfsmount_delete(mnt);
 5402|}
 5403|
 5404|
 5405|
 5406|
 5407|static inline void fsnotify_nameremove(struct dentry *dentry, int isdir)
 5408|{
 5409| __u32 mask = 0x00000200;
 5410|
 5411| if (isdir)
 5412|  mask |= 0x40000000;
 5413|
 5414| fsnotify_parent(((void *)0), dentry, mask);
 5415|}
 5416|
 5417|
 5418|
 5419|
 5420|static inline void fsnotify_inoderemove(struct inode *inode)
 5421|{
 5422| fsnotify(inode, 0x00000400, inode, 2, ((void *)0), 0);
 5423| __fsnotify_inode_delete(inode);
 5424|}
 5425|
 5426|
 5427|
 5428|
 5429|static inline void fsnotify_create(struct inode *inode, struct dentry *dentry)
 5430|{
 5431| audit_inode_child(dentry, inode);
 5432|
 5433| fsnotify(inode, 0x00000100, dentry->d_inode, 2, dentry->d_name.name, 0);
 5434|}
 5435|
 5436|
 5437|
 5438|
 5439|
 5440|
 5441|static inline void fsnotify_link(struct inode *dir, struct inode *inode, struct dentry *new_dentry)
 5442|{
 5443| fsnotify_link_count(inode);
 5444| audit_inode_child(new_dentry, dir);
 5445|
 5446| fsnotify(dir, 0x00000100, inode, 2, new_dentry->d_name.name, 0);
 5447|}
 5448|
 5449|
 5450|
 5451|
 5452|static inline void fsnotify_mkdir(struct inode *inode, struct dentry *dentry)
 5453|{
 5454| __u32 mask = (0x00000100 | 0x40000000);
 5455| struct inode *d_inode = dentry->d_inode;
 5456|
 5457| audit_inode_child(dentry, inode);
 5458|
 5459| fsnotify(inode, mask, d_inode, 2, dentry->d_name.name, 0);
 5460|}
 5461|
 5462|
 5463|
 5464|
 5465|static inline void fsnotify_access(struct file *file)
 5466|{
 5467| struct path *path = &file->f_path;
 5468| struct inode *inode = path->dentry->d_inode;
 5469| __u32 mask = 0x00000001;
 5470|
 5471| if ((((inode->i_mode) & 00170000) == 0040000))
 5472|  mask |= 0x40000000;
 5473|
 5474| if (!(file->f_mode & (( fmode_t)0x1000000))) {
 5475|  fsnotify_parent(path, ((void *)0), mask);
 5476|  fsnotify(inode, mask, path, 1, ((void *)0), 0);
 5477| }
 5478|}
 5479|
 5480|
 5481|
 5482|
 5483|static inline void fsnotify_modify(struct file *file)
 5484|{
 5485| struct path *path = &file->f_path;
 5486| struct inode *inode = path->dentry->d_inode;
 5487| __u32 mask = 0x00000002;
 5488|
 5489| if ((((inode->i_mode) & 00170000) == 0040000))
 5490|  mask |= 0x40000000;
 5491|
 5492| if (!(file->f_mode & (( fmode_t)0x1000000))) {
 5493|  fsnotify_parent(path, ((void *)0), mask);
 5494|  fsnotify(inode, mask, path, 1, ((void *)0), 0);
 5495| }
 5496|}
 5497|
 5498|
 5499|
 5500|
 5501|static inline void fsnotify_open(struct file *file)
 5502|{
 5503| struct path *path = &file->f_path;
 5504| struct inode *inode = path->dentry->d_inode;
 5505| __u32 mask = 0x00000020;
 5506|
 5507| if ((((inode->i_mode) & 00170000) == 0040000))
 5508|  mask |= 0x40000000;
 5509|
 5510| fsnotify_parent(path, ((void *)0), mask);
 5511| fsnotify(inode, mask, path, 1, ((void *)0), 0);
 5512|}
 5513|
 5514|
 5515|
 5516|
 5517|static inline void fsnotify_close(struct file *file)
 5518|{
 5519| struct path *path = &file->f_path;
 5520| struct inode *inode = file->f_path.dentry->d_inode;
 5521| fmode_t mode = file->f_mode;
 5522| __u32 mask = (mode & (( fmode_t)0x2)) ? 0x00000008 : 0x00000010;
 5523|
 5524| if ((((inode->i_mode) & 00170000) == 0040000))
 5525|  mask |= 0x40000000;
 5526|
 5527| if (!(file->f_mode & (( fmode_t)0x1000000))) {
 5528|  fsnotify_parent(path, ((void *)0), mask);
 5529|  fsnotify(inode, mask, path, 1, ((void *)0), 0);
 5530| }
 5531|}
 5532|
 5533|
 5534|
 5535|
 5536|static inline void fsnotify_xattr(struct dentry *dentry)
 5537|{
 5538| struct inode *inode = dentry->d_inode;
 5539| __u32 mask = 0x00000004;
 5540|
 5541| if ((((inode->i_mode) & 00170000) == 0040000))
 5542|  mask |= 0x40000000;
 5543|
 5544| fsnotify_parent(((void *)0), dentry, mask);
 5545| fsnotify(inode, mask, inode, 2, ((void *)0), 0);
 5546|}
 5547|
 5548|
 5549|
 5550|
 5551|
 5552|static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
 5553|{
 5554| struct inode *inode = dentry->d_inode;
 5555| __u32 mask = 0;
 5556|
 5557| if (ia_valid & (1 << 1))
 5558|  mask |= 0x00000004;
 5559| if (ia_valid & (1 << 2))
 5560|  mask |= 0x00000004;
 5561| if (ia_valid & (1 << 3))
 5562|  mask |= 0x00000002;
 5563|
 5564|
 5565| if ((ia_valid & ((1 << 4) | (1 << 5))) == ((1 << 4) | (1 << 5)))
 5566|  mask |= 0x00000004;
 5567| else if (ia_valid & (1 << 4))
 5568|  mask |= 0x00000001;
 5569| else if (ia_valid & (1 << 5))
 5570|  mask |= 0x00000002;
 5571|
 5572| if (ia_valid & (1 << 0))
 5573|  mask |= 0x00000004;
 5574|
 5575| if (mask) {
 5576|  if ((((inode->i_mode) & 00170000) == 0040000))
 5577|   mask |= 0x40000000;
 5578|
 5579|  fsnotify_parent(((void *)0), dentry, mask);
 5580|  fsnotify(inode, mask, inode, 2, ((void *)0), 0);
 5581| }
 5582|}
 5583|
 5584|
 5585|
 5586|
 5587|
 5588|
 5589|static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
 5590|{
 5591| return kstrdup(name, ((( gfp_t)0x10u) | (( gfp_t)0x40u) | (( gfp_t)0x80u)));
 5592|}
 5593|
 5594|
 5595|
 5596|
 5597|static inline void fsnotify_oldname_free(const unsigned char *old_name)
 5598|{
 5599| kfree(old_name);
 5600|}
 5601|
 5602|
 5603|
 5604|
 5605|
 5606|struct pt_regs;
 5607|struct linux_binprm{
 5608| char buf[128];
 5609|
 5610| struct vm_area_struct *vma;
 5611|
 5612|
 5613|
 5614|
 5615| struct mm_struct *mm;
 5616| unsigned long p;
 5617| unsigned int
 5618|  cred_prepared:1,
 5619|
 5620|  cap_effective:1;
 5621|
 5622|
 5623|
 5624|
 5625|
 5626| unsigned int recursion_depth;
 5627| struct file * file;
 5628| struct cred *cred;
 5629| int unsafe;
 5630| unsigned int per_clear;
 5631| int argc, envc;
 5632| const char * filename;
 5633| const char * interp;
 5634|
 5635|
 5636| unsigned interp_flags;
 5637| unsigned interp_data;
 5638| unsigned long loader, exec;
 5639|};
 5640|struct coredump_params {
 5641| long signr;
 5642| struct pt_regs *regs;
 5643| struct file *file;
 5644| unsigned long limit;
 5645| unsigned long mm_flags;
 5646|};
 5647|
 5648|
 5649|
 5650|
 5651|
 5652|struct linux_binfmt {
 5653| struct list_head lh;
 5654| struct module *module;
 5655| int (*load_binary)(struct linux_binprm *, struct pt_regs * regs);
 5656| int (*load_shlib)(struct file *);
 5657| int (*core_dump)(struct coredump_params *cprm);
 5658| unsigned long min_coredump;
 5659| int hasvdso;
 5660|};
 5661|
 5662|extern int __register_binfmt(struct linux_binfmt *fmt, int insert);
 5663|
 5664|
 5665|static inline int register_binfmt(struct linux_binfmt *fmt)
 5666|{
 5667| return __register_binfmt(fmt, 0);
 5668|}
 5669|
 5670|static inline int insert_binfmt(struct linux_binfmt *fmt)
 5671|{
 5672| return __register_binfmt(fmt, 1);
 5673|}
 5674|
 5675|extern void unregister_binfmt(struct linux_binfmt *);
 5676|
 5677|extern int prepare_binprm(struct linux_binprm *);
 5678|extern int remove_arg_zero(struct linux_binprm *);
 5679|extern int search_binary_handler(struct linux_binprm *,struct pt_regs *);
 5680|extern int flush_old_exec(struct linux_binprm * bprm);
 5681|extern void setup_new_exec(struct linux_binprm * bprm);
 5682|
 5683|extern int suid_dumpable;
 5684|extern int setup_arg_pages(struct linux_binprm * bprm,
 5685|      unsigned long stack_top,
 5686|      int executable_stack);
 5687|extern int bprm_mm_init(struct linux_binprm *bprm);
 5688|extern int copy_strings_kernel(int argc, const char *const *argv,
 5689|          struct linux_binprm *bprm);
 5690|extern int prepare_bprm_creds(struct linux_binprm *bprm);
 5691|extern void install_exec_creds(struct linux_binprm *bprm);
 5692|extern void do_coredump(long signr, int exit_code, struct pt_regs *regs);
 5693|extern void set_binfmt(struct linux_binfmt *new);
 5694|extern void free_bprm(struct linux_binprm *);
 5695|
 5696|
 5697|
 5698|
 5699|
 5700|
 5701|struct shmid_ds {
 5702| struct ipc_perm shm_perm;
 5703| int shm_segsz;
 5704| __kernel_time_t shm_atime;
 5705| __kernel_time_t shm_dtime;
 5706| __kernel_time_t shm_ctime;
 5707| __kernel_ipc_pid_t shm_cpid;
 5708| __kernel_ipc_pid_t shm_lpid;
 5709| unsigned short shm_nattch;
 5710| unsigned short shm_unused;
 5711| void *shm_unused2;
 5712| void *shm_unused3;
 5713|};
 5714|
 5715|
 5716|struct shmid64_ds {
 5717| struct ipc64_perm shm_perm;
 5718| size_t shm_segsz;
 5719| __kernel_time_t shm_atime;
 5720|
 5721|
 5722|
 5723| __kernel_time_t shm_dtime;
 5724|
 5725|
 5726|
 5727| __kernel_time_t shm_ctime;
 5728|
 5729|
 5730|
 5731| __kernel_pid_t shm_cpid;
 5732| __kernel_pid_t shm_lpid;
 5733| unsigned long shm_nattch;
 5734| unsigned long __unused4;
 5735| unsigned long __unused5;
 5736|};
 5737|
 5738|struct shminfo64 {
 5739| unsigned long shmmax;
 5740| unsigned long shmmin;
 5741| unsigned long shmmni;
 5742| unsigned long shmseg;
 5743| unsigned long shmall;
 5744| unsigned long __unused1;
 5745| unsigned long __unused2;
 5746| unsigned long __unused3;
 5747| unsigned long __unused4;
 5748|};
 5749|struct shminfo {
 5750| int shmmax;
 5751| int shmmin;
 5752| int shmmni;
 5753| int shmseg;
 5754| int shmall;
 5755|};
 5756|
 5757|struct shm_info {
 5758| int used_ids;
 5759| unsigned long shm_tot;
 5760| unsigned long shm_rss;
 5761| unsigned long shm_swp;
 5762| unsigned long swap_attempts;
 5763| unsigned long swap_successes;
 5764|};
 5765|
 5766|
 5767|struct shmid_kernel
 5768|{
 5769| struct kern_ipc_perm shm_perm;
 5770| struct file * shm_file;
 5771| unsigned long shm_nattch;
 5772| unsigned long shm_segsz;
 5773| time_t shm_atim;
 5774| time_t shm_dtim;
 5775| time_t shm_ctim;
 5776| pid_t shm_cprid;
 5777| pid_t shm_lprid;
 5778| struct user_struct *mlock_user;
 5779|};
 5780|long do_shmat(int shmid, char *shmaddr, int shmflg, unsigned long *addr);
 5781|extern int is_file_shm_hugepages(struct file *file);
 5782|
 5783|struct msqid_ds {
 5784| struct ipc_perm msg_perm;
 5785| struct msg *msg_first;
 5786| struct msg *msg_last;
 5787| __kernel_time_t msg_stime;
 5788| __kernel_time_t msg_rtime;
 5789| __kernel_time_t msg_ctime;
 5790| unsigned long msg_lcbytes;
 5791| unsigned long msg_lqbytes;
 5792| unsigned short msg_cbytes;
 5793| unsigned short msg_qnum;
 5794| unsigned short msg_qbytes;
 5795| __kernel_ipc_pid_t msg_lspid;
 5796| __kernel_ipc_pid_t msg_lrpid;
 5797|};
 5798|
 5799|
 5800|struct msqid64_ds {
 5801| struct ipc64_perm msg_perm;
 5802| __kernel_time_t msg_stime;
 5803|
 5804|
 5805|
 5806| __kernel_time_t msg_rtime;
 5807|
 5808|
 5809|
 5810| __kernel_time_t msg_ctime;
 5811|
 5812|
 5813|
 5814| unsigned long msg_cbytes;
 5815| unsigned long msg_qnum;
 5816| unsigned long msg_qbytes;
 5817| __kernel_pid_t msg_lspid;
 5818| __kernel_pid_t msg_lrpid;
 5819| unsigned long __unused4;
 5820| unsigned long __unused5;
 5821|};
 5822|
 5823|
 5824|struct msgbuf {
 5825| long mtype;
 5826| char mtext[1];
 5827|};
 5828|
 5829|
 5830|struct msginfo {
 5831| int msgpool;
 5832| int msgmap;
 5833| int msgmax;
 5834| int msgmnb;
 5835| int msgmni;
 5836| int msgssz;
 5837| int msgtql;
 5838| unsigned short msgseg;
 5839|};
 5840|struct msg_msg {
 5841| struct list_head m_list;
 5842| long m_type;
 5843| int m_ts;
 5844| struct msg_msgseg* next;
 5845| void *security;
 5846|
 5847|};
 5848|
 5849|
 5850|struct msg_queue {
 5851| struct kern_ipc_perm q_perm;
 5852| time_t q_stime;
 5853| time_t q_rtime;
 5854| time_t q_ctime;
 5855| unsigned long q_cbytes;
 5856| unsigned long q_qnum;
 5857| unsigned long q_qbytes;
 5858| pid_t q_lspid;
 5859| pid_t q_lrpid;
 5860|
 5861| struct list_head q_messages;
 5862| struct list_head q_receivers;
 5863| struct list_head q_senders;
 5864|};
 5865|
 5866|
 5867|extern long do_msgsnd(int msqid, long mtype, void *mtext,
 5868|   size_t msgsz, int msgflg);
 5869|extern long do_msgrcv(int msqid, long *pmtype, void *mtext,
 5870|   size_t msgsz, long msgtyp, int msgflg);
 5871|
 5872|
 5873|typedef union {
 5874| __be32 a4;
 5875| __be32 a6[4];
 5876|} xfrm_address_t;
 5877|
 5878|
 5879|
 5880|
 5881|
 5882|struct xfrm_id {
 5883| xfrm_address_t daddr;
 5884| __be32 spi;
 5885| __u8 proto;
 5886|};
 5887|
 5888|struct xfrm_sec_ctx {
 5889| __u8 ctx_doi;
 5890| __u8 ctx_alg;
 5891| __u16 ctx_len;
 5892| __u32 ctx_sid;
 5893| char ctx_str[0];
 5894|};
 5895|struct xfrm_selector {
 5896| xfrm_address_t daddr;
 5897| xfrm_address_t saddr;
 5898| __be16 dport;
 5899| __be16 dport_mask;
 5900| __be16 sport;
 5901| __be16 sport_mask;
 5902| __u16 family;
 5903| __u8 prefixlen_d;
 5904| __u8 prefixlen_s;
 5905| __u8 proto;
 5906| int ifindex;
 5907| __kernel_uid32_t user;
 5908|};
 5909|
 5910|
 5911|
 5912|struct xfrm_lifetime_cfg {
 5913| __u64 soft_byte_limit;
 5914| __u64 hard_byte_limit;
 5915| __u64 soft_packet_limit;
 5916| __u64 hard_packet_limit;
 5917| __u64 soft_add_expires_seconds;
 5918| __u64 hard_add_expires_seconds;
 5919| __u64 soft_use_expires_seconds;
 5920| __u64 hard_use_expires_seconds;
 5921|};
 5922|
 5923|struct xfrm_lifetime_cur {
 5924| __u64 bytes;
 5925| __u64 packets;
 5926| __u64 add_time;
 5927| __u64 use_time;
 5928|};
 5929|
 5930|struct xfrm_replay_state {
 5931| __u32 oseq;
 5932| __u32 seq;
 5933| __u32 bitmap;
 5934|};
 5935|
 5936|struct xfrm_algo {
 5937| char alg_name[64];
 5938| unsigned int alg_key_len;
 5939| char alg_key[0];
 5940|};
 5941|
 5942|struct xfrm_algo_auth {
 5943| char alg_name[64];
 5944| unsigned int alg_key_len;
 5945| unsigned int alg_trunc_len;
 5946| char alg_key[0];
 5947|};
 5948|
 5949|struct xfrm_algo_aead {
 5950| char alg_name[64];
 5951| unsigned int alg_key_len;
 5952| unsigned int alg_icv_len;
 5953| char alg_key[0];
 5954|};
 5955|
 5956|struct xfrm_stats {
 5957| __u32 replay_window;
 5958| __u32 replay;
 5959| __u32 integrity_failed;
 5960|};
 5961|
 5962|enum {
 5963| XFRM_POLICY_TYPE_MAIN = 0,
 5964| XFRM_POLICY_TYPE_SUB = 1,
 5965| XFRM_POLICY_TYPE_MAX = 2,
 5966| XFRM_POLICY_TYPE_ANY = 255
 5967|};
 5968|
 5969|enum {
 5970| XFRM_POLICY_IN = 0,
 5971| XFRM_POLICY_OUT = 1,
 5972| XFRM_POLICY_FWD = 2,
 5973| XFRM_POLICY_MASK = 3,
 5974| XFRM_POLICY_MAX = 3
 5975|};
 5976|
 5977|enum {
 5978| XFRM_SHARE_ANY,
 5979| XFRM_SHARE_SESSION,
 5980| XFRM_SHARE_USER,
 5981| XFRM_SHARE_UNIQUE
 5982|};
 5983|enum {
 5984| XFRM_MSG_BASE = 0x10,
 5985|
 5986| XFRM_MSG_NEWSA = 0x10,
 5987|
 5988| XFRM_MSG_DELSA,
 5989|
 5990| XFRM_MSG_GETSA,
 5991|
 5992|
 5993| XFRM_MSG_NEWPOLICY,
 5994|
 5995| XFRM_MSG_DELPOLICY,
 5996|
 5997| XFRM_MSG_GETPOLICY,
 5998|
 5999|
 6000| XFRM_MSG_ALLOCSPI,
 6001|
 6002| XFRM_MSG_ACQUIRE,
 6003|
 6004| XFRM_MSG_EXPIRE,
 6005|
 6006|
 6007| XFRM_MSG_UPDPOLICY,
 6008|
 6009| XFRM_MSG_UPDSA,
 6010|
 6011|
 6012| XFRM_MSG_POLEXPIRE,
 6013|
 6014|
 6015| XFRM_MSG_FLUSHSA,
 6016|
 6017| XFRM_MSG_FLUSHPOLICY,
 6018|
 6019|
 6020| XFRM_MSG_NEWAE,
 6021|
 6022| XFRM_MSG_GETAE,
 6023|
 6024|
 6025| XFRM_MSG_REPORT,
 6026|
 6027|
 6028| XFRM_MSG_MIGRATE,
 6029|
 6030|
 6031| XFRM_MSG_NEWSADINFO,
 6032|
 6033| XFRM_MSG_GETSADINFO,
 6034|
 6035|
 6036| XFRM_MSG_NEWSPDINFO,
 6037|
 6038| XFRM_MSG_GETSPDINFO,
 6039|
 6040|
 6041| XFRM_MSG_MAPPING,
 6042|
 6043| __XFRM_MSG_MAX
 6044|};
 6045|struct xfrm_user_sec_ctx {
 6046| __u16 len;
 6047| __u16 exttype;
 6048| __u8 ctx_alg;
 6049| __u8 ctx_doi;
 6050| __u16 ctx_len;
 6051|};
 6052|
 6053|struct xfrm_user_tmpl {
 6054| struct xfrm_id id;
 6055| __u16 family;
 6056| xfrm_address_t saddr;
 6057| __u32 reqid;
 6058| __u8 mode;
 6059| __u8 share;
 6060| __u8 optional;
 6061| __u32 aalgos;
 6062| __u32 ealgos;
 6063| __u32 calgos;
 6064|};
 6065|
 6066|struct xfrm_encap_tmpl {
 6067| __u16 encap_type;
 6068| __be16 encap_sport;
 6069| __be16 encap_dport;
 6070| xfrm_address_t encap_oa;
 6071|};
 6072|
 6073|
 6074|enum xfrm_ae_ftype_t {
 6075| XFRM_AE_UNSPEC,
 6076| XFRM_AE_RTHR=1,
 6077| XFRM_AE_RVAL=2,
 6078| XFRM_AE_LVAL=4,
 6079| XFRM_AE_ETHR=8,
 6080| XFRM_AE_CR=16,
 6081| XFRM_AE_CE=32,
 6082| XFRM_AE_CU=64,
 6083| __XFRM_AE_MAX
 6084|
 6085|
 6086|};
 6087|
 6088|struct xfrm_userpolicy_type {
 6089| __u8 type;
 6090| __u16 reserved1;
 6091| __u8 reserved2;
 6092|};
 6093|
 6094|
 6095|enum xfrm_attr_type_t {
 6096| XFRMA_UNSPEC,
 6097| XFRMA_ALG_AUTH,
 6098| XFRMA_ALG_CRYPT,
 6099| XFRMA_ALG_COMP,
 6100| XFRMA_ENCAP,
 6101| XFRMA_TMPL,
 6102| XFRMA_SA,
 6103| XFRMA_POLICY,
 6104| XFRMA_SEC_CTX,
 6105| XFRMA_LTIME_VAL,
 6106| XFRMA_REPLAY_VAL,
 6107| XFRMA_REPLAY_THRESH,
 6108| XFRMA_ETIMER_THRESH,
 6109| XFRMA_SRCADDR,
 6110| XFRMA_COADDR,
 6111| XFRMA_LASTUSED,
 6112| XFRMA_POLICY_TYPE,
 6113| XFRMA_MIGRATE,
 6114| XFRMA_ALG_AEAD,
 6115| XFRMA_KMADDRESS,
 6116| XFRMA_ALG_AUTH_TRUNC,
 6117| XFRMA_MARK,
 6118| __XFRMA_MAX
 6119|
 6120|
 6121|};
 6122|
 6123|struct xfrm_mark {
 6124| __u32 v;
 6125| __u32 m;
 6126|};
 6127|
 6128|enum xfrm_sadattr_type_t {
 6129| XFRMA_SAD_UNSPEC,
 6130| XFRMA_SAD_CNT,
 6131| XFRMA_SAD_HINFO,
 6132| __XFRMA_SAD_MAX
 6133|
 6134|
 6135|};
 6136|
 6137|struct xfrmu_sadhinfo {
 6138| __u32 sadhcnt;
 6139| __u32 sadhmcnt;
 6140|};
 6141|
 6142|enum xfrm_spdattr_type_t {
 6143| XFRMA_SPD_UNSPEC,
 6144| XFRMA_SPD_INFO,
 6145| XFRMA_SPD_HINFO,
 6146| __XFRMA_SPD_MAX
 6147|
 6148|
 6149|};
 6150|
 6151|struct xfrmu_spdinfo {
 6152| __u32 incnt;
 6153| __u32 outcnt;
 6154| __u32 fwdcnt;
 6155| __u32 inscnt;
 6156| __u32 outscnt;
 6157| __u32 fwdscnt;
 6158|};
 6159|
 6160|struct xfrmu_spdhinfo {
 6161| __u32 spdhcnt;
 6162| __u32 spdhmcnt;
 6163|};
 6164|
 6165|struct xfrm_usersa_info {
 6166| struct xfrm_selector sel;
 6167| struct xfrm_id id;
 6168| xfrm_address_t saddr;
 6169| struct xfrm_lifetime_cfg lft;
 6170| struct xfrm_lifetime_cur curlft;
 6171| struct xfrm_stats stats;
 6172| __u32 seq;
 6173| __u32 reqid;
 6174| __u16 family;
 6175| __u8 mode;
 6176| __u8 replay_window;
 6177| __u8 flags;
 6178|
 6179|
 6180|
 6181|
 6182|
 6183|
 6184|};
 6185|
 6186|struct xfrm_usersa_id {
 6187| xfrm_address_t daddr;
 6188| __be32 spi;
 6189| __u16 family;
 6190| __u8 proto;
 6191|};
 6192|
 6193|struct xfrm_aevent_id {
 6194| struct xfrm_usersa_id sa_id;
 6195| xfrm_address_t saddr;
 6196| __u32 flags;
 6197| __u32 reqid;
 6198|};
 6199|
 6200|struct xfrm_userspi_info {
 6201| struct xfrm_usersa_info info;
 6202| __u32 min;
 6203| __u32 max;
 6204|};
 6205|
 6206|struct xfrm_userpolicy_info {
 6207| struct xfrm_selector sel;
 6208| struct xfrm_lifetime_cfg lft;
 6209| struct xfrm_lifetime_cur curlft;
 6210| __u32 priority;
 6211| __u32 index;
 6212| __u8 dir;
 6213| __u8 action;
 6214|
 6215|
 6216| __u8 flags;
 6217|
 6218|
 6219|
 6220| __u8 share;
 6221|};
 6222|
 6223|struct xfrm_userpolicy_id {
 6224| struct xfrm_selector sel;
 6225| __u32 index;
 6226| __u8 dir;
 6227|};
 6228|
 6229|struct xfrm_user_acquire {
 6230| struct xfrm_id id;
 6231| xfrm_address_t saddr;
 6232| struct xfrm_selector sel;
 6233| struct xfrm_userpolicy_info policy;
 6234| __u32 aalgos;
 6235| __u32 ealgos;
 6236| __u32 calgos;
 6237| __u32 seq;
 6238|};
 6239|
 6240|struct xfrm_user_expire {
 6241| struct xfrm_usersa_info state;
 6242| __u8 hard;
 6243|};
 6244|
 6245|struct xfrm_user_polexpire {
 6246| struct xfrm_userpolicy_info pol;
 6247| __u8 hard;
 6248|};
 6249|
 6250|struct xfrm_usersa_flush {
 6251| __u8 proto;
 6252|};
 6253|
 6254|struct xfrm_user_report {
 6255| __u8 proto;
 6256| struct xfrm_selector sel;
 6257|};
 6258|
 6259|
 6260|
 6261|struct xfrm_user_kmaddress {
 6262| xfrm_address_t local;
 6263| xfrm_address_t remote;
 6264| __u32 reserved;
 6265| __u16 family;
 6266|};
 6267|
 6268|struct xfrm_user_migrate {
 6269| xfrm_address_t old_daddr;
 6270| xfrm_address_t old_saddr;
 6271| xfrm_address_t new_daddr;
 6272| xfrm_address_t new_saddr;
 6273| __u8 proto;
 6274| __u8 mode;
 6275| __u16 reserved;
 6276| __u32 reqid;
 6277| __u16 old_family;
 6278| __u16 new_family;
 6279|};
 6280|
 6281|struct xfrm_user_mapping {
 6282| struct xfrm_usersa_id id;
 6283| __u32 reqid;
 6284| xfrm_address_t old_saddr;
 6285| xfrm_address_t new_saddr;
 6286| __be16 old_sport;
 6287| __be16 new_sport;
 6288|};
 6289|enum xfrm_nlgroups {
 6290| XFRMNLGRP_NONE,
 6291|
 6292| XFRMNLGRP_ACQUIRE,
 6293|
 6294| XFRMNLGRP_EXPIRE,
 6295|
 6296| XFRMNLGRP_SA,
 6297|
 6298| XFRMNLGRP_POLICY,
 6299|
 6300| XFRMNLGRP_AEVENTS,
 6301|
 6302| XFRMNLGRP_REPORT,
 6303|
 6304| XFRMNLGRP_MIGRATE,
 6305|
 6306| XFRMNLGRP_MAPPING,
 6307|
 6308| __XFRMNLGRP_MAX
 6309|};
 6310|
 6311|struct in6_addr {
 6312| union {
 6313|  __u8 u6_addr8[16];
 6314|  __be16 u6_addr16[8];
 6315|  __be32 u6_addr32[4];
 6316| } in6_u;
 6317|
 6318|
 6319|
 6320|};
 6321|
 6322|
 6323|
 6324|
 6325|
 6326|
 6327|extern const struct in6_addr in6addr_any;
 6328|
 6329|extern const struct in6_addr in6addr_loopback;
 6330|
 6331|extern const struct in6_addr in6addr_linklocal_allnodes;
 6332|
 6333|
 6334|extern const struct in6_addr in6addr_linklocal_allrouters;
 6335|
 6336|
 6337|
 6338|
 6339|struct sockaddr_in6 {
 6340| unsigned short int sin6_family;
 6341| __be16 sin6_port;
 6342| __be32 sin6_flowinfo;
 6343| struct in6_addr sin6_addr;
 6344| __u32 sin6_scope_id;
 6345|};
 6346|
 6347|struct ipv6_mreq {
 6348|
 6349| struct in6_addr ipv6mr_multiaddr;
 6350|
 6351|
 6352| int ipv6mr_ifindex;
 6353|};
 6354|
 6355|
 6356|
 6357|struct in6_flowlabel_req {
 6358| struct in6_addr flr_dst;
 6359| __be32 flr_label;
 6360| __u8 flr_action;
 6361| __u8 flr_share;
 6362| __u16 flr_flags;
 6363| __u16 flr_expires;
 6364| __u16 flr_linger;
 6365| __u32 __flr_pad;
 6366|
 6367|};
 6368|
 6369|
 6370|struct flowi {
 6371| int oif;
 6372| int iif;
 6373| __u32 mark;
 6374|
 6375| union {
 6376|  struct {
 6377|   __be32 daddr;
 6378|   __be32 saddr;
 6379|   __u8 tos;
 6380|   __u8 scope;
 6381|  } ip4_u;
 6382|
 6383|  struct {
 6384|   struct in6_addr daddr;
 6385|   struct in6_addr saddr;
 6386|   __be32 flowlabel;
 6387|  } ip6_u;
 6388|
 6389|  struct {
 6390|   __le16 daddr;
 6391|   __le16 saddr;
 6392|   __u8 scope;
 6393|  } dn_u;
 6394| } nl_u;
 6395| __u8 proto;
 6396| __u8 flags;
 6397|
 6398|
 6399| union {
 6400|  struct {
 6401|   __be16 sport;
 6402|   __be16 dport;
 6403|  } ports;
 6404|
 6405|  struct {
 6406|   __u8 type;
 6407|   __u8 code;
 6408|  } icmpt;
 6409|
 6410|  struct {
 6411|   __le16 sport;
 6412|   __le16 dport;
 6413|  } dnports;
 6414|
 6415|  __be32 spi;
 6416|  __be32 gre_key;
 6417|
 6418|  struct {
 6419|   __u8 type;
 6420|  } mht;
 6421| } uli_u;
 6422|
 6423|
 6424|
 6425|
 6426|
 6427|
 6428|
 6429| __u32 secid;
 6430|} ;
 6431|
 6432|
 6433|
 6434|
 6435|
 6436|struct net;
 6437|struct sock;
 6438|struct flow_cache_ops;
 6439|
 6440|struct flow_cache_object {
 6441| const struct flow_cache_ops *ops;
 6442|};
 6443|
 6444|struct flow_cache_ops {
 6445| struct flow_cache_object *(*get)(struct flow_cache_object *);
 6446| int (*check)(struct flow_cache_object *);
 6447| void (*delete)(struct flow_cache_object *);
 6448|};
 6449|
 6450|typedef struct flow_cache_object *(*flow_resolve_t)(
 6451|  struct net *net, struct flowi *key, u16 family,
 6452|  u8 dir, struct flow_cache_object *oldobj, void *ctx);
 6453|
 6454|extern struct flow_cache_object *flow_cache_lookup(
 6455|  struct net *net, struct flowi *key, u16 family,
 6456|  u8 dir, flow_resolve_t resolver, void *ctx);
 6457|
 6458|extern void flow_cache_flush(void);
 6459|extern atomic_t flow_cache_genid;
 6460|
 6461|static inline int flow_cache_uli_match(struct flowi *fl1, struct flowi *fl2)
 6462|{
 6463| return (fl1->proto == fl2->proto &&
 6464|  !memcmp(&fl1->uli_u, &fl2->uli_u, sizeof(fl1->uli_u)));
 6465|}
 6466|struct ctl_table;
 6467|struct audit_krule;
 6468|
 6469|
 6470|
 6471|
 6472|
 6473|extern int cap_capable(struct task_struct *tsk, const struct cred *cred,
 6474|         int cap, int audit);
 6475|extern int cap_settime(struct timespec *ts, struct timezone *tz);
 6476|extern int cap_ptrace_access_check(struct task_struct *child, unsigned int mode);
 6477|extern int cap_ptrace_traceme(struct task_struct *parent);
 6478|extern int cap_capget(struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
 6479|extern int cap_capset(struct cred *new, const struct cred *old,
 6480|        const kernel_cap_t *effective,
 6481|        const kernel_cap_t *inheritable,
 6482|        const kernel_cap_t *permitted);
 6483|extern int cap_bprm_set_creds(struct linux_binprm *bprm);
 6484|extern int cap_bprm_secureexec(struct linux_binprm *bprm);
 6485|extern int cap_inode_setxattr(struct dentry *dentry, const char *name,
 6486|         const void *value, size_t size, int flags);
 6487|extern int cap_inode_removexattr(struct dentry *dentry, const char *name);
 6488|extern int cap_inode_need_killpriv(struct dentry *dentry);
 6489|extern int cap_inode_killpriv(struct dentry *dentry);
 6490|extern int cap_file_mmap(struct file *file, unsigned long reqprot,
 6491|    unsigned long prot, unsigned long flags,
 6492|    unsigned long addr, unsigned long addr_only);
 6493|extern int cap_task_fix_setuid(struct cred *new, const struct cred *old, int flags);
 6494|extern int cap_task_prctl(int option, unsigned long arg2, unsigned long arg3,
 6495|     unsigned long arg4, unsigned long arg5);
 6496|extern int cap_task_setscheduler(struct task_struct *p);
 6497|extern int cap_task_setioprio(struct task_struct *p, int ioprio);
 6498|extern int cap_task_setnice(struct task_struct *p, int nice);
 6499|extern int cap_vm_enough_memory(struct mm_struct *mm, long pages);
 6500|
 6501|struct msghdr;
 6502|struct sk_buff;
 6503|struct sock;
 6504|struct sockaddr;
 6505|struct socket;
 6506|struct flowi;
 6507|struct dst_entry;
 6508|struct xfrm_selector;
 6509|struct xfrm_policy;
 6510|struct xfrm_state;
 6511|struct xfrm_user_sec_ctx;
 6512|struct seq_file;
 6513|
 6514|extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb);
 6515|extern int cap_netlink_recv(struct sk_buff *skb, int cap);
 6516|
 6517|void reset_security_ops(void);
 6518|
 6519|
 6520|extern unsigned long mmap_min_addr;
 6521|extern unsigned long dac_mmap_min_addr;
 6522|struct sched_param;
 6523|struct request_sock;
 6524|static inline unsigned long round_hint_to_min(unsigned long hint)
 6525|{
 6526| hint &= (~(((1UL) << 12)-1));
 6527| if (((void *)hint != ((void *)0)) &&
 6528|     (hint < mmap_min_addr))
 6529|  return ((((mmap_min_addr)) + ((typeof((mmap_min_addr)))((((1UL) << 12))) - 1)) & ~((typeof((mmap_min_addr)))((((1UL) << 12))) - 1));
 6530| return hint;
 6531|}
 6532|extern int mmap_min_addr_handler(struct ctl_table *table, int write,
 6533|     void *buffer, size_t *lenp, loff_t *ppos);
 6534|
 6535|
 6536|
 6537|
 6538|struct security_mnt_opts {
 6539| char **mnt_opts;
 6540| int *mnt_opts_flags;
 6541| int num_mnt_opts;
 6542|};
 6543|
 6544|static inline void security_init_mnt_opts(struct security_mnt_opts *opts)
 6545|{
 6546| opts->mnt_opts = ((void *)0);
 6547| opts->mnt_opts_flags = ((void *)0);
 6548| opts->num_mnt_opts = 0;
 6549|}
 6550|
 6551|static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
 6552|{
 6553| int i;
 6554| if (opts->mnt_opts)
 6555|  for (i = 0; i < opts->num_mnt_opts; i++)
 6556|   kfree(opts->mnt_opts[i]);
 6557| kfree(opts->mnt_opts);
 6558| opts->mnt_opts = ((void *)0);
 6559| kfree(opts->mnt_opts_flags);
 6560| opts->mnt_opts_flags = ((void *)0);
 6561| opts->num_mnt_opts = 0;
 6562|}
 6563|struct security_operations {
 6564| char name[10 + 1];
 6565|
 6566| int (*ptrace_access_check) (struct task_struct *child, unsigned int mode);
 6567| int (*ptrace_traceme) (struct task_struct *parent);
 6568| int (*capget) (struct task_struct *target,
 6569|         kernel_cap_t *effective,
 6570|         kernel_cap_t *inheritable, kernel_cap_t *permitted);
 6571| int (*capset) (struct cred *new,
 6572|         const struct cred *old,
 6573|         const kernel_cap_t *effective,
 6574|         const kernel_cap_t *inheritable,
 6575|         const kernel_cap_t *permitted);
 6576| int (*capable) (struct task_struct *tsk, const struct cred *cred,
 6577|   int cap, int audit);
 6578| int (*sysctl) (struct ctl_table *table, int op);
 6579| int (*quotactl) (int cmds, int type, int id, struct super_block *sb);
 6580| int (*quota_on) (struct dentry *dentry);
 6581| int (*syslog) (int type);
 6582| int (*settime) (struct timespec *ts, struct timezone *tz);
 6583| int (*vm_enough_memory) (struct mm_struct *mm, long pages);
 6584|
 6585| int (*bprm_set_creds) (struct linux_binprm *bprm);
 6586| int (*bprm_check_security) (struct linux_binprm *bprm);
 6587| int (*bprm_secureexec) (struct linux_binprm *bprm);
 6588| void (*bprm_committing_creds) (struct linux_binprm *bprm);
 6589| void (*bprm_committed_creds) (struct linux_binprm *bprm);
 6590|
 6591| int (*sb_alloc_security) (struct super_block *sb);
 6592| void (*sb_free_security) (struct super_block *sb);
 6593| int (*sb_copy_data) (char *orig, char *copy);
 6594| int (*sb_kern_mount) (struct super_block *sb, int flags, void *data);
 6595| int (*sb_show_options) (struct seq_file *m, struct super_block *sb);
 6596| int (*sb_statfs) (struct dentry *dentry);
 6597| int (*sb_mount) (char *dev_name, struct path *path,
 6598|    char *type, unsigned long flags, void *data);
 6599| int (*sb_umount) (struct vfsmount *mnt, int flags);
 6600| int (*sb_pivotroot) (struct path *old_path,
 6601|        struct path *new_path);
 6602| int (*sb_set_mnt_opts) (struct super_block *sb,
 6603|    struct security_mnt_opts *opts);
 6604| void (*sb_clone_mnt_opts) (const struct super_block *oldsb,
 6605|       struct super_block *newsb);
 6606| int (*sb_parse_opts_str) (char *options, struct security_mnt_opts *opts);
 6607|
 6608|
 6609| int (*path_unlink) (struct path *dir, struct dentry *dentry);
 6610| int (*path_mkdir) (struct path *dir, struct dentry *dentry, int mode);
 6611| int (*path_rmdir) (struct path *dir, struct dentry *dentry);
 6612| int (*path_mknod) (struct path *dir, struct dentry *dentry, int mode,
 6613|      unsigned int dev);
 6614| int (*path_truncate) (struct path *path);
 6615| int (*path_symlink) (struct path *dir, struct dentry *dentry,
 6616|        const char *old_name);
 6617| int (*path_link) (struct dentry *old_dentry, struct path *new_dir,
 6618|     struct dentry *new_dentry);
 6619| int (*path_rename) (struct path *old_dir, struct dentry *old_dentry,
 6620|       struct path *new_dir, struct dentry *new_dentry);
 6621| int (*path_chmod) (struct dentry *dentry, struct vfsmount *mnt,
 6622|      mode_t mode);
 6623| int (*path_chown) (struct path *path, uid_t uid, gid_t gid);
 6624| int (*path_chroot) (struct path *path);
 6625|
 6626|
 6627| int (*inode_alloc_security) (struct inode *inode);
 6628| void (*inode_free_security) (struct inode *inode);
 6629| int (*inode_init_security) (struct inode *inode, struct inode *dir,
 6630|        char **name, void **value, size_t *len);
 6631| int (*inode_create) (struct inode *dir,
 6632|        struct dentry *dentry, int mode);
 6633| int (*inode_link) (struct dentry *old_dentry,
 6634|      struct inode *dir, struct dentry *new_dentry);
 6635| int (*inode_unlink) (struct inode *dir, struct dentry *dentry);
 6636| int (*inode_symlink) (struct inode *dir,
 6637|         struct dentry *dentry, const char *old_name);
 6638| int (*inode_mkdir) (struct inode *dir, struct dentry *dentry, int mode);
 6639| int (*inode_rmdir) (struct inode *dir, struct dentry *dentry);
 6640| int (*inode_mknod) (struct inode *dir, struct dentry *dentry,
 6641|       int mode, dev_t dev);
 6642| int (*inode_rename) (struct inode *old_dir, struct dentry *old_dentry,
 6643|        struct inode *new_dir, struct dentry *new_dentry);
 6644| int (*inode_readlink) (struct dentry *dentry);
 6645| int (*inode_follow_link) (struct dentry *dentry, struct nameidata *nd);
 6646| int (*inode_permission) (struct inode *inode, int mask);
 6647| int (*inode_setattr) (struct dentry *dentry, struct iattr *attr);
 6648| int (*inode_getattr) (struct vfsmount *mnt, struct dentry *dentry);
 6649| int (*inode_setxattr) (struct dentry *dentry, const char *name,
 6650|          const void *value, size_t size, int flags);
 6651| void (*inode_post_setxattr) (struct dentry *dentry, const char *name,
 6652|         const void *value, size_t size, int flags);
 6653| int (*inode_getxattr) (struct dentry *dentry, const char *name);
 6654| int (*inode_listxattr) (struct dentry *dentry);
 6655| int (*inode_removexattr) (struct dentry *dentry, const char *name);
 6656| int (*inode_need_killpriv) (struct dentry *dentry);
 6657| int (*inode_killpriv) (struct dentry *dentry);
 6658| int (*inode_getsecurity) (const struct inode *inode, const char *name, void **buffer, bool alloc);
 6659| int (*inode_setsecurity) (struct inode *inode, const char *name, const void *value, size_t size, int flags);
 6660| int (*inode_listsecurity) (struct inode *inode, char *buffer, size_t buffer_size);
 6661| void (*inode_getsecid) (const struct inode *inode, u32 *secid);
 6662|
 6663| int (*file_permission) (struct file *file, int mask);
 6664| int (*file_alloc_security) (struct file *file);
 6665| void (*file_free_security) (struct file *file);
 6666| int (*file_ioctl) (struct file *file, unsigned int cmd,
 6667|      unsigned long arg);
 6668| int (*file_mmap) (struct file *file,
 6669|     unsigned long reqprot, unsigned long prot,
 6670|     unsigned long flags, unsigned long addr,
 6671|     unsigned long addr_only);
 6672| int (*file_mprotect) (struct vm_area_struct *vma,
 6673|         unsigned long reqprot,
 6674|         unsigned long prot);
 6675| int (*file_lock) (struct file *file, unsigned int cmd);
 6676| int (*file_fcntl) (struct file *file, unsigned int cmd,
 6677|      unsigned long arg);
 6678| int (*file_set_fowner) (struct file *file);
 6679| int (*file_send_sigiotask) (struct task_struct *tsk,
 6680|        struct fown_struct *fown, int sig);
 6681| int (*file_receive) (struct file *file);
 6682| int (*dentry_open) (struct file *file, const struct cred *cred);
 6683|
 6684| int (*task_create) (unsigned long clone_flags);
 6685| int (*cred_alloc_blank) (struct cred *cred, gfp_t gfp);
 6686| void (*cred_free) (struct cred *cred);
 6687| int (*cred_prepare)(struct cred *new, const struct cred *old,
 6688|       gfp_t gfp);
 6689| void (*cred_transfer)(struct cred *new, const struct cred *old);
 6690| int (*kernel_act_as)(struct cred *new, u32 secid);
 6691| int (*kernel_create_files_as)(struct cred *new, struct inode *inode);
 6692| int (*kernel_module_request)(char *kmod_name);
 6693| int (*task_fix_setuid) (struct cred *new, const struct cred *old,
 6694|    int flags);
 6695| int (*task_setpgid) (struct task_struct *p, pid_t pgid);
 6696| int (*task_getpgid) (struct task_struct *p);
 6697| int (*task_getsid) (struct task_struct *p);
 6698| void (*task_getsecid) (struct task_struct *p, u32 *secid);
 6699| int (*task_setnice) (struct task_struct *p, int nice);
 6700| int (*task_setioprio) (struct task_struct *p, int ioprio);
 6701| int (*task_getioprio) (struct task_struct *p);
 6702| int (*task_setrlimit) (struct task_struct *p, unsigned int resource,
 6703|   struct rlimit *new_rlim);
 6704| int (*task_setscheduler) (struct task_struct *p);
 6705| int (*task_getscheduler) (struct task_struct *p);
 6706| int (*task_movememory) (struct task_struct *p);
 6707| int (*task_kill) (struct task_struct *p,
 6708|     struct siginfo *info, int sig, u32 secid);
 6709| int (*task_wait) (struct task_struct *p);
 6710| int (*task_prctl) (int option, unsigned long arg2,
 6711|      unsigned long arg3, unsigned long arg4,
 6712|      unsigned long arg5);
 6713| void (*task_to_inode) (struct task_struct *p, struct inode *inode);
 6714|
 6715| int (*ipc_permission) (struct kern_ipc_perm *ipcp, short flag);
 6716| void (*ipc_getsecid) (struct kern_ipc_perm *ipcp, u32 *secid);
 6717|
 6718| int (*msg_msg_alloc_security) (struct msg_msg *msg);
 6719| void (*msg_msg_free_security) (struct msg_msg *msg);
 6720|
 6721| int (*msg_queue_alloc_security) (struct msg_queue *msq);
 6722| void (*msg_queue_free_security) (struct msg_queue *msq);
 6723| int (*msg_queue_associate) (struct msg_queue *msq, int msqflg);
 6724| int (*msg_queue_msgctl) (struct msg_queue *msq, int cmd);
 6725| int (*msg_queue_msgsnd) (struct msg_queue *msq,
 6726|     struct msg_msg *msg, int msqflg);
 6727| int (*msg_queue_msgrcv) (struct msg_queue *msq,
 6728|     struct msg_msg *msg,
 6729|     struct task_struct *target,
 6730|     long type, int mode);
 6731|
 6732| int (*shm_alloc_security) (struct shmid_kernel *shp);
 6733| void (*shm_free_security) (struct shmid_kernel *shp);
 6734| int (*shm_associate) (struct shmid_kernel *shp, int shmflg);
 6735| int (*shm_shmctl) (struct shmid_kernel *shp, int cmd);
 6736| int (*shm_shmat) (struct shmid_kernel *shp,
 6737|     char *shmaddr, int shmflg);
 6738|
 6739| int (*sem_alloc_security) (struct sem_array *sma);
 6740| void (*sem_free_security) (struct sem_array *sma);
 6741| int (*sem_associate) (struct sem_array *sma, int semflg);
 6742| int (*sem_semctl) (struct sem_array *sma, int cmd);
 6743| int (*sem_semop) (struct sem_array *sma,
 6744|     struct sembuf *sops, unsigned nsops, int alter);
 6745|
 6746| int (*netlink_send) (struct sock *sk, struct sk_buff *skb);
 6747| int (*netlink_recv) (struct sk_buff *skb, int cap);
 6748|
 6749| void (*d_instantiate) (struct dentry *dentry, struct inode *inode);
 6750|
 6751| int (*getprocattr) (struct task_struct *p, char *name, char **value);
 6752| int (*setprocattr) (struct task_struct *p, char *name, void *value, size_t size);
 6753| int (*secid_to_secctx) (u32 secid, char **secdata, u32 *seclen);
 6754| int (*secctx_to_secid) (const char *secdata, u32 seclen, u32 *secid);
 6755| void (*release_secctx) (char *secdata, u32 seclen);
 6756|
 6757| int (*inode_notifysecctx)(struct inode *inode, void *ctx, u32 ctxlen);
 6758| int (*inode_setsecctx)(struct dentry *dentry, void *ctx, u32 ctxlen);
 6759| int (*inode_getsecctx)(struct inode *inode, void **ctx, u32 *ctxlen);
 6760|
 6761|
 6762| int (*unix_stream_connect) (struct socket *sock,
 6763|        struct socket *other, struct sock *newsk);
 6764| int (*unix_may_send) (struct socket *sock, struct socket *other);
 6765|
 6766| int (*socket_create) (int family, int type, int protocol, int kern);
 6767| int (*socket_post_create) (struct socket *sock, int family,
 6768|       int type, int protocol, int kern);
 6769| int (*socket_bind) (struct socket *sock,
 6770|       struct sockaddr *address, int addrlen);
 6771| int (*socket_connect) (struct socket *sock,
 6772|          struct sockaddr *address, int addrlen);
 6773| int (*socket_listen) (struct socket *sock, int backlog);
 6774| int (*socket_accept) (struct socket *sock, struct socket *newsock);
 6775| int (*socket_sendmsg) (struct socket *sock,
 6776|          struct msghdr *msg, int size);
 6777| int (*socket_recvmsg) (struct socket *sock,
 6778|          struct msghdr *msg, int size, int flags);
 6779| int (*socket_getsockname) (struct socket *sock);
 6780| int (*socket_getpeername) (struct socket *sock);
 6781| int (*socket_getsockopt) (struct socket *sock, int level, int optname);
 6782| int (*socket_setsockopt) (struct socket *sock, int level, int optname);
 6783| int (*socket_shutdown) (struct socket *sock, int how);
 6784| int (*socket_sock_rcv_skb) (struct sock *sk, struct sk_buff *skb);
 6785| int (*socket_getpeersec_stream) (struct socket *sock, char *optval, int *optlen, unsigned len);
 6786| int (*socket_getpeersec_dgram) (struct socket *sock, struct sk_buff *skb, u32 *secid);
 6787| int (*sk_alloc_security) (struct sock *sk, int family, gfp_t priority);
 6788| void (*sk_free_security) (struct sock *sk);
 6789| void (*sk_clone_security) (const struct sock *sk, struct sock *newsk);
 6790| void (*sk_getsecid) (struct sock *sk, u32 *secid);
 6791| void (*sock_graft) (struct sock *sk, struct socket *parent);
 6792| int (*inet_conn_request) (struct sock *sk, struct sk_buff *skb,
 6793|      struct request_sock *req);
 6794| void (*inet_csk_clone) (struct sock *newsk, const struct request_sock *req);
 6795| void (*inet_conn_established) (struct sock *sk, struct sk_buff *skb);
 6796| int (*secmark_relabel_packet) (u32 secid);
 6797| void (*secmark_refcount_inc) (void);
 6798| void (*secmark_refcount_dec) (void);
 6799| void (*req_classify_flow) (const struct request_sock *req, struct flowi *fl);
 6800| int (*tun_dev_create)(void);
 6801| void (*tun_dev_post_create)(struct sock *sk);
 6802| int (*tun_dev_attach)(struct sock *sk);
 6803|
 6804|
 6805|
 6806| int (*xfrm_policy_alloc_security) (struct xfrm_sec_ctx **ctxp,
 6807|   struct xfrm_user_sec_ctx *sec_ctx);
 6808| int (*xfrm_policy_clone_security) (struct xfrm_sec_ctx *old_ctx, struct xfrm_sec_ctx **new_ctx);
 6809| void (*xfrm_policy_free_security) (struct xfrm_sec_ctx *ctx);
 6810| int (*xfrm_policy_delete_security) (struct xfrm_sec_ctx *ctx);
 6811| int (*xfrm_state_alloc_security) (struct xfrm_state *x,
 6812|  struct xfrm_user_sec_ctx *sec_ctx,
 6813|  u32 secid);
 6814| void (*xfrm_state_free_security) (struct xfrm_state *x);
 6815| int (*xfrm_state_delete_security) (struct xfrm_state *x);
 6816| int (*xfrm_policy_lookup) (struct xfrm_sec_ctx *ctx, u32 fl_secid, u8 dir);
 6817| int (*xfrm_state_pol_flow_match) (struct xfrm_state *x,
 6818|       struct xfrm_policy *xp,
 6819|       struct flowi *fl);
 6820| int (*xfrm_decode_session) (struct sk_buff *skb, u32 *secid, int ckall);
 6821|
 6822|
 6823|
 6824|
 6825| int (*key_alloc) (struct key *key, const struct cred *cred, unsigned long flags);
 6826| void (*key_free) (struct key *key);
 6827| int (*key_permission) (key_ref_t key_ref,
 6828|          const struct cred *cred,
 6829|          key_perm_t perm);
 6830| int (*key_getsecurity)(struct key *key, char **_buffer);
 6831|
 6832|
 6833|
 6834| int (*audit_rule_init) (u32 field, u32 op, char *rulestr, void **lsmrule);
 6835| int (*audit_rule_known) (struct audit_krule *krule);
 6836| int (*audit_rule_match) (u32 secid, u32 field, u32 op, void *lsmrule,
 6837|     struct audit_context *actx);
 6838| void (*audit_rule_free) (void *lsmrule);
 6839|
 6840|};
 6841|
 6842|
 6843|extern int security_init(void);
 6844|extern int security_module_enable(struct security_operations *ops);
 6845|extern int register_security(struct security_operations *ops);
 6846|
 6847|
 6848|int security_ptrace_access_check(struct task_struct *child, unsigned int mode);
 6849|int security_ptrace_traceme(struct task_struct *parent);
 6850|int security_capget(struct task_struct *target,
 6851|      kernel_cap_t *effective,
 6852|      kernel_cap_t *inheritable,
 6853|      kernel_cap_t *permitted);
 6854|int security_capset(struct cred *new, const struct cred *old,
 6855|      const kernel_cap_t *effective,
 6856|      const kernel_cap_t *inheritable,
 6857|      const kernel_cap_t *permitted);
 6858|int security_capable(int cap);
 6859|int security_real_capable(struct task_struct *tsk, int cap);
 6860|int security_real_capable_noaudit(struct task_struct *tsk, int cap);
 6861|int security_sysctl(struct ctl_table *table, int op);
 6862|int security_quotactl(int cmds, int type, int id, struct super_block *sb);
 6863|int security_quota_on(struct dentry *dentry);
 6864|int security_syslog(int type);
 6865|int security_settime(struct timespec *ts, struct timezone *tz);
 6866|int security_vm_enough_memory(long pages);
 6867|int security_vm_enough_memory_mm(struct mm_struct *mm, long pages);
 6868|int security_vm_enough_memory_kern(long pages);
 6869|int security_bprm_set_creds(struct linux_binprm *bprm);
 6870|int security_bprm_check(struct linux_binprm *bprm);
 6871|void security_bprm_committing_creds(struct linux_binprm *bprm);
 6872|void security_bprm_committed_creds(struct linux_binprm *bprm);
 6873|int security_bprm_secureexec(struct linux_binprm *bprm);
 6874|int security_sb_alloc(struct super_block *sb);
 6875|void security_sb_free(struct super_block *sb);
 6876|int security_sb_copy_data(char *orig, char *copy);
 6877|int security_sb_kern_mount(struct super_block *sb, int flags, void *data);
 6878|int security_sb_show_options(struct seq_file *m, struct super_block *sb);
 6879|int security_sb_statfs(struct dentry *dentry);
 6880|int security_sb_mount(char *dev_name, struct path *path,
 6881|        char *type, unsigned long flags, void *data);
 6882|int security_sb_umount(struct vfsmount *mnt, int flags);
 6883|int security_sb_pivotroot(struct path *old_path, struct path *new_path);
 6884|int security_sb_set_mnt_opts(struct super_block *sb, struct security_mnt_opts *opts);
 6885|void security_sb_clone_mnt_opts(const struct super_block *oldsb,
 6886|    struct super_block *newsb);
 6887|int security_sb_parse_opts_str(char *options, struct security_mnt_opts *opts);
 6888|
 6889|int security_inode_alloc(struct inode *inode);
 6890|void security_inode_free(struct inode *inode);
 6891|int security_inode_init_security(struct inode *inode, struct inode *dir,
 6892|      char **name, void **value, size_t *len);
 6893|int security_inode_create(struct inode *dir, struct dentry *dentry, int mode);
 6894|int security_inode_link(struct dentry *old_dentry, struct inode *dir,
 6895|    struct dentry *new_dentry);
 6896|int security_inode_unlink(struct inode *dir, struct dentry *dentry);
 6897|int security_inode_symlink(struct inode *dir, struct dentry *dentry,
 6898|      const char *old_name);
 6899|int security_inode_mkdir(struct inode *dir, struct dentry *dentry, int mode);
 6900|int security_inode_rmdir(struct inode *dir, struct dentry *dentry);
 6901|int security_inode_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev);
 6902|int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry,
 6903|     struct inode *new_dir, struct dentry *new_dentry);
 6904|int security_inode_readlink(struct dentry *dentry);
 6905|int security_inode_follow_link(struct dentry *dentry, struct nameidata *nd);
 6906|int security_inode_permission(struct inode *inode, int mask);
 6907|int security_inode_setattr(struct dentry *dentry, struct iattr *attr);
 6908|int security_inode_getattr(struct vfsmount *mnt, struct dentry *dentry);
 6909|int security_inode_setxattr(struct dentry *dentry, const char *name,
 6910|       const void *value, size_t size, int flags);
 6911|void security_inode_post_setxattr(struct dentry *dentry, const char *name,
 6912|      const void *value, size_t size, int flags);
 6913|int security_inode_getxattr(struct dentry *dentry, const char *name);
 6914|int security_inode_listxattr(struct dentry *dentry);
 6915|int security_inode_removexattr(struct dentry *dentry, const char *name);
 6916|int security_inode_need_killpriv(struct dentry *dentry);
 6917|int security_inode_killpriv(struct dentry *dentry);
 6918|int security_inode_getsecurity(const struct inode *inode, const char *name, void **buffer, bool alloc);
 6919|int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags);
 6920|int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size);
 6921|void security_inode_getsecid(const struct inode *inode, u32 *secid);
 6922|int security_file_permission(struct file *file, int mask);
 6923|int security_file_alloc(struct file *file);
 6924|void security_file_free(struct file *file);
 6925|int security_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
 6926|int security_file_mmap(struct file *file, unsigned long reqprot,
 6927|   unsigned long prot, unsigned long flags,
 6928|   unsigned long addr, unsigned long addr_only);
 6929|int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot,
 6930|      unsigned long prot);
 6931|int security_file_lock(struct file *file, unsigned int cmd);
 6932|int security_file_fcntl(struct file *file, unsigned int cmd, unsigned long arg);
 6933|int security_file_set_fowner(struct file *file);
 6934|int security_file_send_sigiotask(struct task_struct *tsk,
 6935|     struct fown_struct *fown, int sig);
 6936|int security_file_receive(struct file *file);
 6937|int security_dentry_open(struct file *file, const struct cred *cred);
 6938|int security_task_create(unsigned long clone_flags);
 6939|int security_cred_alloc_blank(struct cred *cred, gfp_t gfp);
 6940|void security_cred_free(struct cred *cred);
 6941|int security_prepare_creds(struct cred *new, const struct cred *old, gfp_t gfp);
 6942|void security_transfer_creds(struct cred *new, const struct cred *old);
 6943|int security_kernel_act_as(struct cred *new, u32 secid);
 6944|int security_kernel_create_files_as(struct cred *new, struct inode *inode);
 6945|int security_kernel_module_request(char *kmod_name);
 6946|int security_task_fix_setuid(struct cred *new, const struct cred *old,
 6947|        int flags);
 6948|int security_task_setpgid(struct task_struct *p, pid_t pgid);
 6949|int security_task_getpgid(struct task_struct *p);
 6950|int security_task_getsid(struct task_struct *p);
 6951|void security_task_getsecid(struct task_struct *p, u32 *secid);
 6952|int security_task_setnice(struct task_struct *p, int nice);
 6953|int security_task_setioprio(struct task_struct *p, int ioprio);
 6954|int security_task_getioprio(struct task_struct *p);
 6955|int security_task_setrlimit(struct task_struct *p, unsigned int resource,
 6956|  struct rlimit *new_rlim);
 6957|int security_task_setscheduler(struct task_struct *p);
 6958|int security_task_getscheduler(struct task_struct *p);
 6959|int security_task_movememory(struct task_struct *p);
 6960|int security_task_kill(struct task_struct *p, struct siginfo *info,
 6961|   int sig, u32 secid);
 6962|int security_task_wait(struct task_struct *p);
 6963|int security_task_prctl(int option, unsigned long arg2, unsigned long arg3,
 6964|   unsigned long arg4, unsigned long arg5);
 6965|void security_task_to_inode(struct task_struct *p, struct inode *inode);
 6966|int security_ipc_permission(struct kern_ipc_perm *ipcp, short flag);
 6967|void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid);
 6968|int security_msg_msg_alloc(struct msg_msg *msg);
 6969|void security_msg_msg_free(struct msg_msg *msg);
 6970|int security_msg_queue_alloc(struct msg_queue *msq);
 6971|void security_msg_queue_free(struct msg_queue *msq);
 6972|int security_msg_queue_associate(struct msg_queue *msq, int msqflg);
 6973|int security_msg_queue_msgctl(struct msg_queue *msq, int cmd);
 6974|int security_msg_queue_msgsnd(struct msg_queue *msq,
 6975|         struct msg_msg *msg, int msqflg);
 6976|int security_msg_queue_msgrcv(struct msg_queue *msq, struct msg_msg *msg,
 6977|         struct task_struct *target, long type, int mode);
 6978|int security_shm_alloc(struct shmid_kernel *shp);
 6979|void security_shm_free(struct shmid_kernel *shp);
 6980|int security_shm_associate(struct shmid_kernel *shp, int shmflg);
 6981|int security_shm_shmctl(struct shmid_kernel *shp, int cmd);
 6982|int security_shm_shmat(struct shmid_kernel *shp, char *shmaddr, int shmflg);
 6983|int security_sem_alloc(struct sem_array *sma);
 6984|void security_sem_free(struct sem_array *sma);
 6985|int security_sem_associate(struct sem_array *sma, int semflg);
 6986|int security_sem_semctl(struct sem_array *sma, int cmd);
 6987|int security_sem_semop(struct sem_array *sma, struct sembuf *sops,
 6988|   unsigned nsops, int alter);
 6989|void security_d_instantiate(struct dentry *dentry, struct inode *inode);
 6990|int security_getprocattr(struct task_struct *p, char *name, char **value);
 6991|int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size);
 6992|int security_netlink_send(struct sock *sk, struct sk_buff *skb);
 6993|int security_netlink_recv(struct sk_buff *skb, int cap);
 6994|int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen);
 6995|int security_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid);
 6996|void security_release_secctx(char *secdata, u32 seclen);
 6997|
 6998|int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen);
 6999|int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen);
 7000|int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen);
 7001|int security_unix_stream_connect(struct socket *sock, struct socket *other,
 7002|     struct sock *newsk);
 7003|int security_unix_may_send(struct socket *sock, struct socket *other);
 7004|int security_socket_create(int family, int type, int protocol, int kern);
 7005|int security_socket_post_create(struct socket *sock, int family,
 7006|    int type, int protocol, int kern);
 7007|int security_socket_bind(struct socket *sock, struct sockaddr *address, int addrlen);
 7008|int security_socket_connect(struct socket *sock, struct sockaddr *address, int addrlen);
 7009|int security_socket_listen(struct socket *sock, int backlog);
 7010|int security_socket_accept(struct socket *sock, struct socket *newsock);
 7011|int security_socket_sendmsg(struct socket *sock, struct msghdr *msg, int size);
 7012|int security_socket_recvmsg(struct socket *sock, struct msghdr *msg,
 7013|       int size, int flags);
 7014|int security_socket_getsockname(struct socket *sock);
 7015|int security_socket_getpeername(struct socket *sock);
 7016|int security_socket_getsockopt(struct socket *sock, int level, int optname);
 7017|int security_socket_setsockopt(struct socket *sock, int level, int optname);
 7018|int security_socket_shutdown(struct socket *sock, int how);
 7019|int security_sock_rcv_skb(struct sock *sk, struct sk_buff *skb);
 7020|int security_socket_getpeersec_stream(struct socket *sock, char *optval,
 7021|          int *optlen, unsigned len);
 7022|int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid);
 7023|int security_sk_alloc(struct sock *sk, int family, gfp_t priority);
 7024|void security_sk_free(struct sock *sk);
 7025|void security_sk_clone(const struct sock *sk, struct sock *newsk);
 7026|void security_sk_classify_flow(struct sock *sk, struct flowi *fl);
 7027|void security_req_classify_flow(const struct request_sock *req, struct flowi *fl);
 7028|void security_sock_graft(struct sock*sk, struct socket *parent);
 7029|int security_inet_conn_request(struct sock *sk,
 7030|   struct sk_buff *skb, struct request_sock *req);
 7031|void security_inet_csk_clone(struct sock *newsk,
 7032|   const struct request_sock *req);
 7033|void security_inet_conn_established(struct sock *sk,
 7034|   struct sk_buff *skb);
 7035|int security_secmark_relabel_packet(u32 secid);
 7036|void security_secmark_refcount_inc(void);
 7037|void security_secmark_refcount_dec(void);
 7038|int security_tun_dev_create(void);
 7039|void security_tun_dev_post_create(struct sock *sk);
 7040|int security_tun_dev_attach(struct sock *sk);
 7041|int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp, struct xfrm_user_sec_ctx *sec_ctx);
 7042|int security_xfrm_policy_clone(struct xfrm_sec_ctx *old_ctx, struct xfrm_sec_ctx **new_ctxp);
 7043|void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx);
 7044|int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx);
 7045|int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx);
 7046|int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
 7047|          struct xfrm_sec_ctx *polsec, u32 secid);
 7048|int security_xfrm_state_delete(struct xfrm_state *x);
 7049|void security_xfrm_state_free(struct xfrm_state *x);
 7050|int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid, u8 dir);
 7051|int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
 7052|           struct xfrm_policy *xp, struct flowi *fl);
 7053|int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid);
 7054|void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl);
 7055|int security_path_unlink(struct path *dir, struct dentry *dentry);
 7056|int security_path_mkdir(struct path *dir, struct dentry *dentry, int mode);
 7057|int security_path_rmdir(struct path *dir, struct dentry *dentry);
 7058|int security_path_mknod(struct path *dir, struct dentry *dentry, int mode,
 7059|   unsigned int dev);
 7060|int security_path_truncate(struct path *path);
 7061|int security_path_symlink(struct path *dir, struct dentry *dentry,
 7062|     const char *old_name);
 7063|int security_path_link(struct dentry *old_dentry, struct path *new_dir,
 7064|         struct dentry *new_dentry);
 7065|int security_path_rename(struct path *old_dir, struct dentry *old_dentry,
 7066|    struct path *new_dir, struct dentry *new_dentry);
 7067|int security_path_chmod(struct dentry *dentry, struct vfsmount *mnt,
 7068|   mode_t mode);
 7069|int security_path_chown(struct path *path, uid_t uid, gid_t gid);
 7070|int security_path_chroot(struct path *path);
 7071|int security_key_alloc(struct key *key, const struct cred *cred, unsigned long flags);
 7072|void security_key_free(struct key *key);
 7073|int security_key_permission(key_ref_t key_ref,
 7074|       const struct cred *cred, key_perm_t perm);
 7075|int security_key_getsecurity(struct key *key, char **_buffer);
 7076|int security_audit_rule_init(u32 field, u32 op, char *rulestr, void **lsmrule);
 7077|int security_audit_rule_known(struct audit_krule *krule);
 7078|int security_audit_rule_match(u32 secid, u32 field, u32 op, void *lsmrule,
 7079|         struct audit_context *actx);
 7080|void security_audit_rule_free(void *lsmrule);
 7081|extern struct dentry *securityfs_create_file(const char *name, mode_t mode,
 7082|          struct dentry *parent, void *data,
 7083|          const struct file_operations *fops);
 7084|extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent);
 7085|extern void securityfs_remove(struct dentry *dentry);
 7086|static inline char *alloc_secdata(void)
 7087|{
 7088| return (char *)get_zeroed_page(((( gfp_t)0x10u) | (( gfp_t)0x40u) | (( gfp_t)0x80u)));
 7089|}
 7090|
 7091|static inline void free_secdata(void *secdata)
 7092|{
 7093| free_pages(((unsigned long)secdata), 0);
 7094|}
 7095|static inline swp_entry_t swp_entry(unsigned long type, unsigned long offset)
 7096|{
 7097| swp_entry_t ret;
 7098|
 7099| ret.val = (type << (sizeof(ret.val) * 8 - 5)) |
 7100|   (offset & ((1UL << (sizeof(ret.val) * 8 - 5)) - 1));
 7101| return ret;
 7102|}
 7103|
 7104|
 7105|
 7106|
 7107|
 7108|static inline unsigned swp_type(swp_entry_t entry)
 7109|{
 7110| return (entry.val >> (sizeof(entry.val) * 8 - 5));
 7111|}
 7112|
 7113|
 7114|
 7115|
 7116|
 7117|static inline unsigned long swp_offset(swp_entry_t entry)
 7118|{
 7119| return entry.val & ((1UL << (sizeof(entry.val) * 8 - 5)) - 1);
 7120|}
 7121|
 7122|
 7123|
 7124|static inline int is_swap_pte(pte_t pte)
 7125|{
 7126| return !pte_none(pte) && !pte_present(pte) && !pte_file(pte);
 7127|}
 7128|
 7129|
 7130|
 7131|
 7132|
 7133|
 7134|static inline swp_entry_t pte_to_swp_entry(pte_t pte)
 7135|{
 7136| swp_entry_t arch_entry;
 7137|
 7138| do { if (__builtin_expect(!!(pte_file(pte)), 0)) do { asm volatile("1:\tud2\n" ".pushsection __bug_table,\"a\"\n" "2:\t.long 1b - 2b, %c0 - 2b\n" "\t.word %c1, 0\n" "\t.org 2b+%c2\n" ".popsection" : : "i" ("/home/l/latest/linux/include/linux/swapops.h"), "i" (61), "i" (sizeof(struct bug_entry))); __builtin_unreachable(); } while (0); } while(0);
 7139| arch_entry = ((swp_entry_t) { pte_val((pte)) });
 7140| return swp_entry((((arch_entry).val >> (0 + 1)) & ((1U << (6 - 0 - 1)) - 1)), ((arch_entry).val >> (8 + 1)));
 7141|}
 7142|
 7143|
 7144|
 7145|
 7146|
 7147|static inline pte_t swp_entry_to_pte(swp_entry_t entry)
 7148|{
 7149| swp_entry_t arch_entry;
 7150|
 7151| arch_entry = ((swp_entry_t) { ((swp_type(entry)) << (0 + 1)) | ((swp_offset(entry)) << (8 + 1)) });
 7152| do { if (__builtin_expect(!!(pte_file(((pte_t) { .pte = (arch_entry).val }))), 0)) do { asm volatile("1:\tud2\n" ".pushsection __bug_table,\"a\"\n" "2:\t.long 1b - 2b, %c0 - 2b\n" "\t.word %c1, 0\n" "\t.org 2b+%c2\n" ".popsection" : : "i" ("/home/l/latest/linux/include/linux/swapops.h"), "i" (75), "i" (sizeof(struct bug_entry))); __builtin_unreachable(); } while (0); } while(0);
 7153| return ((pte_t) { .pte = (arch_entry).val });
 7154|}
 7155|
 7156|
 7157|static inline swp_entry_t make_migration_entry(struct page *page, int write)
 7158|{
 7159| do { if (__builtin_expect(!!(!PageLocked(page)), 0)) do { asm volatile("1:\tud2\n" ".pushsection __bug_table,\"a\"\n" "2:\t.long 1b - 2b, %c0 - 2b\n" "\t.word %c1, 0\n" "\t.org 2b+%c2\n" ".popsection" : : "i" ("/home/l/latest/linux/include/linux/swapops.h"), "i" (82), "i" (sizeof(struct bug_entry))); __builtin_unreachable(); } while (0); } while(0);
 7160| return swp_entry(write ? (((1 << 5) - 2 - 1) + 1 + 1) : (((1 << 5) - 2 - 1) + 1),
 7161|   (unsigned long)((page) - ((struct page *)(0xffffea0000000000UL))));
 7162|}
 7163|
 7164|static inline int is_migration_entry(swp_entry_t entry)
 7165|{
 7166| return __builtin_expect(!!(swp_type(entry) == (((1 << 5) - 2 - 1) + 1) || swp_type(entry) == (((1 << 5) - 2 - 1) + 1 + 1)), 0)
 7167|                                          ;
 7168|}
 7169|
 7170|static inline int is_write_migration_entry(swp_entry_t entry)
 7171|{
 7172| return __builtin_expect(!!(swp_type(entry) == (((1 << 5) - 2 - 1) + 1 + 1)), 0);
 7173|}
 7174|
 7175|static inline struct page *migration_entry_to_page(swp_entry_t entry)
 7176|{
 7177| struct page *p = (((struct page *)(0xffffea0000000000UL)) + (swp_offset(entry)));
 7178|
 7179|
 7180|
 7181|
 7182| do { if (__builtin_expect(!!(!PageLocked(p)), 0)) do { asm volatile("1:\tud2\n" ".pushsection __bug_table,\"a\"\n" "2:\t.long 1b - 2b, %c0 - 2b\n" "\t.word %c1, 0\n" "\t.org 2b+%c2\n" ".popsection" : : "i" ("/home/l/latest/linux/include/linux/swapops.h"), "i" (105), "i" (sizeof(struct bug_entry))); __builtin_unreachable(); } while (0); } while(0);
 7183| return p;
 7184|}
 7185|
 7186|static inline void make_migration_entry_read(swp_entry_t *entry)
 7187|{
 7188| *entry = swp_entry((((1 << 5) - 2 - 1) + 1), swp_offset(*entry));
 7189|}
 7190|
 7191|extern void migration_entry_wait(struct mm_struct *mm, pmd_t *pmd,
 7192|     unsigned long address);
 7193|static inline swp_entry_t make_hwpoison_entry(struct page *page)
 7194|{
 7195| do { if (__builtin_expect(!!(!PageLocked(page)), 0)) do { asm volatile("1:\tud2\n" ".pushsection __bug_table,\"a\"\n" "2:\t.long 1b - 2b, %c0 - 2b\n" "\t.word %c1, 0\n" "\t.org 2b+%c2\n" ".popsection" : : "i" ("/home/l/latest/linux/include/linux/swapops.h"), "i" (140), "i" (sizeof(struct bug_entry))); __builtin_unreachable(); } while (0); } while(0);
 7196| return swp_entry(((1 << 5) - 2 - 1), (unsigned long)((page) - ((struct page *)(0xffffea0000000000UL))));
 7197|}
 7198|
 7199|static inline int is_hwpoison_entry(swp_entry_t entry)
 7200|{
 7201| return swp_type(entry) == ((1 << 5) - 2 - 1);
 7202|}
 7203|static inline int non_swap_entry(swp_entry_t entry)
 7204|{
 7205| return swp_type(entry) >= ((1 << 5) - 2 - 1);
 7206|}
 7207|
 7208|
 7209|
 7210|
 7211|
 7212|
 7213|
 7214|
 7215|struct vfsmount;
 7216|
 7217|struct open_intent {
 7218| int flags;
 7219| int create_mode;
 7220| struct file *file;
 7221|};
 7222|
 7223|enum { MAX_NESTED_LINKS = 8 };
 7224|
 7225|struct nameidata {
 7226| struct path path;
 7227| struct qstr last;
 7228| struct path root;
 7229| unsigned int flags;
 7230| int last_type;
 7231| unsigned depth;
 7232| char *saved_names[MAX_NESTED_LINKS + 1];
 7233|
 7234|
 7235| union {
 7236|  struct open_intent open;
 7237| } intent;
 7238|};
 7239|
 7240|
 7241|
 7242|
 7243|enum {LAST_NORM, LAST_ROOT, LAST_DOT, LAST_DOTDOT, LAST_BIND};
 7244|extern int user_path_at(int, const char *, unsigned, struct path *);
 7245|
 7246|
 7247|
 7248|
 7249|
 7250|
 7251|extern int kern_path(const char *, unsigned, struct path *);
 7252|
 7253|extern int path_lookup(const char *, unsigned, struct nameidata *);
 7254|extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
 7255|      const char *, unsigned int, struct nameidata *);
 7256|
 7257|extern struct file *lookup_instantiate_filp(struct nameidata *nd, struct dentry *dentry,
 7258|  int (*open)(struct inode *, struct file *));
 7259|
 7260|extern struct dentry *lookup_one_len(const char *, struct dentry *, int);
 7261|
 7262|extern int follow_down(struct path *);
 7263|extern int follow_up(struct path *);
 7264|
 7265|extern struct dentry *lock_rename(struct dentry *, struct dentry *);
 7266|extern void unlock_rename(struct dentry *, struct dentry *);
 7267|
 7268|static inline void nd_set_link(struct nameidata *nd, char *path)
 7269|{
 7270| nd->saved_names[nd->depth] = path;
 7271|}
 7272|
 7273|static inline char *nd_get_link(struct nameidata *nd)
 7274|{
 7275| return nd->saved_names[nd->depth];
 7276|}
 7277|
 7278|static inline void nd_terminate_link(void *name, size_t len, size_t maxlen)
 7279|{
 7280| ((char *) name)[({ typeof(len) _min1 = (len); typeof(maxlen) _min2 = (maxlen); (void) (&_min1 == &_min2); _min1 < _min2 ? _min1 : _min2; })] = '\0';
 7281|}
 7282|extern const unsigned char _ctype[];
 7283|static inline unsigned char __tolower(unsigned char c)
 7284|{
 7285| if ((((_ctype[(int)(unsigned char)(c)])&(0x01)) != 0))
 7286|  c -= 'A'-'a';
 7287| return c;
 7288|}
 7289|
 7290|static inline unsigned char __toupper(unsigned char c)
 7291|{
 7292| if ((((_ctype[(int)(unsigned char)(c)])&(0x02)) != 0))
 7293|  c -= 'a'-'A';
 7294| return c;
 7295|}
 7296|
 7297|
 7298|
 7299|
 7300|
 7301|
 7302|typedef struct page *new_page_t(struct page *, unsigned long private, int **);
 7303|
 7304|
 7305|
 7306|
 7307|extern void putback_lru_pages(struct list_head *l);
 7308|extern int migrate_page(struct address_space *,
 7309|   struct page *, struct page *);
 7310|extern int migrate_pages(struct list_head *l, new_page_t x,
 7311|   unsigned long private, int offlining);
 7312|extern int migrate_huge_pages(struct list_head *l, new_page_t x,
 7313|   unsigned long private, int offlining);
 7314|
 7315|extern int fail_migrate_page(struct address_space *,
 7316|   struct page *, struct page *);
 7317|
 7318|extern int migrate_prep(void);
 7319|extern int migrate_prep_local(void);
 7320|extern int migrate_vmas(struct mm_struct *mm,
 7321|  const nodemask_t *from, const nodemask_t *to,
 7322|  unsigned long flags);
 7323|extern void migrate_page_copy(struct page *newpage, struct page *page);
 7324|extern int migrate_huge_page_move_mapping(struct address_space *mapping,
 7325|      struct page *newpage, struct page *page);
 7326|
 7327|struct seq_operations;
 7328|struct file;
 7329|struct path;
 7330|struct inode;
 7331|struct dentry;
 7332|
 7333|struct seq_file {
 7334| char *buf;
 7335| size_t size;
 7336| size_t from;
 7337| size_t count;
 7338| loff_t index;
 7339| loff_t read_pos;
 7340| u64 version;
 7341| struct mutex lock;
 7342| const struct seq_operations *op;
 7343| void *private;
 7344|};
 7345|
 7346|struct seq_operations {
 7347| void * (*start) (struct seq_file *m, loff_t *pos);
 7348| void (*stop) (struct seq_file *m, void *v);
 7349| void * (*next) (struct seq_file *m, void *v, loff_t *pos);
 7350| int (*show) (struct seq_file *m, void *v);
 7351|};
 7352|static inline size_t seq_get_buf(struct seq_file *m, char **bufp)
 7353|{
 7354| do { if (__builtin_expect(!!(m->count > m->size), 0)) do { asm volatile("1:\tud2\n" ".pushsection __bug_table,\"a\"\n" "2:\t.long 1b - 2b, %c0 - 2b\n" "\t.word %c1, 0\n" "\t.org 2b+%c2\n" ".popsection" : : "i" ("/home/l/latest/linux/include/linux/seq_file.h"), "i" (48), "i" (sizeof(struct bug_entry))); __builtin_unreachable(); } while (0); } while(0);
 7355| if (m->count < m->size)
 7356|  *bufp = m->buf + m->count;
 7357| else
 7358|  *bufp = ((void *)0);
 7359|
 7360| return m->size - m->count;
 7361|}
 7362|static inline void seq_commit(struct seq_file *m, int num)
 7363|{
 7364| if (num < 0) {
 7365|  m->count = m->size;
 7366| } else {
 7367|  do { if (__builtin_expect(!!(m->count + num > m->size), 0)) do { asm volatile("1:\tud2\n" ".pushsection __bug_table,\"a\"\n" "2:\t.long 1b - 2b, %c0 - 2b\n" "\t.word %c1, 0\n" "\t.org 2b+%c2\n" ".popsection" : : "i" ("/home/l/latest/linux/include/linux/seq_file.h"), "i" (71), "i" (sizeof(struct bug_entry))); __builtin_unreachable(); } while (0); } while(0);
 7368|  m->count += num;
 7369| }
 7370|}
 7371|
 7372|char *mangle_path(char *s, char *p, char *esc);
 7373|int seq_open(struct file *, const struct seq_operations *);
 7374|ssize_t seq_read(struct file *, char *, size_t, loff_t *);
 7375|loff_t seq_lseek(struct file *, loff_t, int);
 7376|int seq_release(struct inode *, struct file *);
 7377|int seq_escape(struct seq_file *, const char *, const char *);
 7378|int seq_putc(struct seq_file *m, char c);
 7379|int seq_puts(struct seq_file *m, const char *s);
 7380|int seq_write(struct seq_file *seq, const void *data, size_t len);
 7381|
 7382|int seq_printf(struct seq_file *, const char *, ...)
 7383| ;
 7384|
 7385|int seq_path(struct seq_file *, struct path *, char *);
 7386|int seq_dentry(struct seq_file *, struct dentry *, char *);
 7387|int seq_path_root(struct seq_file *m, struct path *path, struct path *root,
 7388|    char *esc);
 7389|int seq_bitmap(struct seq_file *m, const unsigned long *bits,
 7390|       unsigned int nr_bits);
 7391|static inline int seq_cpumask(struct seq_file *m, const struct cpumask *mask)
 7392|{
 7393| return seq_bitmap(m, ((mask)->bits), nr_cpu_ids);
 7394|}
 7395|
 7396|static inline int seq_nodemask(struct seq_file *m, nodemask_t *mask)
 7397|{
 7398| return seq_bitmap(m, mask->bits, (1 << 10));
 7399|}
 7400|
 7401|int seq_bitmap_list(struct seq_file *m, const unsigned long *bits,
 7402|  unsigned int nr_bits);
 7403|
 7404|static inline int seq_cpumask_list(struct seq_file *m,
 7405|       const struct cpumask *mask)
 7406|{
 7407| return seq_bitmap_list(m, ((mask)->bits), nr_cpu_ids);
 7408|}
 7409|
 7410|static inline int seq_nodemask_list(struct seq_file *m, nodemask_t *mask)
 7411|{
 7412| return seq_bitmap_list(m, mask->bits, (1 << 10));
 7413|}
 7414|
 7415|int single_open(struct file *, int (*)(struct seq_file *, void *), void *);
 7416|int single_release(struct inode *, struct file *);
 7417|void *__seq_open_private(struct file *, const struct seq_operations *, int);
 7418|int seq_open_private(struct file *, const struct seq_operations *, int);
 7419|int seq_release_private(struct inode *, struct file *);
 7420|
 7421|
 7422|
 7423|
 7424|
 7425|
 7426|
 7427|extern struct list_head *seq_list_start(struct list_head *head,
 7428|  loff_t pos);
 7429|extern struct list_head *seq_list_start_head(struct list_head *head,
 7430|  loff_t pos);
 7431|extern struct list_head *seq_list_next(void *v, struct list_head *head,
 7432|  loff_t *ppos);
 7433|
 7434|
 7435|
 7436|
 7437|
 7438|extern struct hlist_node *seq_hlist_start(struct hlist_head *head,
 7439|       loff_t pos);
 7440|extern struct hlist_node *seq_hlist_start_head(struct hlist_head *head,
 7441|            loff_t pos);
 7442|extern struct hlist_node *seq_hlist_next(void *v, struct hlist_head *head,
 7443|      loff_t *ppos);
 7444|
 7445|extern struct hlist_node *seq_hlist_start_rcu(struct hlist_head *head,
 7446|           loff_t pos);
 7447|extern struct hlist_node *seq_hlist_start_head_rcu(struct hlist_head *head,
 7448|         loff_t pos);
 7449|extern struct hlist_node *seq_hlist_next_rcu(void *v,
 7450|         struct hlist_head *head,
 7451|         loff_t *ppos);
 7452|enum sgp_type {
 7453| SGP_READ,
 7454| SGP_CACHE,
 7455| SGP_DIRTY,
 7456| SGP_WRITE,
 7457|};
 7458|
 7459|
 7460|static unsigned long shmem_default_max_blocks(void)
 7461|{
 7462| return totalram_pages / 2;
 7463|}
 7464|
 7465|static unsigned long shmem_default_max_inodes(void)
 7466|{
 7467| return ({ typeof(totalram_pages - 0UL) _min1 = (totalram_pages - 0UL); typeof(totalram_pages / 2) _min2 = (totalram_pages / 2); (void) (&_min1 == &_min2); _min1 < _min2 ? _min1 : _min2; });
 7468|}
 7469|
 7470|
 7471|static int shmem_getpage(struct inode *inode, unsigned long idx,
 7472|    struct page **pagep, enum sgp_type sgp, int *type);
 7473|
 7474|static inline struct page *shmem_dir_alloc(gfp_t gfp_mask)
 7475|{
 7476|
 7477|
 7478|
 7479|
 7480|
 7481|
 7482|
 7483| return alloc_pages((gfp_mask & ~((( gfp_t)0x80000u)|(( gfp_t)0x08u))) | (( gfp_t)0x8000u),
 7484|    12 -12);
 7485|}
 7486|
 7487|static inline void shmem_dir_free(struct page *page)
 7488|{
 7489| __free_pages(page, 12 -12);
 7490|}
 7491|
 7492|static struct page **shmem_dir_map(struct page *page)
 7493|{
 7494| return (struct page **)__kmap_atomic(page);
     |not affected ==> the lock is still locked. prev next
 7495|}
     |not affected ==> the lock is still locked. prev next
 7496|
 7497|static inline void shmem_dir_unmap(struct page **dir)
 7498|{
 7499| do { ((void)(sizeof(struct { int:-!!(0); }))); __kunmap_atomic(dir); } while (0);
     |not affected ==> the lock is still locked. prev next
 7500|}
     |not affected ==> the lock is still locked. prev next
 7501|
 7502|static swp_entry_t *shmem_swp_map(struct page *page)
 7503|{
 7504| return (swp_entry_t *)__kmap_atomic(page);
 7505|}
 7506|
 7507|static inline void shmem_swp_balance_unmap(void)
 7508|{
 7509|
 7510|
 7511|
 7512|
 7513|
 7514|
 7515|
 7516| (void) __kmap_atomic(((((struct page *)(0xffffea0000000000UL)) + (__phys_addr((unsigned long)(empty_zero_page)) >> 12))));
 7517|}
 7518|
 7519|static inline void shmem_swp_unmap(swp_entry_t *entry)
 7520|{
 7521| do { ((void)(sizeof(struct { int:-!!(0); }))); __kunmap_atomic(entry); } while (0);
 7522|}
 7523|
 7524|static inline struct shmem_sb_info *SHMEM_SB(struct super_block *sb)
 7525|{
 7526| return sb->s_fs_info;
 7527|}
 7528|
 7529|
 7530|
 7531|
 7532|
 7533|
 7534|
 7535|static inline int shmem_acct_size(unsigned long flags, loff_t size)
 7536|{
 7537| return (flags & 0x00200000) ?
 7538|  0 : security_vm_enough_memory_kern(((((size)+((1UL) << 12)-1)&(~(((1UL) << 12)-1))) >> 12));
 7539|}
 7540|
 7541|static inline void shmem_unacct_size(unsigned long flags, loff_t size)
 7542|{
 7543| if (!(flags & 0x00200000))
 7544|  vm_unacct_memory(((((size)+((1UL) << 12)-1)&(~(((1UL) << 12)-1))) >> 12));
 7545|}
 7546|
 7547|
 7548|
 7549|
 7550|
 7551|
 7552|
 7553|static inline int shmem_acct_block(unsigned long flags)
 7554|{
 7555| return (flags & 0x00200000) ?
 7556|  security_vm_enough_memory_kern(((((((1UL) << 12))+((1UL) << 12)-1)&(~(((1UL) << 12)-1))) >> 12)) : 0;
 7557|}
 7558|
 7559|static inline void shmem_unacct_blocks(unsigned long flags, long pages)
 7560|{
 7561| if (flags & 0x00200000)
 7562|  vm_unacct_memory(pages * ((((((1UL) << 12))+((1UL) << 12)-1)&(~(((1UL) << 12)-1))) >> 12));
 7563|}
 7564|
 7565|static const struct super_operations shmem_ops;
 7566|static const struct address_space_operations shmem_aops;
 7567|static const struct file_operations shmem_file_operations;
 7568|static const struct inode_operations shmem_inode_operations;
 7569|static const struct inode_operations shmem_dir_inode_operations;
 7570|static const struct inode_operations shmem_special_inode_operations;
 7571|static const struct vm_operations_struct shmem_vm_ops;
 7572|
 7573|static struct backing_dev_info shmem_backing_dev_info = {
 7574| .ra_pages = 0,
 7575| .capabilities = (0x00000002 | 0x00000001 | 0x00000080) | 0x00000100,
 7576| .unplug_io_fn = default_unplug_io_fn,
 7577|};
 7578|
 7579|static struct list_head shmem_swaplist = { &(shmem_swaplist), &(shmem_swaplist) };
 7580|static struct mutex shmem_swaplist_mutex = { .count = { (1) } , .wait_lock = (spinlock_t ) { { .rlock = { .raw_lock = { 0 }, .magic = 0xdead4ead, .owner_cpu = -1, .owner = ((void *)-1L), .dep_map = { .name = "shmem_swaplist_mutex.wait_lock" } } } } , .wait_list = { &(shmem_swaplist_mutex.wait_list), &(shmem_swaplist_mutex.wait_list) } , .magic = &shmem_swaplist_mutex , .dep_map = { .name = "shmem_swaplist_mutex" } };
 7581|
 7582|static void shmem_free_blocks(struct inode *inode, long pages)
 7583|{
 7584| struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb);
 7585| if (sbinfo->max_blocks) {
 7586|  percpu_counter_add(&sbinfo->used_blocks, -pages);
 7587|  __st_spin_lock_st__(&inode->i_lock);
 7588|  inode->i_blocks -= pages*(((1UL) << 12)/512);
 7589|  __st_spin_unlock_st__(&inode->i_lock);
 7590| }
 7591|}
 7592|
 7593|static int shmem_reserve_inode(struct super_block *sb)
 7594|{
 7595| struct shmem_sb_info *sbinfo = SHMEM_SB(sb);
 7596| if (sbinfo->max_inodes) {
 7597|  __st_spin_lock_st__(&sbinfo->stat_lock);
 7598|  if (!sbinfo->free_inodes) {
 7599|   __st_spin_unlock_st__(&sbinfo->stat_lock);
 7600|   return -28;
 7601|  }
 7602|  sbinfo->free_inodes--;
 7603|  __st_spin_unlock_st__(&sbinfo->stat_lock);
 7604| }
 7605| return 0;
 7606|}
 7607|
 7608|static void shmem_free_inode(struct super_block *sb)
 7609|{
 7610| struct shmem_sb_info *sbinfo = SHMEM_SB(sb);
 7611| if (sbinfo->max_inodes) {
 7612|  __st_spin_lock_st__(&sbinfo->stat_lock);
 7613|  sbinfo->free_inodes++;
 7614|  __st_spin_unlock_st__(&sbinfo->stat_lock);
 7615| }
 7616|}
 7617|static void shmem_recalc_inode(struct inode *inode)
 7618|{
 7619| struct shmem_inode_info *info = SHMEM_I(inode);
 7620| long freed;
 7621|
 7622| freed = info->alloced - info->swapped - inode->i_mapping->nrpages;
 7623| if (freed > 0) {
 7624|  info->alloced -= freed;
 7625|  shmem_unacct_blocks(info->flags, freed);
 7626|  shmem_free_blocks(inode, freed);
 7627| }
 7628|}
 7629|static swp_entry_t *shmem_swp_entry(struct shmem_inode_info *info, unsigned long index, struct page **page)
 7630|{
 7631| unsigned long offset;
 7632| struct page **dir;
 7633| struct page *subdir;
 7634|
 7635| if (index < 16) {
 7636|  shmem_swp_balance_unmap();
 7637|  return info->i_direct+index;
 7638| }
 7639| if (!info->i_indirect) {
 7640|  if (page) {
 7641|   info->i_indirect = *page;
 7642|   *page = ((void *)0);
 7643|  }
 7644|  return ((void *)0);
 7645| }
 7646|
 7647| index -= 16;
 7648| offset = index % (((1UL) << 12)/sizeof(unsigned long));
 7649| index /= (((1UL) << 12)/sizeof(unsigned long));
 7650| dir = shmem_dir_map(info->i_indirect);
 7651|
 7652| if (index >= (((1UL) << 12)/sizeof(unsigned long))/2) {
 7653|  index -= (((1UL) << 12)/sizeof(unsigned long))/2;
 7654|  dir += (((1UL) << 12)/sizeof(unsigned long))/2 + index/(((1UL) << 12)/sizeof(unsigned long));
 7655|  index %= (((1UL) << 12)/sizeof(unsigned long));
 7656|  subdir = *dir;
 7657|  if (!subdir) {
 7658|   if (page) {
 7659|    *dir = *page;
 7660|    *page = ((void *)0);
 7661|   }
 7662|   shmem_dir_unmap(dir);
 7663|   return ((void *)0);
 7664|  }
 7665|  shmem_dir_unmap(dir);
 7666|  dir = shmem_dir_map(subdir);
 7667| }
 7668|
 7669| dir += index;
 7670| subdir = *dir;
 7671| if (!subdir) {
 7672|  if (!page || !(subdir = *page)) {
 7673|   shmem_dir_unmap(dir);
 7674|   return ((void *)0);
 7675|  }
 7676|  *dir = subdir;
 7677|  *page = ((void *)0);
 7678| }
 7679| shmem_dir_unmap(dir);
 7680| return shmem_swp_map(subdir) + offset;
 7681|}
 7682|
 7683|static void shmem_swp_set(struct shmem_inode_info *info, swp_entry_t *entry, unsigned long value)
 7684|{
 7685| long incdec = value? 1: -1;
 7686|
 7687| entry->val = value;
 7688| info->swapped += incdec;
 7689| if ((unsigned long)(entry - info->i_direct) >= 16) {
 7690|  struct page *page = (((struct page *)(0xffffea0000000000UL)) + (__phys_addr((unsigned long)(entry)) >> 12));
 7691|  ((page)->private = (((page)->private) + incdec));
 7692| }
 7693|}
 7694|static swp_entry_t *shmem_swp_alloc(struct shmem_inode_info *info, unsigned long index, enum sgp_type sgp)
 7695|{
 7696| struct inode *inode = &info->vfs_inode;
 7697| struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb);
 7698| struct page *page = ((void *)0);
 7699| swp_entry_t *entry;
 7700|
 7701| if (sgp != SGP_WRITE &&
 7702|     ((loff_t) index << 12) >= i_size_read(inode))
 7703|  return ERR_PTR(-22);
 7704|
 7705| while (!(entry = shmem_swp_entry(info, index, &page))) {
 7706|  if (sgp == SGP_READ)
 7707|   return shmem_swp_map(((((struct page *)(0xffffea0000000000UL)) + (__phys_addr((unsigned long)(empty_zero_page)) >> 12))));
 7708|
 7709|
 7710|
 7711|
 7712|
 7713|  if (sbinfo->max_blocks) {
 7714|   if (percpu_counter_compare(&sbinfo->used_blocks, (sbinfo->max_blocks - 1)) > 0)
 7715|    return ERR_PTR(-28);
 7716|   percpu_counter_inc(&sbinfo->used_blocks);
 7717|   __st_spin_lock_st__(&inode->i_lock);
 7718|   inode->i_blocks += (((1UL) << 12)/512);
 7719|   __st_spin_unlock_st__(&inode->i_lock);
 7720|  }
 7721|
 7722|  __st_spin_unlock_st__(&info->lock);
 7723|  page = shmem_dir_alloc(mapping_gfp_mask(inode->i_mapping));
 7724|  __st_spin_lock_st__(&info->lock);
 7725|
 7726|  if (!page) {
 7727|   shmem_free_blocks(inode, 1);
 7728|   return ERR_PTR(-12);
 7729|  }
 7730|  if (sgp != SGP_WRITE &&
 7731|      ((loff_t) index << 12) >= i_size_read(inode)) {
 7732|   entry = ERR_PTR(-22);
 7733|   break;
 7734|  }
 7735|  if (info->next_index <= index)
 7736|   info->next_index = index + 1;
 7737| }
 7738| if (page) {
 7739|
 7740|  shmem_free_blocks(inode, 1);
 7741|  shmem_dir_free(page);
 7742| }
 7743| if (info->next_index <= index && !IS_ERR(entry))
 7744|  info->next_index = index + 1;
 7745| return entry;
 7746|}
 7747|
 7748|
 7749|
 7750|
 7751|
 7752|
 7753|
 7754|static int shmem_free_swp(swp_entry_t *dir, swp_entry_t *edir,
 7755|      spinlock_t *punch_lock)
 7756|{
 7757| spinlock_t *punch_unlock = ((void *)0);
 7758| swp_entry_t *ptr;
 7759| int freed = 0;
 7760|
 7761| for (ptr = dir; ptr < edir; ptr++) {
 7762|  if (ptr->val) {
 7763|   if (punch_lock) {
 7764|    punch_unlock = punch_lock;
 7765|    punch_lock = ((void *)0);
 7766|    __st_spin_lock_st__(punch_unlock);
 7767|    if (!ptr->val)
 7768|     continue;
 7769|   }
 7770|   free_swap_and_cache(*ptr);
 7771|   *ptr = (swp_entry_t){0};
 7772|   freed++;
 7773|  }
 7774| }
 7775| if (punch_unlock)
 7776|  __st_spin_unlock_st__(punch_unlock);
 7777| return freed;
 7778|}
 7779|
 7780|static int shmem_map_and_free_swp(struct page *subdir, int offset,
 7781|  int limit, struct page ***dir, spinlock_t *punch_lock)
 7782|{
 7783| swp_entry_t *ptr;
 7784| int freed = 0;
 7785|
 7786| ptr = shmem_swp_map(subdir);
 7787| for (; offset < limit; offset += 64) {
 7788|  int size = limit - offset;
 7789|  if (size > 64)
 7790|   size = 64;
 7791|  freed += shmem_free_swp(ptr+offset, ptr+offset+size,
 7792|       punch_lock);
 7793|  if (need_resched()) {
 7794|   shmem_swp_unmap(ptr);
 7795|   if (*dir) {
 7796|    shmem_dir_unmap(*dir);
 7797|    *dir = ((void *)0);
 7798|   }
 7799|   ({ __might_sleep("mm/.tmp_shmem.o.armored.c", 510, 0); _cond_resched(); });
 7800|   ptr = shmem_swp_map(subdir);
 7801|  }
 7802| }
 7803| shmem_swp_unmap(ptr);
 7804| return freed;
 7805|}
 7806|
 7807|static void shmem_free_pages(struct list_head *next)
 7808|{
 7809| struct page *page;
 7810| int freed = 0;
 7811|
 7812| do {
 7813|  page = ({ const typeof( ((struct page *)0)->lru ) *__mptr = (next); (struct page *)( (char *)__mptr - 1 );});
 7814|  next = next->next;
 7815|  shmem_dir_free(page);
 7816|  freed++;
 7817|  if (freed >= 64) {
 7818|   ({ __might_sleep("mm/.tmp_shmem.o.armored.c", 529, 0); _cond_resched(); });
 7819|   freed = 0;
 7820|  }
 7821| } while (next);
 7822|}
 7823|
 7824|static void shmem_truncate_range(struct inode *inode, loff_t start, loff_t end)
 7825|{
 7826| struct shmem_inode_info *info = SHMEM_I(inode);
 7827| unsigned long idx;
 7828| unsigned long size;
 7829| unsigned long limit;
 7830| unsigned long stage;
 7831| unsigned long diroff;
 7832| struct page **dir;
 7833| struct page *topdir;
 7834| struct page *middir;
 7835| struct page *subdir;
 7836| swp_entry_t *ptr;
 7837| struct list_head pages_to_free = { &(pages_to_free), &(pages_to_free) };
 7838| long nr_pages_to_free = 0;
 7839| long nr_swaps_freed = 0;
 7840| int offset;
 7841| int freed;
 7842| int punch_hole;
 7843| spinlock_t *needs_lock;
 7844| spinlock_t *punch_lock;
 7845| unsigned long upper_limit;
 7846|
 7847| inode->i_ctime = inode->i_mtime = (current_kernel_time());
 7848| idx = (start + ((1UL) << 12) - 1) >> 12;
 7849| if (idx >= info->next_index)
 7850|  return;
 7851|
 7852| __st_spin_lock_st__(&info->lock);
 7853| info->flags |= 0x00000002;
 7854| if (end == (loff_t) -1) {
 7855|  limit = info->next_index;
 7856|  upper_limit = ((unsigned long)((({ unsigned long long __min1 = (((16 + (((unsigned long long)(((1UL) << 12)/sizeof(unsigned long))*(((1UL) << 12)/sizeof(unsigned long)))/2) * ((((1UL) << 12)/sizeof(unsigned long))+1)) << 12)); unsigned long long __min2 = (0x7fffffffffffffffUL); __min1 < __min2 ? __min1: __min2; })+1) >> 12));
 7857|  info->next_index = idx;
 7858|  needs_lock = ((void *)0);
 7859|  punch_hole = 0;
 7860| } else {
 7861|  if (end + 1 >= inode->i_size) {
 7862|   limit = (inode->i_size + ((1UL) << 12) - 1) >>
 7863|       12;
 7864|   upper_limit = ((unsigned long)((({ unsigned long long __min1 = (((16 + (((unsigned long long)(((1UL) << 12)/sizeof(unsigned long))*(((1UL) << 12)/sizeof(unsigned long)))/2) * ((((1UL) << 12)/sizeof(unsigned long))+1)) << 12)); unsigned long long __min2 = (0x7fffffffffffffffUL); __min1 < __min2 ? __min1: __min2; })+1) >> 12));
 7865|  } else {
 7866|   limit = (end + 1) >> 12;
 7867|   upper_limit = limit;
 7868|  }
 7869|  needs_lock = &info->lock;
 7870|  punch_hole = 1;
 7871| }
 7872|
 7873| topdir = info->i_indirect;
 7874| if (topdir && idx <= 16 && !punch_hole) {
 7875|  info->i_indirect = ((void *)0);
 7876|  nr_pages_to_free++;
 7877|  list_add(&topdir->lru, &pages_to_free);
 7878| }
 7879| __st_spin_unlock_st__(&info->lock);
 7880|
 7881| if (info->swapped && idx < 16) {
 7882|  ptr = info->i_direct;
 7883|  size = limit;
 7884|  if (size > 16)
 7885|   size = 16;
 7886|  nr_swaps_freed = shmem_free_swp(ptr+idx, ptr+size, needs_lock);
 7887| }
 7888|
 7889|
 7890|
 7891|
 7892|
 7893| if (!topdir || limit <= 16)
 7894|  goto done2;
 7895| upper_limit -= 16;
 7896| limit -= 16;
 7897| idx = (idx > 16)? (idx - 16): 0;
 7898| offset = idx % (((1UL) << 12)/sizeof(unsigned long));
 7899| idx -= offset;
 7900|
 7901| dir = shmem_dir_map(topdir);
 7902| stage = ((unsigned long long)(((1UL) << 12)/sizeof(unsigned long))*(((1UL) << 12)/sizeof(unsigned long)))/2;
 7903| if (idx < ((unsigned long long)(((1UL) << 12)/sizeof(unsigned long))*(((1UL) << 12)/sizeof(unsigned long)))/2) {
 7904|  middir = topdir;
 7905|  diroff = idx/(((1UL) << 12)/sizeof(unsigned long));
 7906| } else {
 7907|  dir += (((1UL) << 12)/sizeof(unsigned long))/2;
 7908|  dir += (idx - ((unsigned long long)(((1UL) << 12)/sizeof(unsigned long))*(((1UL) << 12)/sizeof(unsigned long)))/2)/((unsigned long long)(((1UL) << 12)/sizeof(unsigned long))*(((1UL) << 12)/sizeof(unsigned long)));
 7909|  while (stage <= idx)
 7910|   stage += ((unsigned long long)(((1UL) << 12)/sizeof(unsigned long))*(((1UL) << 12)/sizeof(unsigned long)));
 7911|  middir = *dir;
 7912|  if (*dir) {
 7913|   diroff = ((idx - ((unsigned long long)(((1UL) << 12)/sizeof(unsigned long))*(((1UL) << 12)/sizeof(unsigned long)))/2) %
 7914|    ((unsigned long long)(((1UL) << 12)/sizeof(unsigned long))*(((1UL) << 12)/sizeof(unsigned long)))) / (((1UL) << 12)/sizeof(unsigned long));
 7915|   if (!diroff && !offset && upper_limit >= stage) {
 7916|    if (needs_lock) {
 7917|     __st_spin_lock_st__(needs_lock);
 7918|     *dir = ((void *)0);
 7919|     __st_spin_unlock_st__(needs_lock);
 7920|     needs_lock = ((void *)0);
 7921|    } else
 7922|     *dir = ((void *)0);
 7923|    nr_pages_to_free++;
 7924|    list_add(&middir->lru, &pages_to_free);
 7925|   }
 7926|   shmem_dir_unmap(dir);
 7927|   dir = shmem_dir_map(middir);
 7928|  } else {
 7929|   diroff = 0;
 7930|   offset = 0;
 7931|   idx = stage;
 7932|  }
 7933| }
 7934|
 7935| for (; idx < limit; idx += (((1UL) << 12)/sizeof(unsigned long)), diroff++) {
 7936|  if (idx == stage) {
 7937|   shmem_dir_unmap(dir);
 7938|   dir = shmem_dir_map(topdir) +
 7939|       (((1UL) << 12)/sizeof(unsigned long))/2 + idx/((unsigned long long)(((1UL) << 12)/sizeof(unsigned long))*(((1UL) << 12)/sizeof(unsigned long)));
 7940|   while (!*dir) {
 7941|    dir++;
 7942|    idx += ((unsigned long long)(((1UL) << 12)/sizeof(unsigned long))*(((1UL) << 12)/sizeof(unsigned long)));
 7943|    if (idx >= limit)
 7944|     goto done1;
 7945|   }
 7946|   stage = idx + ((unsigned long long)(((1UL) << 12)/sizeof(unsigned long))*(((1UL) << 12)/sizeof(unsigned long)));
 7947|   middir = *dir;
 7948|   if (punch_hole)
 7949|    needs_lock = &info->lock;
 7950|   if (upper_limit >= stage) {
 7951|    if (needs_lock) {
 7952|     __st_spin_lock_st__(needs_lock);
 7953|     *dir = ((void *)0);
 7954|     __st_spin_unlock_st__(needs_lock);
 7955|     needs_lock = ((void *)0);
 7956|    } else
 7957|     *dir = ((void *)0);
 7958|    nr_pages_to_free++;
 7959|    list_add(&middir->lru, &pages_to_free);
 7960|   }
 7961|   shmem_dir_unmap(dir);
 7962|   ({ __might_sleep("mm/.tmp_shmem.o.armored.c", 687, 0); _cond_resched(); });
 7963|   dir = shmem_dir_map(middir);
 7964|   diroff = 0;
 7965|  }
 7966|  punch_lock = needs_lock;
 7967|  subdir = dir[diroff];
 7968|  if (subdir && !offset && upper_limit-idx >= (((1UL) << 12)/sizeof(unsigned long))) {
 7969|   if (needs_lock) {
 7970|    __st_spin_lock_st__(needs_lock);
 7971|    dir[diroff] = ((void *)0);
 7972|    __st_spin_unlock_st__(needs_lock);
 7973|    punch_lock = ((void *)0);
 7974|   } else
 7975|    dir[diroff] = ((void *)0);
 7976|   nr_pages_to_free++;
 7977|   list_add(&subdir->lru, &pages_to_free);
 7978|  }
 7979|  if (subdir && ((subdir)->private) ) {
 7980|   size = limit - idx;
 7981|   if (size > (((1UL) << 12)/sizeof(unsigned long)))
 7982|    size = (((1UL) << 12)/sizeof(unsigned long));
 7983|   freed = shmem_map_and_free_swp(subdir,
 7984|     offset, size, &dir, punch_lock);
 7985|   if (!dir)
 7986|    dir = shmem_dir_map(middir);
 7987|   nr_swaps_freed += freed;
 7988|   if (offset || punch_lock) {
 7989|    __st_spin_lock_st__(&info->lock);
 7990|    ((subdir)->private = (((subdir)->private) - freed))
 7991|                                  ;
 7992|    __st_spin_unlock_st__(&info->lock);
 7993|   } else
 7994|    __st_BUG_ON_st__(((subdir)->private) != freed);
 7995|  }
 7996|  offset = 0;
 7997| }
 7998|done1:
 7999| shmem_dir_unmap(dir);
 8000|done2:
 8001| if (inode->i_mapping->nrpages && (info->flags & 0x00000001)) {
 8002|  truncate_inode_pages_range(inode->i_mapping, start, end);
 8003|  if (punch_hole)
 8004|   unmap_mapping_range(inode->i_mapping, start,
 8005|       end - start, 1);
 8006| }
 8007|
 8008| __st_spin_lock_st__(&info->lock);
 8009| info->flags &= ~0x00000002;
 8010| info->swapped -= nr_swaps_freed;
 8011| if (nr_pages_to_free)
 8012|  shmem_free_blocks(inode, nr_pages_to_free);
 8013| shmem_recalc_inode(inode);
 8014| __st_spin_unlock_st__(&info->lock);
 8015|
 8016|
 8017|
 8018|
 8019| if (!list_empty(&pages_to_free)) {
 8020|  pages_to_free.prev->next = ((void *)0);
 8021|  shmem_free_pages(pages_to_free.next);
 8022| }
 8023|}
 8024|
 8025|static int shmem_notify_change(struct dentry *dentry, struct iattr *attr)
 8026|{
 8027| struct inode *inode = dentry->d_inode;
 8028| loff_t newsize = attr->ia_size;
 8029| int error;
 8030|
 8031| error = inode_change_ok(inode, attr);
 8032| if (error)
 8033|  return error;
 8034|
 8035| if ((((inode->i_mode) & 00170000) == 0100000) && (attr->ia_valid & (1 << 3))
 8036|     && newsize != inode->i_size) {
 8037|  struct page *page = ((void *)0);
 8038|
 8039|  if (newsize < inode->i_size) {
 8040|
 8041|
 8042|
 8043|
 8044|
 8045|
 8046|
 8047|   if (newsize & (((1UL) << 12)-1)) {
 8048|    (void) shmem_getpage(inode,
 8049|     newsize >> 12,
 8050|      &page, SGP_READ, ((void *)0));
 8051|    if (page)
 8052|     unlock_page(page);
 8053|   }
 8054|
 8055|
 8056|
 8057|
 8058|
 8059|
 8060|
 8061|   if (newsize) {
 8062|    struct shmem_inode_info *info = SHMEM_I(inode);
 8063|    __st_spin_lock_st__(&info->lock);
 8064|    info->flags &= ~0x00000001;
 8065|    __st_spin_unlock_st__(&info->lock);
 8066|   }
 8067|  }
 8068|
 8069|
 8070|  truncate_setsize(inode, newsize);
 8071|  if (page)
 8072|   put_page(page);
 8073|  shmem_truncate_range(inode, newsize, (loff_t)-1);
 8074| }
 8075|
 8076| setattr_copy(inode, attr);
 8077|
 8078| if (attr->ia_valid & (1 << 0))
 8079|  error = generic_acl_chmod(inode);
 8080|
 8081| return error;
 8082|}
 8083|
 8084|static void shmem_evict_inode(struct inode *inode)
 8085|{
 8086| struct shmem_inode_info *info = SHMEM_I(inode);
 8087|
 8088| if (inode->i_mapping->a_ops == &shmem_aops) {
 8089|  truncate_inode_pages(inode->i_mapping, 0);
 8090|  shmem_unacct_size(info->flags, inode->i_size);
 8091|  inode->i_size = 0;
 8092|  shmem_truncate_range(inode, 0, (loff_t)-1);
 8093|  if (!list_empty(&info->swaplist)) {
 8094|   __st_mutex_lock_st__(&shmem_swaplist_mutex);
 8095|   list_del_init(&info->swaplist);
 8096|   __st_mutex_unlock_st__(&shmem_swaplist_mutex);
 8097|  }
 8098| }
 8099| __st_BUG_ON_st__(inode->i_blocks);
 8100| shmem_free_inode(inode->i_sb);
 8101| end_writeback(inode);
 8102|}
 8103|
 8104|static inline int shmem_find_swp(swp_entry_t entry, swp_entry_t *dir, swp_entry_t *edir)
 8105|{
 8106| swp_entry_t *ptr;
 8107|
 8108| for (ptr = dir; ptr < edir; ptr++) {
     |not affected ==> the lock is still locked. prev next
 8109|  if (ptr->val == entry.val)
     |not affected ==> the lock is still locked. prev next
 8110|   return ptr - dir;
     |not affected ==> the lock is still locked. prev next
 8111| }
 8112| return -1;
 8113|}
     |not affected ==> the lock is still locked. prev next
 8114|
 8115|static int shmem_unuse_inode(struct shmem_inode_info *info, swp_entry_t entry, struct page *page)
 8116|{
 8117| struct inode *inode;
 8118| unsigned long idx;
 8119| unsigned long size;
 8120| unsigned long limit;
 8121| unsigned long stage;
 8122| struct page **dir;
 8123| struct page *subdir;
 8124| swp_entry_t *ptr;
 8125| int offset;
 8126| int error;
 8127|
 8128| idx = 0;
     |not affected ==> the lock is still locked. prev next
 8129| ptr = info->i_direct;
     |not affected ==> the lock is still locked. prev next
 8130| __st_spin_lock_st__(&info->lock);
     |not affected ==> the lock is still locked. prev next
 8131| if (!info->swapped) {
     |not affected ==> the lock is still locked. prev next
 8132|  list_del_init(&info->swaplist);
 8133|  goto lost2;
 8134| }
 8135| limit = info->next_index;
     |not affected ==> the lock is still locked. prev next
 8136| size = limit;
     |not affected ==> the lock is still locked. prev next
 8137| if (size > 16)
     |not affected ==> the lock is still locked. prev next
 8138|  size = 16;
 8139| offset = shmem_find_swp(entry, ptr, ptr+size);
     |not affected ==> the lock is still locked. prev next
 8140| if (offset >= 0)
     |not affected ==> the lock is still locked. prev next
 8141|  goto found;
 8142| if (!info->i_indirect)
     |not affected ==> the lock is still locked. prev next
 8143|  goto lost2;
 8144|
 8145| dir = shmem_dir_map(info->i_indirect);
     |not affected ==> the lock is still locked. prev next
 8146| stage = 16 + ((unsigned long long)(((1UL) << 12)/sizeof(unsigned long))*(((1UL) << 12)/sizeof(unsigned long)))/2;
     |not affected ==> the lock is still locked. prev next
 8147|
 8148| for (idx = 16; idx < limit; idx += (((1UL) << 12)/sizeof(unsigned long)), dir++) {
     |not affected ==> the lock is still locked. prev next
 8149|  if (idx == stage) {
 8150|   shmem_dir_unmap(dir-1);
 8151|   if (({ __might_sleep("mm/.tmp_shmem.o.armored.c", 889, 0); __cond_resched_lock(&info->lock); })) {
 8152|
 8153|    if (limit > info->next_index) {
 8154|     limit = info->next_index;
 8155|     if (idx >= limit)
 8156|      goto lost2;
 8157|    }
 8158|   }
 8159|   dir = shmem_dir_map(info->i_indirect) +
 8160|       (((1UL) << 12)/sizeof(unsigned long))/2 + idx/((unsigned long long)(((1UL) << 12)/sizeof(unsigned long))*(((1UL) << 12)/sizeof(unsigned long)));
 8161|   while (!*dir) {
 8162|    dir++;
 8163|    idx += ((unsigned long long)(((1UL) << 12)/sizeof(unsigned long))*(((1UL) << 12)/sizeof(unsigned long)));
 8164|    if (idx >= limit)
 8165|     goto lost1;
 8166|   }
 8167|   stage = idx + ((unsigned long long)(((1UL) << 12)/sizeof(unsigned long))*(((1UL) << 12)/sizeof(unsigned long)));
 8168|   subdir = *dir;
 8169|   shmem_dir_unmap(dir);
 8170|   dir = shmem_dir_map(subdir);
 8171|  }
 8172|  subdir = *dir;
 8173|  if (subdir && ((subdir)->private)) {
 8174|   ptr = shmem_swp_map(subdir);
 8175|   size = limit - idx;
 8176|   if (size > (((1UL) << 12)/sizeof(unsigned long)))
 8177|    size = (((1UL) << 12)/sizeof(unsigned long));
 8178|   offset = shmem_find_swp(entry, ptr, ptr+size);
 8179|   shmem_swp_unmap(ptr);
 8180|   if (offset >= 0) {
 8181|    shmem_dir_unmap(dir);
 8182|    goto found;
 8183|   }
 8184|  }
 8185| }
 8186|lost1:
 8187| shmem_dir_unmap(dir-1);
     |not affected ==> the lock is still locked. prev next
 8188|lost2:
 8189| __st_spin_unlock_st__(&info->lock);
     |not affected ==> the lock is still locked. prev next
 8190| return 0;
     |not affected ==> the lock is still locked. prev next
 8191|found:
 8192| idx += offset;
 8193| inode = igrab(&info->vfs_inode);
 8194| __st_spin_unlock_st__(&info->lock);
 8195| if (shmem_swaplist.next != &info->swaplist)
 8196|  list_move_tail(&shmem_swaplist, &info->swaplist);
 8197| __st_mutex_unlock_st__(&shmem_swaplist_mutex);
 8198|
 8199| error = 1;
 8200| if (!inode)
 8201|  goto out;
 8202|
 8203|
 8204|
 8205|
 8206|
 8207| error = mem_cgroup_cache_charge(page, get_current()->mm, __st_GFP_KERNEL_st__);
 8208| if (error)
 8209|  goto out;
 8210| error = radix_tree_preload(__st_GFP_KERNEL_st__);
 8211| if (error) {
 8212|  mem_cgroup_uncharge_cache_page(page);
 8213|  goto out;
 8214| }
 8215| error = 1;
 8216|
 8217| __st_spin_lock_st__(&info->lock);
 8218| ptr = shmem_swp_entry(info, idx, ((void *)0));
 8219| if (ptr && ptr->val == entry.val) {
 8220|  error = add_to_page_cache_locked(page, inode->i_mapping,
 8221|      idx, (((( gfp_t)0x20u)) & ~(( gfp_t)0x20u)));
 8222|
 8223| } else
 8224|  mem_cgroup_uncharge_cache_page(page);
 8225|
 8226| if (error == -17) {
 8227|  struct page *filepage = find_get_page(inode->i_mapping, idx);
 8228|  error = 1;
 8229|  if (filepage) {
 8230|
 8231|
 8232|
 8233|
 8234|   if (PageUptodate(filepage))
 8235|    error = 0;
 8236|   put_page(filepage);
 8237|  }
 8238| }
 8239| if (!error) {
 8240|  delete_from_swap_cache(page);
 8241|  set_page_dirty(page);
 8242|  info->flags |= 0x00000001;
 8243|  shmem_swp_set(info, ptr, 0);
 8244|  swap_free(entry);
 8245|  error = 1;
 8246| }
 8247| if (ptr)
 8248|  shmem_swp_unmap(ptr);
 8249| __st_spin_unlock_st__(&info->lock);
 8250| radix_tree_preload_end();
 8251|out:
 8252| unlock_page(page);
 8253| put_page(page);
 8254| iput(inode);
 8255| return error;
 8256|}
     |not affected ==> the lock is still locked. prev next
 8257|
 8258|
 8259|
 8260|
 8261|int shmem_unuse(swp_entry_t entry, struct page *page)
 8262|{
 8263| struct list_head *p, *next;
 8264| struct shmem_inode_info *info;
 8265| int found = 0;
 8266|
 8267| __st_mutex_lock_st__(&shmem_swaplist_mutex);
     |The lock is locked here. next
 8268| for (p = (&shmem_swaplist)->next, next = p->next; p != (&shmem_swaplist); p = next, next = p->next) {
     |not affected ==> the lock is still locked. prev next
 8269|  info = ({ const typeof( ((struct shmem_inode_info *)0)->swaplist ) *__mptr = (p); (struct shmem_inode_info *)( (char *)__mptr - 1 );});
     |not affected ==> the lock is still locked. prev next
 8270|  found = shmem_unuse_inode(info, entry, page);
     |not affected ==> the lock is still locked. prev next
 8271|  ({ __might_sleep("mm/.tmp_shmem.o.armored.c", 1017, 0); _cond_resched(); });
     |not affected ==> the lock is still locked. prev next
 8272|  if (found)
     |not affected ==> the lock is still locked. prev next
 8273|   goto out;
     |not affected ==> the lock is still locked. prev next
 8274| }
 8275| __st_mutex_unlock_st__(&shmem_swaplist_mutex);
 8276|
 8277|
 8278|
 8279|
 8280| unlock_page(page);
 8281| put_page(page);
 8282|out:
 8283| return (found < 0) ? found : 0;
     |not affected ==> the lock is still locked. prev next
 8284|}
     |Leaving function in locked state.[& shmem_swaplist_mutex] prev
 8285|
 8286|
 8287|
 8288|
 8289|static int shmem_writepage(struct page *page, struct writeback_control *wbc)
 8290|{
 8291| struct shmem_inode_info *info;
 8292| swp_entry_t *entry, swap;
 8293| struct address_space *mapping;
 8294| unsigned long index;
 8295| struct inode *inode;
 8296|
 8297| __st_BUG_ON_st__(!PageLocked(page));
 8298| mapping = page->mapping;
 8299| index = page->index;
 8300| inode = mapping->host;
 8301| info = SHMEM_I(inode);
 8302| if (info->flags & 0x00002000)
 8303|  goto redirty;
 8304| if (!total_swap_pages)
 8305|  goto redirty;
 8306| if (wbc->for_reclaim)
 8307|  swap = get_swap_page();
 8308| else
 8309|  swap.val = 0;
 8310|
 8311| __st_spin_lock_st__(&info->lock);
 8312| if (index >= info->next_index) {
 8313|  __st_BUG_ON_st__(!(info->flags & 0x00000002));
 8314|  goto unlock;
 8315| }
 8316| entry = shmem_swp_entry(info, index, ((void *)0));
 8317| if (entry->val) {
 8318|
 8319|
 8320|
 8321|
 8322|  free_swap_and_cache(*entry);
 8323|  shmem_swp_set(info, entry, 0);
 8324| }
 8325| shmem_recalc_inode(inode);
 8326|
 8327| if (swap.val && add_to_swap_cache(page, swap, ((( gfp_t)0x20u))) == 0) {
 8328|  remove_from_page_cache(page);
 8329|  shmem_swp_set(info, entry, swap.val);
 8330|  shmem_swp_unmap(entry);
 8331|  if (list_empty(&info->swaplist))
 8332|   inode = igrab(inode);
 8333|  else
 8334|   inode = ((void *)0);
 8335|  __st_spin_unlock_st__(&info->lock);
 8336|  swap_shmem_alloc(swap);
 8337|  __st_BUG_ON_st__(page_mapped(page));
 8338|  put_page(page);
 8339|  swap_writepage(page, wbc);
 8340|  if (inode) {
 8341|   __st_mutex_lock_st__(&shmem_swaplist_mutex);
 8342|
 8343|   list_move_tail(&info->swaplist, &shmem_swaplist);
 8344|   __st_mutex_unlock_st__(&shmem_swaplist_mutex);
 8345|   iput(inode);
 8346|  }
 8347|  return 0;
 8348| }
 8349|
 8350| shmem_swp_unmap(entry);
 8351|unlock:
 8352| __st_spin_unlock_st__(&info->lock);
 8353|
 8354|
 8355|
 8356|
 8357| swapcache_free(swap, ((void *)0));
 8358|redirty:
 8359| set_page_dirty(page);
 8360| if (wbc->for_reclaim)
 8361|  return AOP_WRITEPAGE_ACTIVATE;
 8362| unlock_page(page);
 8363| return 0;
 8364|}
 8365|
 8366|
 8367|
 8368|static void shmem_show_mpol(struct seq_file *seq, struct mempolicy *mpol)
 8369|{
 8370| char buffer[64];
 8371|
 8372| if (!mpol || mpol->mode == MPOL_DEFAULT)
 8373|  return;
 8374|
 8375| mpol_to_str(buffer, sizeof(buffer), mpol, 1);
 8376|
 8377| seq_printf(seq, ",mpol=%s", buffer);
 8378|}
 8379|
 8380|static struct mempolicy *shmem_get_sbmpol(struct shmem_sb_info *sbinfo)
 8381|{
 8382| struct mempolicy *mpol = ((void *)0);
 8383| if (sbinfo->mpol) {
 8384|  __st_spin_lock_st__(&sbinfo->stat_lock);
 8385|  mpol = sbinfo->mpol;
 8386|  mpol_get(mpol);
 8387|  __st_spin_unlock_st__(&sbinfo->stat_lock);
 8388| }
 8389| return mpol;
 8390|}
 8391|
 8392|
 8393|static struct page *shmem_swapin(swp_entry_t entry, gfp_t gfp,
 8394|   struct shmem_inode_info *info, unsigned long idx)
 8395|{
 8396| struct mempolicy mpol, *spol;
 8397| struct vm_area_struct pvma;
 8398| struct page *page;
 8399|
 8400| spol = mpol_cond_copy(&mpol,
 8401|    mpol_shared_policy_lookup(&info->policy, idx));
 8402|
 8403|
 8404| pvma.vm_start = 0;
 8405| pvma.vm_pgoff = idx;
 8406| pvma.vm_ops = ((void *)0);
 8407| pvma.vm_policy = spol;
 8408| page = swapin_readahead(entry, gfp, &pvma, 0);
 8409| return page;
 8410|}
 8411|
 8412|static struct page *shmem_alloc_page(gfp_t gfp,
 8413|   struct shmem_inode_info *info, unsigned long idx)
 8414|{
 8415| struct vm_area_struct pvma;
 8416|
 8417|
 8418| pvma.vm_start = 0;
 8419| pvma.vm_pgoff = idx;
 8420| pvma.vm_ops = ((void *)0);
 8421| pvma.vm_policy = mpol_shared_policy_lookup(&info->policy, idx);
 8422|
 8423|
 8424|
 8425|
 8426| return alloc_page_vma(gfp, &pvma, 0);
 8427|}
 8428|static int shmem_getpage(struct inode *inode, unsigned long idx,
 8429|   struct page **pagep, enum sgp_type sgp, int *type)
 8430|{
 8431| struct address_space *mapping = inode->i_mapping;
 8432| struct shmem_inode_info *info = SHMEM_I(inode);
 8433| struct shmem_sb_info *sbinfo;
 8434| struct page *filepage = *pagep;
 8435| struct page *swappage;
 8436| struct page *prealloc_page = ((void *)0);
 8437| swp_entry_t *entry;
 8438| swp_entry_t swap;
 8439| gfp_t gfp;
 8440| int error;
 8441|
 8442| if (idx >= ((unsigned long)((({ unsigned long long __min1 = (((16 + (((unsigned long long)(((1UL) << 12)/sizeof(unsigned long))*(((1UL) << 12)/sizeof(unsigned long)))/2) * ((((1UL) << 12)/sizeof(unsigned long))+1)) << 12)); unsigned long long __min2 = (0x7fffffffffffffffUL); __min1 < __min2 ? __min1: __min2; })+1) >> 12)))
 8443|  return -27;
 8444|
 8445| if (type)
 8446|  *type = 0;
 8447|repeat:
 8448| if (!filepage)
 8449|  filepage = find_lock_page(mapping, idx);
 8450| if (filepage && PageUptodate(filepage))
 8451|  goto done;
 8452| gfp = mapping_gfp_mask(mapping);
 8453| if (!filepage) {
 8454|
 8455|
 8456|
 8457|
 8458|  error = radix_tree_preload(gfp & ~(( gfp_t)0x02u));
 8459|  if (error)
 8460|   goto failed;
 8461|  radix_tree_preload_end();
 8462|  if (sgp != SGP_READ && !prealloc_page) {
 8463|
 8464|   prealloc_page = shmem_alloc_page(gfp, info, idx);
 8465|   if (prealloc_page) {
 8466|    if (mem_cgroup_cache_charge(prealloc_page,
 8467|      get_current()->mm, __st_GFP_KERNEL_st__)) {
 8468|     put_page(prealloc_page);
 8469|     prealloc_page = ((void *)0);
 8470|    }
 8471|   }
 8472|  }
 8473| }
 8474| error = 0;
 8475|
 8476| __st_spin_lock_st__(&info->lock);
 8477| shmem_recalc_inode(inode);
 8478| entry = shmem_swp_alloc(info, idx, sgp);
 8479| if (IS_ERR(entry)) {
 8480|  __st_spin_unlock_st__(&info->lock);
 8481|  error = PTR_ERR(entry);
 8482|  goto failed;
 8483| }
 8484| swap = *entry;
 8485|
 8486| if (swap.val) {
 8487|
 8488|  swappage = lookup_swap_cache(swap);
 8489|  if (!swappage) {
 8490|   shmem_swp_unmap(entry);
 8491|
 8492|   if (type && !(*type & 0x0004)) {
 8493|    __count_vm_event(PGMAJFAULT);
 8494|    *type |= 0x0004;
 8495|   }
 8496|   __st_spin_unlock_st__(&info->lock);
 8497|   swappage = shmem_swapin(swap, gfp, info, idx);
 8498|   if (!swappage) {
 8499|    __st_spin_lock_st__(&info->lock);
 8500|    entry = shmem_swp_alloc(info, idx, sgp);
 8501|    if (IS_ERR(entry))
 8502|     error = PTR_ERR(entry);
 8503|    else {
 8504|     if (entry->val == swap.val)
 8505|      error = -12;
 8506|     shmem_swp_unmap(entry);
 8507|    }
 8508|    __st_spin_unlock_st__(&info->lock);
 8509|    if (error)
 8510|     goto failed;
 8511|    goto repeat;
 8512|   }
 8513|   wait_on_page_locked(swappage);
 8514|   put_page(swappage);
 8515|   goto repeat;
 8516|  }
 8517|
 8518|
 8519|  if (!trylock_page(swappage)) {
 8520|   shmem_swp_unmap(entry);
 8521|   __st_spin_unlock_st__(&info->lock);
 8522|   wait_on_page_locked(swappage);
 8523|   put_page(swappage);
 8524|   goto repeat;
 8525|  }
 8526|  if (PageWriteback(swappage)) {
 8527|   shmem_swp_unmap(entry);
 8528|   __st_spin_unlock_st__(&info->lock);
 8529|   wait_on_page_writeback(swappage);
 8530|   unlock_page(swappage);
 8531|   put_page(swappage);
 8532|   goto repeat;
 8533|  }
 8534|  if (!PageUptodate(swappage)) {
 8535|   shmem_swp_unmap(entry);
 8536|   __st_spin_unlock_st__(&info->lock);
 8537|   unlock_page(swappage);
 8538|   put_page(swappage);
 8539|   error = -5;
 8540|   goto failed;
 8541|  }
 8542|
 8543|  if (filepage) {
 8544|   shmem_swp_set(info, entry, 0);
 8545|   shmem_swp_unmap(entry);
 8546|   delete_from_swap_cache(swappage);
 8547|   __st_spin_unlock_st__(&info->lock);
 8548|   copy_highpage(filepage, swappage);
 8549|   unlock_page(swappage);
 8550|   put_page(swappage);
 8551|   flush_dcache_page(filepage);
 8552|   SetPageUptodate(filepage);
 8553|   set_page_dirty(filepage);
 8554|   swap_free(swap);
 8555|  } else if (!(error = add_to_page_cache_locked(swappage, mapping,
 8556|     idx, (((( gfp_t)0x20u)) & ~(( gfp_t)0x20u))))) {
 8557|   info->flags |= 0x00000001;
 8558|   shmem_swp_set(info, entry, 0);
 8559|   shmem_swp_unmap(entry);
 8560|   delete_from_swap_cache(swappage);
 8561|   __st_spin_unlock_st__(&info->lock);
 8562|   filepage = swappage;
 8563|   set_page_dirty(filepage);
 8564|   swap_free(swap);
 8565|  } else {
 8566|   shmem_swp_unmap(entry);
 8567|   __st_spin_unlock_st__(&info->lock);
 8568|   if (error == -12) {
 8569|
 8570|
 8571|
 8572|
 8573|    error = mem_cgroup_shmem_charge_fallback(
 8574|        swappage,
 8575|        get_current()->mm,
 8576|        gfp);
 8577|    if (error) {
 8578|     unlock_page(swappage);
 8579|     put_page(swappage);
 8580|     goto failed;
 8581|    }
 8582|   }
 8583|   unlock_page(swappage);
 8584|   put_page(swappage);
 8585|   goto repeat;
 8586|  }
 8587| } else if (sgp == SGP_READ && !filepage) {
 8588|  shmem_swp_unmap(entry);
 8589|  filepage = find_get_page(mapping, idx);
 8590|  if (filepage &&
 8591|      (!PageUptodate(filepage) || !trylock_page(filepage))) {
 8592|   __st_spin_unlock_st__(&info->lock);
 8593|   wait_on_page_locked(filepage);
 8594|   put_page(filepage);
 8595|   filepage = ((void *)0);
 8596|   goto repeat;
 8597|  }
 8598|  __st_spin_unlock_st__(&info->lock);
 8599| } else {
 8600|  shmem_swp_unmap(entry);
 8601|  sbinfo = SHMEM_SB(inode->i_sb);
 8602|  if (sbinfo->max_blocks) {
 8603|   if ((percpu_counter_compare(&sbinfo->used_blocks, sbinfo->max_blocks) > 0) ||
 8604|       shmem_acct_block(info->flags)) {
 8605|    __st_spin_unlock_st__(&info->lock);
 8606|    error = -28;
 8607|    goto failed;
 8608|   }
 8609|   percpu_counter_inc(&sbinfo->used_blocks);
 8610|   __st_spin_lock_st__(&inode->i_lock);
 8611|   inode->i_blocks += (((1UL) << 12)/512);
 8612|   __st_spin_unlock_st__(&inode->i_lock);
 8613|  } else if (shmem_acct_block(info->flags)) {
 8614|   __st_spin_unlock_st__(&info->lock);
 8615|   error = -28;
 8616|   goto failed;
 8617|  }
 8618|
 8619|  if (!filepage) {
 8620|   int ret;
 8621|
 8622|   if (!prealloc_page) {
 8623|    __st_spin_unlock_st__(&info->lock);
 8624|    filepage = shmem_alloc_page(gfp, info, idx);
 8625|    if (!filepage) {
 8626|     shmem_unacct_blocks(info->flags, 1);
 8627|     shmem_free_blocks(inode, 1);
 8628|     error = -12;
 8629|     goto failed;
 8630|    }
 8631|    SetPageSwapBacked(filepage);
 8632|
 8633|
 8634|
 8635|
 8636|
 8637|    error = mem_cgroup_cache_charge(filepage,
 8638|     get_current()->mm, __st_GFP_KERNEL_st__);
 8639|    if (error) {
 8640|     put_page(filepage);
 8641|     shmem_unacct_blocks(info->flags, 1);
 8642|     shmem_free_blocks(inode, 1);
 8643|     filepage = ((void *)0);
 8644|     goto failed;
 8645|    }
 8646|
 8647|    __st_spin_lock_st__(&info->lock);
 8648|   } else {
 8649|    filepage = prealloc_page;
 8650|    prealloc_page = ((void *)0);
 8651|    SetPageSwapBacked(filepage);
 8652|   }
 8653|
 8654|   entry = shmem_swp_alloc(info, idx, sgp);
 8655|   if (IS_ERR(entry))
 8656|    error = PTR_ERR(entry);
 8657|   else {
 8658|    swap = *entry;
 8659|    shmem_swp_unmap(entry);
 8660|   }
 8661|   ret = error || swap.val;
 8662|   if (ret)
 8663|    mem_cgroup_uncharge_cache_page(filepage);
 8664|   else
 8665|    ret = add_to_page_cache_lru(filepage, mapping,
 8666|      idx, (((( gfp_t)0x20u)) & ~(( gfp_t)0x20u)));
 8667|
 8668|
 8669|
 8670|
 8671|   if (ret) {
 8672|    __st_spin_unlock_st__(&info->lock);
 8673|    put_page(filepage);
 8674|    shmem_unacct_blocks(info->flags, 1);
 8675|    shmem_free_blocks(inode, 1);
 8676|    filepage = ((void *)0);
 8677|    if (error)
 8678|     goto failed;
 8679|    goto repeat;
 8680|   }
 8681|   info->flags |= 0x00000001;
 8682|  }
 8683|
 8684|  info->alloced++;
 8685|  __st_spin_unlock_st__(&info->lock);
 8686|  clear_highpage(filepage);
 8687|  flush_dcache_page(filepage);
 8688|  SetPageUptodate(filepage);
 8689|  if (sgp == SGP_DIRTY)
 8690|   set_page_dirty(filepage);
 8691| }
 8692|done:
 8693| *pagep = filepage;
 8694| error = 0;
 8695| goto out;
 8696|
 8697|failed:
 8698| if (*pagep != filepage) {
 8699|  unlock_page(filepage);
 8700|  put_page(filepage);
 8701| }
 8702|out:
 8703| if (prealloc_page) {
 8704|  mem_cgroup_uncharge_cache_page(prealloc_page);
 8705|  put_page(prealloc_page);
 8706| }
 8707| return error;
 8708|}
 8709|
 8710|static int shmem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
 8711|{
 8712| struct inode *inode = vma->vm_file->f_path.dentry->d_inode;
 8713| int error;
 8714| int ret;
 8715|
 8716| if (((loff_t)vmf->pgoff << 12) >= i_size_read(inode))
 8717|  return 0x0002;
 8718|
 8719| error = shmem_getpage(inode, vmf->pgoff, &vmf->page, SGP_CACHE, &ret);
 8720| if (error)
 8721|  return ((error == -12) ? 0x0001 : 0x0002);
 8722|
 8723| return ret | 0x0200;
 8724|}
 8725|
 8726|
 8727|static int shmem_set_policy(struct vm_area_struct *vma, struct mempolicy *new)
 8728|{
 8729| struct inode *i = vma->vm_file->f_path.dentry->d_inode;
 8730| return mpol_set_shared_policy(&SHMEM_I(i)->policy, vma, new);
 8731|}
 8732|
 8733|static struct mempolicy *shmem_get_policy(struct vm_area_struct *vma,
 8734|       unsigned long addr)
 8735|{
 8736| struct inode *i = vma->vm_file->f_path.dentry->d_inode;
 8737| unsigned long idx;
 8738|
 8739| idx = ((addr - vma->vm_start) >> 12) + vma->vm_pgoff;
 8740| return mpol_shared_policy_lookup(&SHMEM_I(i)->policy, idx);
 8741|}
 8742|
 8743|
 8744|int shmem_lock(struct file *file, int lock, struct user_struct *user)
 8745|{
 8746| struct inode *inode = file->f_path.dentry->d_inode;
 8747| struct shmem_inode_info *info = SHMEM_I(inode);
 8748| int retval = -12;
 8749|
 8750| __st_spin_lock_st__(&info->lock);
 8751| if (lock && !(info->flags & 0x00002000)) {
 8752|  if (!user_shm_lock(inode->i_size, user))
 8753|   goto out_nomem;
 8754|  info->flags |= 0x00002000;
 8755|  mapping_set_unevictable(file->f_mapping);
 8756| }
 8757| if (!lock && (info->flags & 0x00002000) && user) {
 8758|  user_shm_unlock(inode->i_size, user);
 8759|  info->flags &= ~0x00002000;
 8760|  mapping_clear_unevictable(file->f_mapping);
 8761|  scan_mapping_unevictable_pages(file->f_mapping);
 8762| }
 8763| retval = 0;
 8764|
 8765|out_nomem:
 8766| __st_spin_unlock_st__(&info->lock);
 8767| return retval;
 8768|}
 8769|
 8770|static int shmem_mmap(struct file *file, struct vm_area_struct *vma)
 8771|{
 8772| file_accessed(file);
 8773| vma->vm_ops = &shmem_vm_ops;
 8774| vma->vm_flags |= 0x08000000;
 8775| return 0;
 8776|}
 8777|
 8778|static struct inode *shmem_get_inode(struct super_block *sb, const struct inode *dir,
 8779|         int mode, dev_t dev, unsigned long flags)
 8780|{
 8781| struct inode *inode;
 8782| struct shmem_inode_info *info;
 8783| struct shmem_sb_info *sbinfo = SHMEM_SB(sb);
 8784|
 8785| if (shmem_reserve_inode(sb))
 8786|  return ((void *)0);
 8787|
 8788| inode = new_inode(sb);
 8789| if (inode) {
 8790|  inode->i_ino = get_next_ino();
 8791|  inode_init_owner(inode, dir, mode);
 8792|  inode->i_blocks = 0;
 8793|  inode->i_mapping->backing_dev_info = &shmem_backing_dev_info;
 8794|  inode->i_atime = inode->i_mtime = inode->i_ctime = (current_kernel_time());
 8795|  inode->i_generation = get_seconds();
 8796|  info = SHMEM_I(inode);
 8797|  __st_memset_st__(info, 0, (char *)inode - (char *)info);
 8798|  do { spinlock_check(&info->lock); do { static struct lock_class_key __key; __raw_spin_lock_init((&(&info->lock)->rlock), "&(&info->lock)->rlock", &__key); } while (0); } while (0);
 8799|  info->flags = flags & 0x00200000;
 8800|  INIT_LIST_HEAD(&info->swaplist);
 8801|  cache_no_acl(inode);
 8802|
 8803|  switch (mode & 00170000) {
 8804|  default:
 8805|   inode->i_op = &shmem_special_inode_operations;
 8806|   init_special_inode(inode, mode, dev);
 8807|   break;
 8808|  case 0100000:
 8809|   inode->i_mapping->a_ops = &shmem_aops;
 8810|   inode->i_op = &shmem_inode_operations;
 8811|   inode->i_fop = &shmem_file_operations;
 8812|   mpol_shared_policy_init(&info->policy,
 8813|       shmem_get_sbmpol(sbinfo));
 8814|   break;
 8815|  case 0040000:
 8816|   inc_nlink(inode);
 8817|
 8818|   inode->i_size = 2 * 20;
 8819|   inode->i_op = &shmem_dir_inode_operations;
 8820|   inode->i_fop = &simple_dir_operations;
 8821|   break;
 8822|  case 0120000:
 8823|
 8824|
 8825|
 8826|
 8827|   mpol_shared_policy_init(&info->policy, ((void *)0));
 8828|   break;
 8829|  }
 8830| } else
 8831|  shmem_free_inode(sb);
 8832| return inode;
 8833|}
 8834|
 8835|
 8836|static const struct inode_operations shmem_symlink_inode_operations;
 8837|static const struct inode_operations shmem_symlink_inline_operations;
 8838|
 8839|
 8840|
 8841|
 8842|
 8843|
 8844|static int shmem_readpage(struct file *file, struct page *page)
 8845|{
 8846| struct inode *inode = page->mapping->host;
 8847| int error = shmem_getpage(inode, page->index, &page, SGP_CACHE, ((void *)0));
 8848| unlock_page(page);
 8849| return error;
 8850|}
 8851|
 8852|static int
 8853|shmem_write_begin(struct file *file, struct address_space *mapping,
 8854|   loff_t pos, unsigned len, unsigned flags,
 8855|   struct page **pagep, void **fsdata)
 8856|{
 8857| struct inode *inode = mapping->host;
 8858| unsigned long index = pos >> 12;
 8859| *pagep = ((void *)0);
 8860| return shmem_getpage(inode, index, pagep, SGP_WRITE, ((void *)0));
 8861|}
 8862|
 8863|static int
 8864|shmem_write_end(struct file *file, struct address_space *mapping,
 8865|   loff_t pos, unsigned len, unsigned copied,
 8866|   struct page *page, void *fsdata)
 8867|{
 8868| struct inode *inode = mapping->host;
 8869|
 8870| if (pos + copied > inode->i_size)
 8871|  i_size_write(inode, pos + copied);
 8872|
 8873| set_page_dirty(page);
 8874| unlock_page(page);
 8875| put_page(page);
 8876|
 8877| return copied;
 8878|}
 8879|
 8880|static void do_shmem_file_read(struct file *filp, loff_t *ppos, read_descriptor_t *desc, read_actor_t actor)
 8881|{
 8882| struct inode *inode = filp->f_path.dentry->d_inode;
 8883| struct address_space *mapping = inode->i_mapping;
 8884| unsigned long index, offset;
 8885| enum sgp_type sgp = SGP_READ;
 8886|
 8887|
 8888|
 8889|
 8890|
 8891|
 8892| if ((((current_thread_info()->addr_limit)).seg == (((mm_segment_t) { (-1UL) })).seg))
 8893|  sgp = SGP_DIRTY;
 8894|
 8895| index = *ppos >> 12;
 8896| offset = *ppos & ~(~(((1UL) << 12)-1));
 8897|
 8898| for (;;) {
 8899|  struct page *page = ((void *)0);
 8900|  unsigned long end_index, nr, ret;
 8901|  loff_t i_size = i_size_read(inode);
 8902|
 8903|  end_index = i_size >> 12;
 8904|  if (index > end_index)
 8905|   break;
 8906|  if (index == end_index) {
 8907|   nr = i_size & ~(~(((1UL) << 12)-1));
 8908|   if (nr <= offset)
 8909|    break;
 8910|  }
 8911|
 8912|  desc->error = shmem_getpage(inode, index, &page, sgp, ((void *)0));
 8913|  if (desc->error) {
 8914|   if (desc->error == -22)
 8915|    desc->error = 0;
 8916|   break;
 8917|  }
 8918|  if (page)
 8919|   unlock_page(page);
 8920|
 8921|
 8922|
 8923|
 8924|
 8925|  nr = ((1UL) << 12);
 8926|  i_size = i_size_read(inode);
 8927|  end_index = i_size >> 12;
 8928|  if (index == end_index) {
 8929|   nr = i_size & ~(~(((1UL) << 12)-1));
 8930|   if (nr <= offset) {
 8931|    if (page)
 8932|     put_page(page);
 8933|    break;
 8934|   }
 8935|  }
 8936|  nr -= offset;
 8937|
 8938|  if (page) {
 8939|
 8940|
 8941|
 8942|
 8943|
 8944|   if (mapping_writably_mapped(mapping))
 8945|    flush_dcache_page(page);
 8946|
 8947|
 8948|
 8949|   if (!offset)
 8950|    mark_page_accessed(page);
 8951|  } else {
 8952|   page = ((((struct page *)(0xffffea0000000000UL)) + (__phys_addr((unsigned long)(empty_zero_page)) >> 12)));
 8953|   get_page(page);
 8954|  }
 8955|  ret = actor(desc, page, offset, nr);
 8956|  offset += ret;
 8957|  index += offset >> 12;
 8958|  offset &= ~(~(((1UL) << 12)-1));
 8959|
 8960|  put_page(page);
 8961|  if (ret != nr || !desc->count)
 8962|   break;
 8963|
 8964|  ({ __might_sleep("mm/.tmp_shmem.o.armored.c", 1774, 0); _cond_resched(); });
 8965| }
 8966|
 8967| *ppos = ((loff_t) index << 12) + offset;
 8968| file_accessed(filp);
 8969|}
 8970|
 8971|static ssize_t shmem_file_aio_read(struct kiocb *iocb,
 8972|  const struct iovec *iov, unsigned long nr_segs, loff_t pos)
 8973|{
 8974| struct file *filp = iocb->ki_filp;
 8975| ssize_t retval;
 8976| unsigned long seg;
 8977| size_t count;
 8978| loff_t *ppos = &iocb->ki_pos;
 8979|
 8980| retval = generic_segment_checks(iov, &nr_segs, &count, 1);
 8981| if (retval)
 8982|  return retval;
 8983|
 8984| for (seg = 0; seg < nr_segs; seg++) {
 8985|  read_descriptor_t desc;
 8986|
 8987|  desc.written = 0;
 8988|  desc.arg.buf = iov[seg].iov_base;
 8989|  desc.count = iov[seg].iov_len;
 8990|  if (desc.count == 0)
 8991|   continue;
 8992|  desc.error = 0;
 8993|  do_shmem_file_read(filp, ppos, &desc, file_read_actor);
 8994|  retval += desc.written;
 8995|  if (desc.error) {
 8996|   retval = retval ?: desc.error;
 8997|   break;
 8998|  }
 8999|  if (desc.count > 0)
 9000|   break;
 9001| }
 9002| return retval;
 9003|}
 9004|
 9005|static int shmem_statfs(struct dentry *dentry, struct kstatfs *buf)
 9006|{
 9007| struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb);
 9008|
 9009| buf->f_type = 0x01021994;
 9010| buf->f_bsize = ((1UL) << 12);
 9011| buf->f_namelen = 255;
 9012| if (sbinfo->max_blocks) {
 9013|  buf->f_blocks = sbinfo->max_blocks;
 9014|  buf->f_bavail = buf->f_bfree =
 9015|    sbinfo->max_blocks - percpu_counter_sum(&sbinfo->used_blocks);
 9016| }
 9017| if (sbinfo->max_inodes) {
 9018|  buf->f_files = sbinfo->max_inodes;
 9019|  buf->f_ffree = sbinfo->free_inodes;
 9020| }
 9021|
 9022| return 0;
 9023|}
 9024|
 9025|
 9026|
 9027|
 9028|static int
 9029|shmem_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
 9030|{
 9031| struct inode *inode;
 9032| int error = -28;
 9033|
 9034| inode = shmem_get_inode(dir->i_sb, dir, mode, dev, 0x00200000);
 9035| if (inode) {
 9036|  error = security_inode_init_security(inode, dir, ((void *)0), ((void *)0),
 9037|           ((void *)0));
 9038|  if (error) {
 9039|   if (error != -95) {
 9040|    iput(inode);
 9041|    return error;
 9042|   }
 9043|  }
 9044|
 9045|  error = generic_acl_init(inode, dir);
 9046|  if (error) {
 9047|   iput(inode);
 9048|   return error;
 9049|  }
 9050|
 9051|
 9052|
 9053|  dir->i_size += 20;
 9054|  dir->i_ctime = dir->i_mtime = (current_kernel_time());
 9055|  d_instantiate(dentry, inode);
 9056|  dget(dentry);
 9057| }
 9058| return error;
 9059|}
 9060|
 9061|static int shmem_mkdir(struct inode *dir, struct dentry *dentry, int mode)
 9062|{
 9063| int error;
 9064|
 9065| if ((error = shmem_mknod(dir, dentry, mode | 0040000, 0)))
 9066|  return error;
 9067| inc_nlink(dir);
 9068| return 0;
 9069|}
 9070|
 9071|static int shmem_create(struct inode *dir, struct dentry *dentry, int mode,
 9072|  struct nameidata *nd)
 9073|{
 9074| return shmem_mknod(dir, dentry, mode | 0100000, 0);
 9075|}
 9076|
 9077|
 9078|
 9079|
 9080|static int shmem_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry)
 9081|{
 9082| struct inode *inode = old_dentry->d_inode;
 9083| int ret;
 9084|
 9085|
 9086|
 9087|
 9088|
 9089|
 9090| ret = shmem_reserve_inode(inode->i_sb);
 9091| if (ret)
 9092|  goto out;
 9093|
 9094| dir->i_size += 20;
 9095| inode->i_ctime = dir->i_ctime = dir->i_mtime = (current_kernel_time());
 9096| inc_nlink(inode);
 9097| ihold(inode);
 9098| dget(dentry);
 9099| d_instantiate(dentry, inode);
 9100|out:
 9101| return ret;
 9102|}
 9103|
 9104|static int shmem_unlink(struct inode *dir, struct dentry *dentry)
 9105|{
 9106| struct inode *inode = dentry->d_inode;
 9107|
 9108| if (inode->i_nlink > 1 && !(((inode->i_mode) & 00170000) == 0040000))
 9109|  shmem_free_inode(inode->i_sb);
 9110|
 9111| dir->i_size -= 20;
 9112| inode->i_ctime = dir->i_ctime = dir->i_mtime = (current_kernel_time());
 9113| drop_nlink(inode);
 9114| dput(dentry);
 9115| return 0;
 9116|}
 9117|
 9118|static int shmem_rmdir(struct inode *dir, struct dentry *dentry)
 9119|{
 9120| if (!simple_empty(dentry))
 9121|  return -39;
 9122|
 9123| drop_nlink(dentry->d_inode);
 9124| drop_nlink(dir);
 9125| return shmem_unlink(dir, dentry);
 9126|}
 9127|
 9128|
 9129|
 9130|
 9131|
 9132|
 9133|
 9134|static int shmem_rename(struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry)
 9135|{
 9136| struct inode *inode = old_dentry->d_inode;
 9137| int they_are_dirs = (((inode->i_mode) & 00170000) == 0040000);
 9138|
 9139| if (!simple_empty(new_dentry))
 9140|  return -39;
 9141|
 9142| if (new_dentry->d_inode) {
 9143|  (void) shmem_unlink(new_dir, new_dentry);
 9144|  if (they_are_dirs)
 9145|   drop_nlink(old_dir);
 9146| } else if (they_are_dirs) {
 9147|  drop_nlink(old_dir);
 9148|  inc_nlink(new_dir);
 9149| }
 9150|
 9151| old_dir->i_size -= 20;
 9152| new_dir->i_size += 20;
 9153| old_dir->i_ctime = old_dir->i_mtime =
 9154| new_dir->i_ctime = new_dir->i_mtime =
 9155| inode->i_ctime = (current_kernel_time());
 9156| return 0;
 9157|}
 9158|
 9159|static int shmem_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
 9160|{
 9161| int error;
 9162| int len;
 9163| struct inode *inode;
 9164| struct page *page = ((void *)0);
 9165| char *kaddr;
 9166| struct shmem_inode_info *info;
 9167|
 9168| len = strlen(symname) + 1;
 9169| if (len > ((1UL) << 12))
 9170|  return -36;
 9171|
 9172| inode = shmem_get_inode(dir->i_sb, dir, 0120000|(00700|00070|00007), 0, 0x00200000);
 9173| if (!inode)
 9174|  return -28;
 9175|
 9176| error = security_inode_init_security(inode, dir, ((void *)0), ((void *)0),
 9177|          ((void *)0));
 9178| if (error) {
 9179|  if (error != -95) {
 9180|   iput(inode);
 9181|   return error;
 9182|  }
 9183|  error = 0;
 9184| }
 9185|
 9186| info = SHMEM_I(inode);
 9187| inode->i_size = len-1;
 9188| if (len <= (char *)inode - (char *)info) {
 9189|
 9190|  __st_memcpy_st__(info, symname, len);
 9191|  inode->i_op = &shmem_symlink_inline_operations;
 9192| } else {
 9193|  error = shmem_getpage(inode, 0, &page, SGP_WRITE, ((void *)0));
 9194|  if (error) {
 9195|   iput(inode);
 9196|   return error;
 9197|  }
 9198|  inode->i_mapping->a_ops = &shmem_aops;
 9199|  inode->i_op = &shmem_symlink_inode_operations;
 9200|  kaddr = __kmap_atomic(page);
 9201|  __st_memcpy_st__(kaddr, symname, len);
 9202|  do { ((void)(sizeof(struct { int:-!!(0); }))); __kunmap_atomic(kaddr); } while (0);
 9203|  set_page_dirty(page);
 9204|  unlock_page(page);
 9205|  put_page(page);
 9206| }
 9207| dir->i_size += 20;
 9208| dir->i_ctime = dir->i_mtime = (current_kernel_time());
 9209| d_instantiate(dentry, inode);
 9210| dget(dentry);
 9211| return 0;
 9212|}
 9213|
 9214|static void *shmem_follow_link_inline(struct dentry *dentry, struct nameidata *nd)
 9215|{
 9216| nd_set_link(nd, (char *)SHMEM_I(dentry->d_inode));
 9217| return ((void *)0);
 9218|}
 9219|
 9220|static void *shmem_follow_link(struct dentry *dentry, struct nameidata *nd)
 9221|{
 9222| struct page *page = ((void *)0);
 9223| int res = shmem_getpage(dentry->d_inode, 0, &page, SGP_READ, ((void *)0));
 9224| nd_set_link(nd, res ? ERR_PTR(res) : kmap(page));
 9225| if (page)
 9226|  unlock_page(page);
 9227| return page;
 9228|}
 9229|
 9230|static void shmem_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
 9231|{
 9232| if (!IS_ERR(nd_get_link(nd))) {
 9233|  struct page *page = cookie;
 9234|  kunmap(page);
 9235|  mark_page_accessed(page);
 9236|  put_page(page);
 9237| }
 9238|}
 9239|
 9240|static const struct inode_operations shmem_symlink_inline_operations = {
 9241| .readlink = generic_readlink,
 9242| .follow_link = shmem_follow_link_inline,
 9243|};
 9244|
 9245|static const struct inode_operations shmem_symlink_inode_operations = {
 9246| .readlink = generic_readlink,
 9247| .follow_link = shmem_follow_link,
 9248| .put_link = shmem_put_link,
 9249|};
 9250|static size_t shmem_xattr_security_list(struct dentry *dentry, char *list,
 9251|     size_t list_len, const char *name,
 9252|     size_t name_len, int handler_flags)
 9253|{
 9254| return security_inode_listsecurity(dentry->d_inode, list, list_len);
 9255|}
 9256|
 9257|static int shmem_xattr_security_get(struct dentry *dentry, const char *name,
 9258|  void *buffer, size_t size, int handler_flags)
 9259|{
 9260| if (strcmp(name, "") == 0)
 9261|  return -22;
 9262| return xattr_getsecurity(dentry->d_inode, name, buffer, size);
 9263|}
 9264|
 9265|static int shmem_xattr_security_set(struct dentry *dentry, const char *name,
 9266|  const void *value, size_t size, int flags, int handler_flags)
 9267|{
 9268| if (strcmp(name, "") == 0)
 9269|  return -22;
 9270| return security_inode_setsecurity(dentry->d_inode, name, value,
 9271|       size, flags);
 9272|}
 9273|
 9274|static const struct xattr_handler shmem_xattr_security_handler = {
 9275| .prefix = "security.",
 9276| .list = shmem_xattr_security_list,
 9277| .get = shmem_xattr_security_get,
 9278| .set = shmem_xattr_security_set,
 9279|};
 9280|
 9281|static const struct xattr_handler *shmem_xattr_handlers[] = {
 9282| &generic_acl_access_handler,
 9283| &generic_acl_default_handler,
 9284| &shmem_xattr_security_handler,
 9285| ((void *)0)
 9286|};
 9287|
 9288|
 9289|static struct dentry *shmem_get_parent(struct dentry *child)
 9290|{
 9291| return ERR_PTR(-116);
 9292|}
 9293|
 9294|static int shmem_match(struct inode *ino, void *vfh)
 9295|{
 9296| __u32 *fh = vfh;
 9297| __u64 inum = fh[2];
 9298| inum = (inum << 32) | fh[1];
 9299| return ino->i_ino == inum && fh[0] == ino->i_generation;
 9300|}
 9301|
 9302|static struct dentry *shmem_fh_to_dentry(struct super_block *sb,
 9303|  struct fid *fid, int fh_len, int fh_type)
 9304|{
 9305| struct inode *inode;
 9306| struct dentry *dentry = ((void *)0);
 9307| u64 inum = fid->raw[2];
 9308| inum = (inum << 32) | fid->raw[1];
 9309|
 9310| if (fh_len < 3)
 9311|  return ((void *)0);
 9312|
 9313| inode = ilookup5(sb, (unsigned long)(inum + fid->raw[0]),
 9314|   shmem_match, fid->raw);
 9315| if (inode) {
 9316|  dentry = d_find_alias(inode);
 9317|  iput(inode);
 9318| }
 9319|
 9320| return dentry;
 9321|}
 9322|
 9323|static int shmem_encode_fh(struct dentry *dentry, __u32 *fh, int *len,
 9324|    int connectable)
 9325|{
 9326| struct inode *inode = dentry->d_inode;
 9327|
 9328| if (*len < 3)
 9329|  return 255;
 9330|
 9331| if (inode_unhashed(inode)) {
 9332|
 9333|
 9334|
 9335|
 9336|
 9337|  static spinlock_t lock = (spinlock_t ) { { .rlock = { .raw_lock = { 0 }, .magic = 0xdead4ead, .owner_cpu = -1, .owner = ((void *)-1L), .dep_map = { .name = "lock" } } } };
 9338|  __st_spin_lock_st__(&lock);
 9339|  if (inode_unhashed(inode))
 9340|   __insert_inode_hash(inode,
 9341|         inode->i_ino + inode->i_generation);
 9342|  __st_spin_unlock_st__(&lock);
 9343| }
 9344|
 9345| fh[0] = inode->i_generation;
 9346| fh[1] = inode->i_ino;
 9347| fh[2] = ((__u64)inode->i_ino) >> 32;
 9348|
 9349| *len = 3;
 9350| return 1;
 9351|}
 9352|
 9353|static const struct export_operations shmem_export_ops = {
 9354| .get_parent = shmem_get_parent,
 9355| .encode_fh = shmem_encode_fh,
 9356| .fh_to_dentry = shmem_fh_to_dentry,
 9357|};
 9358|
 9359|static int shmem_parse_options(char *options, struct shmem_sb_info *sbinfo,
 9360|          bool remount)
 9361|{
 9362| char *this_char, *value, *rest;
 9363|
 9364| while (options != ((void *)0)) {
 9365|  this_char = options;
 9366|  for (;;) {
 9367|
 9368|
 9369|
 9370|
 9371|
 9372|   options = strchr(options, ',');
 9373|   if (options == ((void *)0))
 9374|    break;
 9375|   options++;
 9376|   if (!(((_ctype[(int)(unsigned char)(*options)])&(0x04)) != 0)) {
 9377|    options[-1] = '\0';
 9378|    break;
 9379|   }
 9380|  }
 9381|  if (!*this_char)
 9382|   continue;
 9383|  if ((value = strchr(this_char,'=')) != ((void *)0)) {
 9384|   *value++ = 0;
 9385|  } else {
 9386|   printk("<3>"
 9387|       "tmpfs: No value for mount option '%s'\n",
 9388|       this_char);
 9389|   return 1;
 9390|  }
 9391|
 9392|  if (!strcmp(this_char,"size")) {
 9393|   unsigned long long size;
 9394|   size = memparse(value,&rest);
 9395|   if (*rest == '%') {
 9396|    size <<= 12;
 9397|    size *= totalram_pages;
 9398|    ({ uint32_t __base = (100); uint32_t __rem; __rem = ((uint64_t)(size)) % __base; (size) = ((uint64_t)(size)) / __base; __rem; });
 9399|    rest++;
 9400|   }
 9401|   if (*rest)
 9402|    goto bad_val;
 9403|   sbinfo->max_blocks =
 9404|    (((size) + (((1UL) << 12)) - 1) / (((1UL) << 12)));
 9405|  } else if (!strcmp(this_char,"nr_blocks")) {
 9406|   sbinfo->max_blocks = memparse(value, &rest);
 9407|   if (*rest)
 9408|    goto bad_val;
 9409|  } else if (!strcmp(this_char,"nr_inodes")) {
 9410|   sbinfo->max_inodes = memparse(value, &rest);
 9411|   if (*rest)
 9412|    goto bad_val;
 9413|  } else if (!strcmp(this_char,"mode")) {
 9414|   if (remount)
 9415|    continue;
 9416|   sbinfo->mode = simple_strtoul(value, &rest, 8) & 07777;
 9417|   if (*rest)
 9418|    goto bad_val;
 9419|  } else if (!strcmp(this_char,"uid")) {
 9420|   if (remount)
 9421|    continue;
 9422|   sbinfo->uid = simple_strtoul(value, &rest, 0);
 9423|   if (*rest)
 9424|    goto bad_val;
 9425|  } else if (!strcmp(this_char,"gid")) {
 9426|   if (remount)
 9427|    continue;
 9428|   sbinfo->gid = simple_strtoul(value, &rest, 0);
 9429|   if (*rest)
 9430|    goto bad_val;
 9431|  } else if (!strcmp(this_char,"mpol")) {
 9432|   if (mpol_parse_str(value, &sbinfo->mpol, 1))
 9433|    goto bad_val;
 9434|  } else {
 9435|   printk("<3>" "tmpfs: Bad mount option %s\n",
 9436|          this_char);
 9437|   return 1;
 9438|  }
 9439| }
 9440| return 0;
 9441|
 9442|bad_val:
 9443| printk("<3>" "tmpfs: Bad value '%s' for mount option '%s'\n",
 9444|        value, this_char);
 9445| return 1;
 9446|
 9447|}
 9448|
 9449|static int shmem_remount_fs(struct super_block *sb, int *flags, char *data)
 9450|{
 9451| struct shmem_sb_info *sbinfo = SHMEM_SB(sb);
 9452| struct shmem_sb_info config = *sbinfo;
 9453| unsigned long inodes;
 9454| int error = -22;
 9455|
 9456| if (shmem_parse_options(data, &config, true))
 9457|  return error;
 9458|
 9459| __st_spin_lock_st__(&sbinfo->stat_lock);
 9460| inodes = sbinfo->max_inodes - sbinfo->free_inodes;
 9461| if (percpu_counter_compare(&sbinfo->used_blocks, config.max_blocks) > 0)
 9462|  goto out;
 9463| if (config.max_inodes < inodes)
 9464|  goto out;
 9465|
 9466|
 9467|
 9468|
 9469|
 9470|
 9471| if (config.max_blocks && !sbinfo->max_blocks)
 9472|  goto out;
 9473| if (config.max_inodes && !sbinfo->max_inodes)
 9474|  goto out;
 9475|
 9476| error = 0;
 9477| sbinfo->max_blocks = config.max_blocks;
 9478| sbinfo->max_inodes = config.max_inodes;
 9479| sbinfo->free_inodes = config.max_inodes - inodes;
 9480|
 9481| mpol_put(sbinfo->mpol);
 9482| sbinfo->mpol = config.mpol;
 9483|out:
 9484| __st_spin_unlock_st__(&sbinfo->stat_lock);
 9485| return error;
 9486|}
 9487|
 9488|static int shmem_show_options(struct seq_file *seq, struct vfsmount *vfs)
 9489|{
 9490| struct shmem_sb_info *sbinfo = SHMEM_SB(vfs->mnt_sb);
 9491|
 9492| if (sbinfo->max_blocks != shmem_default_max_blocks())
 9493|  seq_printf(seq, ",size=%luk",
 9494|   sbinfo->max_blocks << (12 - 10));
 9495| if (sbinfo->max_inodes != shmem_default_max_inodes())
 9496|  seq_printf(seq, ",nr_inodes=%lu", sbinfo->max_inodes);
 9497| if (sbinfo->mode != ((00700|00070|00007) | 0001000))
 9498|  seq_printf(seq, ",mode=%03o", sbinfo->mode);
 9499| if (sbinfo->uid != 0)
 9500|  seq_printf(seq, ",uid=%u", sbinfo->uid);
 9501| if (sbinfo->gid != 0)
 9502|  seq_printf(seq, ",gid=%u", sbinfo->gid);
 9503| shmem_show_mpol(seq, sbinfo->mpol);
 9504| return 0;
 9505|}
 9506|
 9507|
 9508|static void shmem_put_super(struct super_block *sb)
 9509|{
 9510| struct shmem_sb_info *sbinfo = SHMEM_SB(sb);
 9511|
 9512| percpu_counter_destroy(&sbinfo->used_blocks);
 9513| kfree(sbinfo);
 9514| sb->s_fs_info = ((void *)0);
 9515|}
 9516|
 9517|int shmem_fill_super(struct super_block *sb, void *data, int silent)
 9518|{
 9519| struct inode *inode;
 9520| struct dentry *root;
 9521| struct shmem_sb_info *sbinfo;
 9522| int err = -12;
 9523|
 9524|
 9525| sbinfo = kzalloc(({ typeof((int)sizeof(struct shmem_sb_info)) _max1 = ((int)sizeof(struct shmem_sb_info)); typeof((1 << (6))) _max2 = ((1 << (6))); (void) (&_max1 == &_max2); _max1 > _max2 ? _max1 : _max2; })
 9526|                   , __st_GFP_KERNEL_st__);
 9527| if (!sbinfo)
 9528|  return -12;
 9529|
 9530| sbinfo->mode = (00700|00070|00007) | 0001000;
 9531| sbinfo->uid = (({ get_current()->cred->fsuid; }));
 9532| sbinfo->gid = (({ get_current()->cred->fsgid; }));
 9533| sb->s_fs_info = sbinfo;
 9534|
 9535|
 9536|
 9537|
 9538|
 9539|
 9540|
 9541| if (!(sb->s_flags & (1<<31))) {
 9542|  sbinfo->max_blocks = shmem_default_max_blocks();
 9543|  sbinfo->max_inodes = shmem_default_max_inodes();
 9544|  if (shmem_parse_options(data, sbinfo, false)) {
 9545|   err = -22;
 9546|   goto failed;
 9547|  }
 9548| }
 9549| sb->s_export_op = &shmem_export_ops;
 9550|
 9551|
 9552|
 9553|
 9554| do { spinlock_check(&sbinfo->stat_lock); do { static struct lock_class_key __key; __raw_spin_lock_init((&(&sbinfo->stat_lock)->rlock), "&(&sbinfo->stat_lock)->rlock", &__key); } while (0); } while (0);
 9555| if (({ static struct lock_class_key __key; __percpu_counter_init(&sbinfo->used_blocks, 0, &__key); }))
 9556|  goto failed;
 9557| sbinfo->free_inodes = sbinfo->max_inodes;
 9558|
 9559| sb->s_maxbytes = ({ unsigned long long __min1 = (((16 + (((unsigned long long)(((1UL) << 12)/sizeof(unsigned long))*(((1UL) << 12)/sizeof(unsigned long)))/2) * ((((1UL) << 12)/sizeof(unsigned long))+1)) << 12)); unsigned long long __min2 = (0x7fffffffffffffffUL); __min1 < __min2 ? __min1: __min2; });
 9560| sb->s_blocksize = ((1UL) << 12);
 9561| sb->s_blocksize_bits = 12;
 9562| sb->s_magic = 0x01021994;
 9563| sb->s_op = &shmem_ops;
 9564| sb->s_time_gran = 1;
 9565|
 9566| sb->s_xattr = shmem_xattr_handlers;
 9567| sb->s_flags |= (1<<16);
 9568|
 9569|
 9570| inode = shmem_get_inode(sb, ((void *)0), 0040000 | sbinfo->mode, 0, 0x00200000);
 9571| if (!inode)
 9572|  goto failed;
 9573| inode->i_uid = sbinfo->uid;
 9574| inode->i_gid = sbinfo->gid;
 9575| root = d_alloc_root(inode);
 9576| if (!root)
 9577|  goto failed_iput;
 9578| sb->s_root = root;
 9579| return 0;
 9580|
 9581|failed_iput:
 9582| iput(inode);
 9583|failed:
 9584| shmem_put_super(sb);
 9585| return err;
 9586|}
 9587|
 9588|static struct kmem_cache *shmem_inode_cachep;
 9589|
 9590|static struct inode *shmem_alloc_inode(struct super_block *sb)
 9591|{
 9592| struct shmem_inode_info *p;
 9593| p = (struct shmem_inode_info *)kmem_cache_alloc(shmem_inode_cachep, __st_GFP_KERNEL_st__);
 9594| if (!p)
 9595|  return ((void *)0);
 9596| return &p->vfs_inode;
 9597|}
 9598|
 9599|static void shmem_destroy_inode(struct inode *inode)
 9600|{
 9601| if ((inode->i_mode & 00170000) == 0100000) {
 9602|
 9603|  mpol_free_shared_policy(&SHMEM_I(inode)->policy);
 9604| }
 9605| kmem_cache_free(shmem_inode_cachep, SHMEM_I(inode));
 9606|}
 9607|
 9608|static void init_once(void *foo)
 9609|{
 9610| struct shmem_inode_info *p = (struct shmem_inode_info *) foo;
 9611|
 9612| inode_init_once(&p->vfs_inode);
 9613|}
 9614|
 9615|static int init_inodecache(void)
 9616|{
 9617| shmem_inode_cachep = kmem_cache_create("shmem_inode_cache",
 9618|    sizeof(struct shmem_inode_info),
 9619|    0, 0x00040000UL, init_once);
 9620| return 0;
 9621|}
 9622|
 9623|static void destroy_inodecache(void)
 9624|{
 9625| kmem_cache_destroy(shmem_inode_cachep);
 9626|}
 9627|
 9628|static const struct address_space_operations shmem_aops = {
 9629| .writepage = shmem_writepage,
 9630| .set_page_dirty = __set_page_dirty_no_writeback,
 9631|
 9632| .readpage = shmem_readpage,
 9633| .write_begin = shmem_write_begin,
 9634| .write_end = shmem_write_end,
 9635|
 9636| .migratepage = migrate_page,
 9637| .error_remove_page = generic_error_remove_page,
 9638|};
 9639|
 9640|static const struct file_operations shmem_file_operations = {
 9641| .mmap = shmem_mmap,
 9642|
 9643| .llseek = generic_file_llseek,
 9644| .read = do_sync_read,
 9645| .write = do_sync_write,
 9646| .aio_read = shmem_file_aio_read,
 9647| .aio_write = generic_file_aio_write,
 9648| .fsync = noop_fsync,
 9649| .splice_read = generic_file_splice_read,
 9650| .splice_write = generic_file_splice_write,
 9651|
 9652|};
 9653|
 9654|static const struct inode_operations shmem_inode_operations = {
 9655| .setattr = shmem_notify_change,
 9656| .truncate_range = shmem_truncate_range,
 9657|
 9658| .setxattr = generic_setxattr,
 9659| .getxattr = generic_getxattr,
 9660| .listxattr = generic_listxattr,
 9661| .removexattr = generic_removexattr,
 9662| .check_acl = generic_check_acl,
 9663|
 9664|
 9665|};
 9666|
 9667|static const struct inode_operations shmem_dir_inode_operations = {
 9668|
 9669| .create = shmem_create,
 9670| .lookup = simple_lookup,
 9671| .link = shmem_link,
 9672| .unlink = shmem_unlink,
 9673| .symlink = shmem_symlink,
 9674| .mkdir = shmem_mkdir,
 9675| .rmdir = shmem_rmdir,
 9676| .mknod = shmem_mknod,
 9677| .rename = shmem_rename,
 9678|
 9679|
 9680| .setattr = shmem_notify_change,
 9681| .setxattr = generic_setxattr,
 9682| .getxattr = generic_getxattr,
 9683| .listxattr = generic_listxattr,
 9684| .removexattr = generic_removexattr,
 9685| .check_acl = generic_check_acl,
 9686|
 9687|};
 9688|
 9689|static const struct inode_operations shmem_special_inode_operations = {
 9690|
 9691| .setattr = shmem_notify_change,
 9692| .setxattr = generic_setxattr,
 9693| .getxattr = generic_getxattr,
 9694| .listxattr = generic_listxattr,
 9695| .removexattr = generic_removexattr,
 9696| .check_acl = generic_check_acl,
 9697|
 9698|};
 9699|
 9700|static const struct super_operations shmem_ops = {
 9701| .alloc_inode = shmem_alloc_inode,
 9702| .destroy_inode = shmem_destroy_inode,
 9703|
 9704| .statfs = shmem_statfs,
 9705| .remount_fs = shmem_remount_fs,
 9706| .show_options = shmem_show_options,
 9707|
 9708| .evict_inode = shmem_evict_inode,
 9709| .drop_inode = generic_delete_inode,
 9710| .put_super = shmem_put_super,
 9711|};
 9712|
 9713|static const struct vm_operations_struct shmem_vm_ops = {
 9714| .fault = shmem_fault,
 9715|
 9716| .set_policy = shmem_set_policy,
 9717| .get_policy = shmem_get_policy,
 9718|
 9719|};
 9720|
 9721|
 9722|static struct dentry *shmem_mount(struct file_system_type *fs_type,
 9723| int flags, const char *dev_name, void *data)
 9724|{
 9725| return mount_nodev(fs_type, flags, data, shmem_fill_super);
 9726|}
 9727|
 9728|static struct file_system_type tmpfs_fs_type = {
 9729| .owner = ((struct module *)0),
 9730| .name = "tmpfs",
 9731| .mount = shmem_mount,
 9732| .kill_sb = kill_litter_super,
 9733|};
 9734|
 9735|int init_tmpfs(void)
 9736|{
 9737| int error;
 9738|
 9739| error = bdi_init(&shmem_backing_dev_info);
 9740| if (error)
 9741|  goto out4;
 9742|
 9743| error = init_inodecache();
 9744| if (error)
 9745|  goto out3;
 9746|
 9747| error = register_filesystem(&tmpfs_fs_type);
 9748| if (error) {
 9749|  printk("<3>" "Could not register tmpfs\n");
 9750|  goto out2;
 9751| }
 9752|
 9753| shm_mnt = vfs_kern_mount(&tmpfs_fs_type, (1<<31),
 9754|    tmpfs_fs_type.name, ((void *)0));
 9755| if (IS_ERR(shm_mnt)) {
 9756|  error = PTR_ERR(shm_mnt);
 9757|  printk("<3>" "Could not kern_mount tmpfs\n");
 9758|  goto out1;
 9759| }
 9760| return 0;
 9761|
 9762|out1:
 9763| unregister_filesystem(&tmpfs_fs_type);
 9764|out2:
 9765| destroy_inodecache();
 9766|out3:
 9767| bdi_destroy(&shmem_backing_dev_info);
 9768|out4:
 9769| shm_mnt = ERR_PTR(error);
 9770| return error;
 9771|}
 9772|void mem_cgroup_get_shmem_target(struct inode *inode, unsigned long pgoff,
 9773|     struct page **pagep, swp_entry_t *ent)
 9774|{
 9775| swp_entry_t entry = { .val = 0 }, *ptr;
 9776| struct page *page = ((void *)0);
 9777| struct shmem_inode_info *info = SHMEM_I(inode);
 9778|
 9779| if ((pgoff << 12) >= i_size_read(inode))
 9780|  goto out;
 9781|
 9782| __st_spin_lock_st__(&info->lock);
 9783| ptr = shmem_swp_entry(info, pgoff, ((void *)0));
 9784|
 9785| if (ptr && ptr->val) {
 9786|  entry.val = ptr->val;
 9787|  page = find_get_page(&swapper_space, entry.val);
 9788| } else
 9789|
 9790|  page = find_get_page(inode->i_mapping, pgoff);
 9791| if (ptr)
 9792|  shmem_swp_unmap(ptr);
 9793| __st_spin_unlock_st__(&info->lock);
 9794|out:
 9795| *pagep = page;
 9796| *ent = entry;
 9797|}
 9798|struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags)
 9799|{
 9800| int error;
 9801| struct file *file;
 9802| struct inode *inode;
 9803| struct path path;
 9804| struct dentry *root;
 9805| struct qstr this;
 9806|
 9807| if (IS_ERR(shm_mnt))
 9808|  return (void *)shm_mnt;
 9809|
 9810| if (size < 0 || size > ({ unsigned long long __min1 = (((16 + (((unsigned long long)(((1UL) << 12)/sizeof(unsigned long))*(((1UL) << 12)/sizeof(unsigned long)))/2) * ((((1UL) << 12)/sizeof(unsigned long))+1)) << 12)); unsigned long long __min2 = (0x7fffffffffffffffUL); __min1 < __min2 ? __min1: __min2; }))
 9811|  return ERR_PTR(-22);
 9812|
 9813| if (shmem_acct_size(flags, size))
 9814|  return ERR_PTR(-12);
 9815|
 9816| error = -12;
 9817| this.name = name;
 9818| this.len = strlen(name);
 9819| this.hash = 0;
 9820| root = shm_mnt->mnt_root;
 9821| path.dentry = d_alloc(root, &this);
 9822| if (!path.dentry)
 9823|  goto put_memory;
 9824| path.mnt = mntget(shm_mnt);
 9825|
 9826| error = -28;
 9827| inode = shmem_get_inode(root->d_sb, ((void *)0), 0100000 | (00700|00070|00007), 0, flags);
 9828| if (!inode)
 9829|  goto put_dentry;
 9830|
 9831| d_instantiate(path.dentry, inode);
 9832| inode->i_size = size;
 9833| inode->i_nlink = 0;
 9834|
 9835|
 9836|
 9837|
 9838|
 9839|
 9840| error = -23;
 9841| file = alloc_file(&path, (( fmode_t)0x2) | (( fmode_t)0x1),
 9842|    &shmem_file_operations);
 9843| if (!file)
 9844|  goto put_dentry;
 9845|
 9846| return file;
 9847|
 9848|put_dentry:
 9849| path_put(&path);
 9850|put_memory:
 9851| shmem_unacct_size(flags, size);
 9852| return ERR_PTR(error);
 9853|}
 9854|extern typeof(shmem_file_setup) shmem_file_setup; extern void *__crc_shmem_file_setup ; static const unsigned long __kcrctab_shmem_file_setup = (unsigned long) &__crc_shmem_file_setup; static const char __kstrtab_shmem_file_setup[] = "" "shmem_file_setup"; static const struct kernel_symbol __ksymtab_shmem_file_setup = { (unsigned long)&shmem_file_setup, __kstrtab_shmem_file_setup };
 9855|
 9856|
 9857|
 9858|
 9859|
 9860|int shmem_zero_setup(struct vm_area_struct *vma)
 9861|{
 9862| struct file *file;
 9863| loff_t size = vma->vm_end - vma->vm_start;
 9864|
 9865| file = shmem_file_setup("dev/zero", size, vma->vm_flags);
 9866| if (IS_ERR(file))
 9867|  return PTR_ERR(file);
 9868|
 9869| if (vma->vm_file)
 9870|  fput(vma->vm_file);
 9871| vma->vm_file = file;
 9872| vma->vm_ops = &shmem_vm_ops;
 9873| return 0;
 9874|}