Skip to content

Commit ca9f518

Browse files
committed
Orangefs: code sanitation.
Signed-off-by: Mike Marshall <hubcap@omnibond.com>
1 parent 401898e commit ca9f518

3 files changed

Lines changed: 46 additions & 29 deletions

File tree

‎fs/orangefs/devorangefs-req.c‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ static void orangefs_devreq_add_op(struct orangefs_kernel_op_s *op)
4646
list_add_tail(&op->list, &htable_ops_in_progress[index]);
4747
}
4848

49+
/*
50+
* find the op with this tag and remove it from the in progress
51+
* hash table.
52+
*/
4953
static struct orangefs_kernel_op_s *orangefs_devreq_remove_op(__u64 tag)
5054
{
5155
struct orangefs_kernel_op_s *op, *next;
@@ -190,8 +194,10 @@ static ssize_t orangefs_devreq_read(struct file *file,
190194
return -EAGAIN;
191195
}
192196

193-
gossip_debug(GOSSIP_DEV_DEBUG, "orangefs: reading op tag %llu %s\n",
194-
llu(cur_op->tag), get_opname_string(cur_op));
197+
gossip_debug(GOSSIP_DEV_DEBUG, "%s: reading op tag %llu %s\n",
198+
__func__,
199+
llu(cur_op->tag),
200+
get_opname_string(cur_op));
195201

196202
/*
197203
* Such an op should never be on the list in the first place. If so, we
@@ -204,6 +210,7 @@ static ssize_t orangefs_devreq_read(struct file *file,
204210
spin_unlock(&orangefs_request_list_lock);
205211
return -EAGAIN;
206212
}
213+
207214
list_del_init(&cur_op->list);
208215
spin_unlock(&orangefs_request_list_lock);
209216

@@ -323,6 +330,7 @@ static ssize_t orangefs_devreq_write_iter(struct kiocb *iocb,
323330
return -EPROTO;
324331
}
325332

333+
/* remove the op from the in progress hash table */
326334
op = orangefs_devreq_remove_op(head.tag);
327335
if (!op) {
328336
gossip_err("WARNING: No one's waiting for tag %llu\n",
@@ -486,15 +494,7 @@ static int orangefs_devreq_release(struct inode *inode, struct file *file)
486494
gossip_debug(GOSSIP_DEV_DEBUG, "ORANGEFS Device Close: Filesystem(s) %s\n",
487495
(unmounted ? "UNMOUNTED" : "MOUNTED"));
488496

489-
/*
490-
* Walk through the list of ops in the request list, mark them
491-
* as purged and wake them up.
492-
*/
493497
purge_waiting_ops();
494-
/*
495-
* Walk through the hash table of in progress operations; mark
496-
* them as purged and wake them up
497-
*/
498498
purge_inprogress_ops();
499499

500500
orangefs_bufmap_run_down();

‎fs/orangefs/orangefs-mod.c‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,10 @@ static int __init orangefs_init(void)
119119
if (gossip_debug_mask != 0)
120120
kernel_mask_set_mod_init = true;
121121

122-
/* print information message to the system log */
123-
pr_info("orangefs: orangefs_init called with debug mask: :%s: :%llx:\n",
124-
kernel_debug_string,
125-
(unsigned long long)gossip_debug_mask);
122+
pr_info("%s: called with debug mask: :%s: :%llx:\n",
123+
__func__,
124+
kernel_debug_string,
125+
(unsigned long long)gossip_debug_mask);
126126

127127
ret = bdi_init(&orangefs_backing_dev_info);
128128

@@ -147,7 +147,8 @@ static int __init orangefs_init(void)
147147
/* Initialize the orangefsdev subsystem. */
148148
ret = orangefs_dev_init();
149149
if (ret < 0) {
150-
gossip_err("orangefs: could not initialize device subsystem %d!\n",
150+
gossip_err("%s: could not initialize device subsystem %d!\n",
151+
__func__,
151152
ret);
152153
goto cleanup_inode;
153154
}

‎fs/orangefs/waitqueue.c‎

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ int service_operation(struct orangefs_kernel_op_s *op,
7575

7676
/*
7777
* If ORANGEFS_OP_NO_MUTEX was set in flags, we need to avoid
78-
* aquiring the request_mutex because we're servicing a
78+
* acquiring the request_mutex because we're servicing a
7979
* high priority remount operation and the request_mutex is
8080
* already taken.
8181
*/
@@ -91,7 +91,8 @@ int service_operation(struct orangefs_kernel_op_s *op,
9191
if (ret < 0) {
9292
op->downcall.status = ret;
9393
gossip_debug(GOSSIP_WAIT_DEBUG,
94-
"orangefs: service_operation interrupted.\n");
94+
"%s: service_operation interrupted.\n",
95+
__func__);
9596
return ret;
9697
}
9798
}
@@ -127,9 +128,9 @@ int service_operation(struct orangefs_kernel_op_s *op,
127128
ret,
128129
op);
129130

131+
/* got matching downcall; make sure status is in errno format */
130132
if (!ret) {
131133
spin_unlock(&op->lock);
132-
/* got matching downcall; make sure status is in errno format */
133134
op->downcall.status =
134135
orangefs_normalize_to_errno(op->downcall.status);
135136
ret = op->downcall.status;
@@ -144,8 +145,8 @@ int service_operation(struct orangefs_kernel_op_s *op,
144145
}
145146

146147
/*
147-
* remove waiting ops from the request list or
148-
* remove in-progress ops from the in-progress list.
148+
* remove a waiting op from the request list or
149+
* remove an in-progress op from the in-progress list.
149150
*/
150151
orangefs_clean_up_interrupted_operation(op);
151152

@@ -179,6 +180,7 @@ int service_operation(struct orangefs_kernel_op_s *op,
179180
return ret;
180181
}
181182

183+
/* This can get called on an I/O op if it had a bad service_operation. */
182184
bool orangefs_cancel_op_in_progress(struct orangefs_kernel_op_s *op)
183185
{
184186
u64 tag = op->tag;
@@ -206,23 +208,31 @@ bool orangefs_cancel_op_in_progress(struct orangefs_kernel_op_s *op)
206208
spin_unlock(&op->lock);
207209
spin_unlock(&orangefs_request_list_lock);
208210

209-
gossip_debug(GOSSIP_UTILS_DEBUG,
211+
gossip_debug(GOSSIP_WAIT_DEBUG,
210212
"Attempting ORANGEFS operation cancellation of tag %llu\n",
211213
llu(tag));
212214
return true;
213215
}
214216

215-
static void orangefs_clean_up_interrupted_operation(struct orangefs_kernel_op_s *op)
217+
/*
218+
* Change an op to the "given up" state and remove it from its list.
219+
*/
220+
static void
221+
orangefs_clean_up_interrupted_operation(struct orangefs_kernel_op_s *op)
216222
{
217223
/*
218224
* handle interrupted cases depending on what state we were in when
219-
* the interruption is detected. there is a coarse grained lock
220-
* across the operation.
225+
* the interruption is detected.
221226
*
222227
* Called with op->lock held.
223228
*/
229+
230+
/*
231+
* List manipulation code elsewhere will ignore ops that
232+
* have been given up upon.
233+
*/
224234
op->op_state |= OP_VFS_STATE_GIVEN_UP;
225-
/* from that point on it can't be moved by anybody else */
235+
226236
if (list_empty(&op->list)) {
227237
/* caught copying to/from daemon */
228238
BUG_ON(op_state_serviced(op));
@@ -259,12 +269,12 @@ static void orangefs_clean_up_interrupted_operation(struct orangefs_kernel_op_s
259269
}
260270

261271
/*
262-
* sleeps on waitqueue waiting for matching downcall.
263-
* if client-core finishes servicing, then we are good to go.
272+
* Sleeps on waitqueue waiting for matching downcall.
273+
* If client-core finishes servicing, then we are good to go.
264274
* else if client-core exits, we get woken up here, and retry with a timeout
265275
*
266-
* Post when this call returns to the caller, the specified op will no
267-
* longer be on any list or htable.
276+
* When this call returns to the caller, the specified op will no
277+
* longer be in either the in_progress hash table or on the request list.
268278
*
269279
* Returns 0 on success and -errno on failure
270280
* Errors are:
@@ -281,6 +291,12 @@ static int wait_for_matching_downcall(struct orangefs_kernel_op_s *op,
281291
{
282292
long n;
283293

294+
/*
295+
* There's a "schedule_timeout" inside of these wait
296+
* primitives, during which the op is out of the hands of the
297+
* user process that needs something done and is being
298+
* manipulated by the client-core process.
299+
*/
284300
if (interruptible)
285301
n = wait_for_completion_interruptible_timeout(&op->waitq,
286302
timeout);

0 commit comments

Comments
 (0)