Lines Matching +full:wr +full:- +full:active
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright 1997-1998 Transmeta Corporation -- All Rights Reserved
4 * Copyright 2001-2006 Ian Kent <raven@themaw.net>
19 mutex_lock(&sbi->wq_mutex); in autofs_catatonic_mode()
20 if (sbi->flags & AUTOFS_SBI_CATATONIC) { in autofs_catatonic_mode()
21 mutex_unlock(&sbi->wq_mutex); in autofs_catatonic_mode()
27 sbi->flags |= AUTOFS_SBI_CATATONIC; in autofs_catatonic_mode()
28 wq = sbi->queues; in autofs_catatonic_mode()
29 sbi->queues = NULL; /* Erase all wait queues */ in autofs_catatonic_mode()
31 nwq = wq->next; in autofs_catatonic_mode()
32 wq->status = -ENOENT; /* Magic is gone - report failure */ in autofs_catatonic_mode()
33 kfree(wq->name.name - wq->offset); in autofs_catatonic_mode()
34 wq->name.name = NULL; in autofs_catatonic_mode()
35 wq->wait_ctr--; in autofs_catatonic_mode()
36 wake_up_interruptible(&wq->queue); in autofs_catatonic_mode()
39 fput(sbi->pipe); /* Close the pipe */ in autofs_catatonic_mode()
40 sbi->pipe = NULL; in autofs_catatonic_mode()
41 sbi->pipefd = -1; in autofs_catatonic_mode()
42 mutex_unlock(&sbi->wq_mutex); in autofs_catatonic_mode()
50 ssize_t wr = 0; in autofs_write() local
52 sigpipe = sigismember(¤t->pending.signal, SIGPIPE); in autofs_write()
54 mutex_lock(&sbi->pipe_mutex); in autofs_write()
56 wr = __kernel_write(file, data, bytes, NULL); in autofs_write()
57 if (wr <= 0) in autofs_write()
59 data += wr; in autofs_write()
60 bytes -= wr; in autofs_write()
62 mutex_unlock(&sbi->pipe_mutex); in autofs_write()
67 if (wr == -EPIPE && !sigpipe) { in autofs_write()
68 spin_lock_irqsave(¤t->sighand->siglock, flags); in autofs_write()
69 sigdelset(¤t->pending.signal, SIGPIPE); in autofs_write()
71 spin_unlock_irqrestore(¤t->sighand->siglock, flags); in autofs_write()
74 /* if 'wr' returned 0 (impossible) we assume -EIO (safe) */ in autofs_write()
75 return bytes == 0 ? 0 : wr < 0 ? wr : -EIO; in autofs_write()
92 (unsigned long) wq->wait_queue_token, in autofs_notify_daemon()
93 wq->name.len, wq->name.name, type); in autofs_notify_daemon()
97 pkt.hdr.proto_version = sbi->version; in autofs_notify_daemon()
108 mp->wait_queue_token = wq->wait_queue_token; in autofs_notify_daemon()
109 mp->len = wq->name.len; in autofs_notify_daemon()
110 memcpy(mp->name, wq->name.name, wq->name.len); in autofs_notify_daemon()
111 mp->name[wq->name.len] = '\0'; in autofs_notify_daemon()
121 ep->wait_queue_token = wq->wait_queue_token; in autofs_notify_daemon()
122 ep->len = wq->name.len; in autofs_notify_daemon()
123 memcpy(ep->name, wq->name.name, wq->name.len); in autofs_notify_daemon()
124 ep->name[wq->name.len] = '\0'; in autofs_notify_daemon()
137 struct user_namespace *user_ns = sbi->pipe->f_cred->user_ns; in autofs_notify_daemon()
141 packet->wait_queue_token = wq->wait_queue_token; in autofs_notify_daemon()
142 packet->len = wq->name.len; in autofs_notify_daemon()
143 memcpy(packet->name, wq->name.name, wq->name.len); in autofs_notify_daemon()
144 packet->name[wq->name.len] = '\0'; in autofs_notify_daemon()
145 packet->dev = wq->dev; in autofs_notify_daemon()
146 packet->ino = wq->ino; in autofs_notify_daemon()
147 packet->uid = from_kuid_munged(user_ns, wq->uid); in autofs_notify_daemon()
148 packet->gid = from_kgid_munged(user_ns, wq->gid); in autofs_notify_daemon()
149 packet->pid = wq->pid; in autofs_notify_daemon()
150 packet->tgid = wq->tgid; in autofs_notify_daemon()
155 mutex_unlock(&sbi->wq_mutex); in autofs_notify_daemon()
159 pipe = get_file(sbi->pipe); in autofs_notify_daemon()
161 mutex_unlock(&sbi->wq_mutex); in autofs_notify_daemon()
166 case -ENOMEM: in autofs_notify_daemon()
167 case -ERESTARTSYS: in autofs_notify_daemon()
169 autofs_wait_release(sbi, wq->wait_queue_token, ret); in autofs_notify_daemon()
183 for (wq = sbi->queues; wq; wq = wq->next) { in autofs_find_wait()
184 if (wq->name.hash == qstr->hash && in autofs_find_wait()
185 wq->name.len == qstr->len && in autofs_find_wait()
186 wq->name.name && in autofs_find_wait()
187 !memcmp(wq->name.name, qstr->name, qstr->len)) in autofs_find_wait()
206 struct dentry *dentry = path->dentry; in validate_request()
210 if (sbi->flags & AUTOFS_SBI_CATATONIC) in validate_request()
211 return -ENOENT; in validate_request()
239 while (ino->flags & AUTOFS_INF_EXPIRING) { in validate_request()
240 mutex_unlock(&sbi->wq_mutex); in validate_request()
242 if (mutex_lock_interruptible(&sbi->wq_mutex)) in validate_request()
243 return -EINTR; in validate_request()
245 if (sbi->flags & AUTOFS_SBI_CATATONIC) in validate_request()
246 return -ENOENT; in validate_request()
276 * a multi-mount with no mount at it's base) we can in validate_request()
282 struct dentry *parent = dentry->d_parent; in validate_request()
284 new = d_lookup(parent, &dentry->d_name); in validate_request()
289 this.mnt = path->mnt; in validate_request()
305 struct dentry *dentry = path->dentry; in autofs_wait()
315 if (sbi->flags & AUTOFS_SBI_CATATONIC) in autofs_wait()
316 return -ENOENT; in autofs_wait()
323 pid = task_pid_nr_ns(current, ns_of_pid(sbi->oz_pgrp)); in autofs_wait()
324 tgid = task_tgid_nr_ns(current, ns_of_pid(sbi->oz_pgrp)); in autofs_wait()
326 return -ENOENT; in autofs_wait()
337 if (autofs_type_trigger(sbi->type)) in autofs_wait()
338 return -ENOENT; in autofs_wait()
339 else if (!IS_ROOT(dentry->d_parent)) in autofs_wait()
340 return -ENOENT; in autofs_wait()
345 return -ENOMEM; in autofs_wait()
348 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type)) { in autofs_wait()
355 return -ENOENT; in autofs_wait()
359 offset = p - name; in autofs_wait()
363 if (mutex_lock_interruptible(&sbi->wq_mutex)) { in autofs_wait()
365 return -EINTR; in autofs_wait()
370 if (ret != -EINTR) in autofs_wait()
371 mutex_unlock(&sbi->wq_mutex); in autofs_wait()
381 mutex_unlock(&sbi->wq_mutex); in autofs_wait()
382 return -ENOMEM; in autofs_wait()
385 wq->wait_queue_token = autofs_next_wait_queue; in autofs_wait()
388 wq->next = sbi->queues; in autofs_wait()
389 sbi->queues = wq; in autofs_wait()
390 init_waitqueue_head(&wq->queue); in autofs_wait()
391 memcpy(&wq->name, &qstr, sizeof(struct qstr)); in autofs_wait()
392 wq->offset = offset; in autofs_wait()
393 wq->dev = autofs_get_dev(sbi); in autofs_wait()
394 wq->ino = autofs_get_ino(sbi); in autofs_wait()
395 wq->uid = current_uid(); in autofs_wait()
396 wq->gid = current_gid(); in autofs_wait()
397 wq->pid = pid; in autofs_wait()
398 wq->tgid = tgid; in autofs_wait()
399 wq->status = -EINTR; /* Status return if interrupted */ in autofs_wait()
400 wq->wait_ctr = 2; in autofs_wait()
402 if (sbi->version < 5) { in autofs_wait()
409 type = autofs_type_trigger(sbi->type) ? in autofs_wait()
413 type = autofs_type_trigger(sbi->type) ? in autofs_wait()
419 (unsigned long) wq->wait_queue_token, wq->name.len, in autofs_wait()
420 wq->name.name, notify); in autofs_wait()
423 * autofs_notify_daemon() may block; it will unlock ->wq_mutex in autofs_wait()
427 wq->wait_ctr++; in autofs_wait()
429 (unsigned long) wq->wait_queue_token, wq->name.len, in autofs_wait()
430 wq->name.name, notify); in autofs_wait()
431 mutex_unlock(&sbi->wq_mutex); in autofs_wait()
436 * wq->name.name is NULL iff the lock is already released in autofs_wait()
439 wait_event_killable(wq->queue, wq->name.name == NULL); in autofs_wait()
440 status = wq->status; in autofs_wait()
447 * to existing, active, autofs mounts. The uid and gid (and in autofs_wait()
459 de = d_lookup(dentry->d_parent, &dentry->d_name); in autofs_wait()
466 spin_lock(&sbi->fs_lock); in autofs_wait()
467 ino->uid = wq->uid; in autofs_wait()
468 ino->gid = wq->gid; in autofs_wait()
469 spin_unlock(&sbi->fs_lock); in autofs_wait()
477 mutex_lock(&sbi->wq_mutex); in autofs_wait()
478 if (!--wq->wait_ctr) in autofs_wait()
480 mutex_unlock(&sbi->wq_mutex); in autofs_wait()
491 mutex_lock(&sbi->wq_mutex); in autofs_wait_release()
492 for (wql = &sbi->queues; (wq = *wql) != NULL; wql = &wq->next) { in autofs_wait_release()
493 if (wq->wait_queue_token == wait_queue_token) in autofs_wait_release()
498 mutex_unlock(&sbi->wq_mutex); in autofs_wait_release()
499 return -EINVAL; in autofs_wait_release()
502 *wql = wq->next; /* Unlink from chain */ in autofs_wait_release()
503 kfree(wq->name.name - wq->offset); in autofs_wait_release()
504 wq->name.name = NULL; /* Do not wait on this queue */ in autofs_wait_release()
505 wq->status = status; in autofs_wait_release()
506 wake_up(&wq->queue); in autofs_wait_release()
507 if (!--wq->wait_ctr) in autofs_wait_release()
509 mutex_unlock(&sbi->wq_mutex); in autofs_wait_release()