diff options
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/fscache-cache.h | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h index e3d6d939d959..f5facd1d333f 100644 --- a/include/linux/fscache-cache.h +++ b/include/linux/fscache-cache.h | |||
@@ -75,6 +75,16 @@ extern wait_queue_head_t fscache_cache_cleared_wq; | |||
75 | typedef void (*fscache_operation_release_t)(struct fscache_operation *op); | 75 | typedef void (*fscache_operation_release_t)(struct fscache_operation *op); |
76 | typedef void (*fscache_operation_processor_t)(struct fscache_operation *op); | 76 | typedef void (*fscache_operation_processor_t)(struct fscache_operation *op); |
77 | 77 | ||
78 | enum fscache_operation_state { | ||
79 | FSCACHE_OP_ST_BLANK, /* Op is not yet submitted */ | ||
80 | FSCACHE_OP_ST_INITIALISED, /* Op is initialised */ | ||
81 | FSCACHE_OP_ST_PENDING, /* Op is blocked from running */ | ||
82 | FSCACHE_OP_ST_IN_PROGRESS, /* Op is in progress */ | ||
83 | FSCACHE_OP_ST_COMPLETE, /* Op is complete */ | ||
84 | FSCACHE_OP_ST_CANCELLED, /* Op has been cancelled */ | ||
85 | FSCACHE_OP_ST_DEAD /* Op is now dead */ | ||
86 | }; | ||
87 | |||
78 | struct fscache_operation { | 88 | struct fscache_operation { |
79 | struct work_struct work; /* record for async ops */ | 89 | struct work_struct work; /* record for async ops */ |
80 | struct list_head pend_link; /* link in object->pending_ops */ | 90 | struct list_head pend_link; /* link in object->pending_ops */ |
@@ -86,10 +96,10 @@ struct fscache_operation { | |||
86 | #define FSCACHE_OP_MYTHREAD 0x0002 /* - processing is done be issuing thread, not pool */ | 96 | #define FSCACHE_OP_MYTHREAD 0x0002 /* - processing is done be issuing thread, not pool */ |
87 | #define FSCACHE_OP_WAITING 4 /* cleared when op is woken */ | 97 | #define FSCACHE_OP_WAITING 4 /* cleared when op is woken */ |
88 | #define FSCACHE_OP_EXCLUSIVE 5 /* exclusive op, other ops must wait */ | 98 | #define FSCACHE_OP_EXCLUSIVE 5 /* exclusive op, other ops must wait */ |
89 | #define FSCACHE_OP_DEAD 6 /* op is now dead */ | 99 | #define FSCACHE_OP_DEC_READ_CNT 6 /* decrement object->n_reads on destruction */ |
90 | #define FSCACHE_OP_DEC_READ_CNT 7 /* decrement object->n_reads on destruction */ | 100 | #define FSCACHE_OP_KEEP_FLAGS 0x0070 /* flags to keep when repurposing an op */ |
91 | #define FSCACHE_OP_KEEP_FLAGS 0xc0 /* flags to keep when repurposing an op */ | ||
92 | 101 | ||
102 | enum fscache_operation_state state; | ||
93 | atomic_t usage; | 103 | atomic_t usage; |
94 | unsigned debug_id; /* debugging ID */ | 104 | unsigned debug_id; /* debugging ID */ |
95 | 105 | ||
@@ -106,6 +116,7 @@ extern atomic_t fscache_op_debug_id; | |||
106 | extern void fscache_op_work_func(struct work_struct *work); | 116 | extern void fscache_op_work_func(struct work_struct *work); |
107 | 117 | ||
108 | extern void fscache_enqueue_operation(struct fscache_operation *); | 118 | extern void fscache_enqueue_operation(struct fscache_operation *); |
119 | extern void fscache_op_complete(struct fscache_operation *); | ||
109 | extern void fscache_put_operation(struct fscache_operation *); | 120 | extern void fscache_put_operation(struct fscache_operation *); |
110 | 121 | ||
111 | /** | 122 | /** |
@@ -122,6 +133,7 @@ static inline void fscache_operation_init(struct fscache_operation *op, | |||
122 | { | 133 | { |
123 | INIT_WORK(&op->work, fscache_op_work_func); | 134 | INIT_WORK(&op->work, fscache_op_work_func); |
124 | atomic_set(&op->usage, 1); | 135 | atomic_set(&op->usage, 1); |
136 | op->state = FSCACHE_OP_ST_INITIALISED; | ||
125 | op->debug_id = atomic_inc_return(&fscache_op_debug_id); | 137 | op->debug_id = atomic_inc_return(&fscache_op_debug_id); |
126 | op->processor = processor; | 138 | op->processor = processor; |
127 | op->release = release; | 139 | op->release = release; |
@@ -138,6 +150,7 @@ struct fscache_retrieval { | |||
138 | void *context; /* netfs read context (pinned) */ | 150 | void *context; /* netfs read context (pinned) */ |
139 | struct list_head to_do; /* list of things to be done by the backend */ | 151 | struct list_head to_do; /* list of things to be done by the backend */ |
140 | unsigned long start_time; /* time at which retrieval started */ | 152 | unsigned long start_time; /* time at which retrieval started */ |
153 | unsigned n_pages; /* number of pages to be retrieved */ | ||
141 | }; | 154 | }; |
142 | 155 | ||
143 | typedef int (*fscache_page_retrieval_func_t)(struct fscache_retrieval *op, | 156 | typedef int (*fscache_page_retrieval_func_t)(struct fscache_retrieval *op, |
@@ -174,8 +187,22 @@ static inline void fscache_enqueue_retrieval(struct fscache_retrieval *op) | |||
174 | } | 187 | } |
175 | 188 | ||
176 | /** | 189 | /** |
190 | * fscache_retrieval_complete - Record (partial) completion of a retrieval | ||
191 | * @op: The retrieval operation affected | ||
192 | * @n_pages: The number of pages to account for | ||
193 | */ | ||
194 | static inline void fscache_retrieval_complete(struct fscache_retrieval *op, | ||
195 | int n_pages) | ||
196 | { | ||
197 | op->n_pages -= n_pages; | ||
198 | if (op->n_pages <= 0) | ||
199 | fscache_op_complete(&op->op); | ||
200 | } | ||
201 | |||
202 | /** | ||
177 | * fscache_put_retrieval - Drop a reference to a retrieval operation | 203 | * fscache_put_retrieval - Drop a reference to a retrieval operation |
178 | * @op: The retrieval operation affected | 204 | * @op: The retrieval operation affected |
205 | * @n_pages: The number of pages to account for | ||
179 | * | 206 | * |
180 | * Drop a reference to a retrieval operation. | 207 | * Drop a reference to a retrieval operation. |
181 | */ | 208 | */ |
@@ -333,10 +360,10 @@ struct fscache_object { | |||
333 | 360 | ||
334 | int debug_id; /* debugging ID */ | 361 | int debug_id; /* debugging ID */ |
335 | int n_children; /* number of child objects */ | 362 | int n_children; /* number of child objects */ |
336 | int n_ops; /* number of ops outstanding on object */ | 363 | int n_ops; /* number of extant ops on object */ |
337 | int n_obj_ops; /* number of object ops outstanding on object */ | 364 | int n_obj_ops; /* number of object ops outstanding on object */ |
338 | int n_in_progress; /* number of ops in progress */ | 365 | int n_in_progress; /* number of ops in progress */ |
339 | int n_exclusive; /* number of exclusive ops queued */ | 366 | int n_exclusive; /* number of exclusive ops queued or in progress */ |
340 | atomic_t n_reads; /* number of read ops in progress */ | 367 | atomic_t n_reads; /* number of read ops in progress */ |
341 | spinlock_t lock; /* state and operations lock */ | 368 | spinlock_t lock; /* state and operations lock */ |
342 | 369 | ||