Skip to content

Commit adcf34a

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

4 files changed

Lines changed: 29 additions & 14 deletions

File tree

‎fs/orangefs/devorangefs-req.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ static long dispatch_ioctl_command(unsigned int command, unsigned long arg)
590590
* remount all mounted orangefs volumes to regain the lost
591591
* dynamic mount tables (if any) -- NOTE: this is done
592592
* without keeping the superblock list locked due to the
593-
* upcall/downcall waiting. also, the request semaphore is
593+
* upcall/downcall waiting. also, the request mutex is
594594
* used to ensure that no operations will be serviced until
595595
* all of the remounts are serviced (to avoid ops between
596596
* mounts to fail)

‎fs/orangefs/orangefs-kernel.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ extern wait_queue_head_t orangefs_bufmap_init_waitq;
603603
#define ORANGEFS_OP_INTERRUPTIBLE 1 /* service_operation() is interruptible */
604604
#define ORANGEFS_OP_PRIORITY 2 /* service_operation() is high priority */
605605
#define ORANGEFS_OP_CANCELLATION 4 /* this is a cancellation */
606-
#define ORANGEFS_OP_NO_SEMAPHORE 8 /* don't acquire semaphore */
606+
#define ORANGEFS_OP_NO_MUTEX 8 /* don't acquire request_mutex */
607607
#define ORANGEFS_OP_ASYNC 16 /* Queue it, but don't wait */
608608

609609
int service_operation(struct orangefs_kernel_op_s *op,

‎fs/orangefs/super.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,12 @@ int orangefs_remount(struct super_block *sb)
229229
new_op->upcall.req.fs_mount.orangefs_config_server);
230230

231231
/*
232-
* we assume that the calling function has already acquire the
232+
* we assume that the calling function has already acquired the
233233
* request_mutex to prevent other operations from bypassing
234234
* this one
235235
*/
236236
ret = service_operation(new_op, "orangefs_remount",
237-
ORANGEFS_OP_PRIORITY | ORANGEFS_OP_NO_SEMAPHORE);
237+
ORANGEFS_OP_PRIORITY | ORANGEFS_OP_NO_MUTEX);
238238
gossip_debug(GOSSIP_SUPER_DEBUG,
239239
"orangefs_remount: mount got return value of %d\n",
240240
ret);

‎fs/orangefs/waitqueue.c‎

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ int service_operation(struct orangefs_kernel_op_s *op,
5656
int flags)
5757
{
5858
long timeout = MAX_SCHEDULE_TIMEOUT;
59-
/* flags to modify behavior */
6059
int ret = 0;
6160

6261
DEFINE_WAIT(wait_entry);
@@ -74,14 +73,20 @@ int service_operation(struct orangefs_kernel_op_s *op,
7473
current->comm,
7574
current->pid);
7675

77-
if (!(flags & ORANGEFS_OP_NO_SEMAPHORE)) {
76+
/*
77+
* If ORANGEFS_OP_NO_MUTEX was set in flags, we need to avoid
78+
* aquiring the request_mutex because we're servicing a
79+
* high priority remount operation and the request_mutex is
80+
* already taken.
81+
*/
82+
if (!(flags & ORANGEFS_OP_NO_MUTEX)) {
7883
if (flags & ORANGEFS_OP_INTERRUPTIBLE)
7984
ret = mutex_lock_interruptible(&request_mutex);
8085
else
8186
ret = mutex_lock_killable(&request_mutex);
8287
/*
8388
* check to see if we were interrupted while waiting for
84-
* semaphore
89+
* mutex
8590
*/
8691
if (ret < 0) {
8792
op->downcall.status = ret;
@@ -95,6 +100,7 @@ int service_operation(struct orangefs_kernel_op_s *op,
95100
spin_lock(&orangefs_request_list_lock);
96101
spin_lock(&op->lock);
97102
set_op_state_waiting(op);
103+
/* add high priority remount op to the front of the line. */
98104
if (flags & ORANGEFS_OP_PRIORITY)
99105
list_add(&op->list, &orangefs_request_list);
100106
else
@@ -109,7 +115,7 @@ int service_operation(struct orangefs_kernel_op_s *op,
109115
}
110116
spin_unlock(&orangefs_request_list_lock);
111117

112-
if (!(flags & ORANGEFS_OP_NO_SEMAPHORE))
118+
if (!(flags & ORANGEFS_OP_NO_MUTEX))
113119
mutex_unlock(&request_mutex);
114120

115121
ret = wait_for_matching_downcall(op, timeout,
@@ -132,10 +138,17 @@ int service_operation(struct orangefs_kernel_op_s *op,
132138

133139
/* failed to get matching downcall */
134140
if (ret == -ETIMEDOUT) {
135-
gossip_err("orangefs: %s -- wait timed out; aborting attempt.\n",
141+
gossip_err("%s: %s -- wait timed out; aborting attempt.\n",
142+
__func__,
136143
op_name);
137144
}
145+
146+
/*
147+
* remove waiting ops from the request list or
148+
* remove in-progress ops from the in-progress list.
149+
*/
138150
orangefs_clean_up_interrupted_operation(op);
151+
139152
op->downcall.status = ret;
140153
/* retry if operation has not been serviced and if requested */
141154
if (ret == -EAGAIN) {
@@ -148,11 +161,12 @@ int service_operation(struct orangefs_kernel_op_s *op,
148161
op_name,
149162
op->attempts);
150163

164+
/*
165+
* io ops (ops that use the shared memory buffer) have
166+
* to be returned to their caller for a retry. Other ops
167+
* can just be recycled here.
168+
*/
151169
if (!op->uses_shared_memory)
152-
/*
153-
* this operation doesn't use the shared memory
154-
* system
155-
*/
156170
goto retry_servicing;
157171
}
158172

@@ -268,7 +282,8 @@ static int wait_for_matching_downcall(struct orangefs_kernel_op_s *op,
268282
long n;
269283

270284
if (interruptible)
271-
n = wait_for_completion_interruptible_timeout(&op->waitq, timeout);
285+
n = wait_for_completion_interruptible_timeout(&op->waitq,
286+
timeout);
272287
else
273288
n = wait_for_completion_killable_timeout(&op->waitq, timeout);
274289

0 commit comments

Comments
 (0)