Skip to content

Commit

Permalink
Merge branch 'task_killable' of git://git.kernel.org/pub/scm/linux/ke…
Browse files Browse the repository at this point in the history
…rnel/git/willy/misc

* 'task_killable' of git://git.kernel.org/pub/scm/linux/kernel/git/willy/misc: (22 commits)
  Remove commented-out code copied from NFS
  NFS: Switch from intr mount option to TASK_KILLABLE
  Add wait_for_completion_killable
  Add wait_event_killable
  Add schedule_timeout_killable
  Use mutex_lock_killable in vfs_readdir
  Add mutex_lock_killable
  Use lock_page_killable
  Add lock_page_killable
  Add fatal_signal_pending
  Add TASK_WAKEKILL
  exit: Use task_is_*
  signal: Use task_is_*
  sched: Use task_contributes_to_load, TASK_ALL and TASK_NORMAL
  ptrace: Use task_is_*
  power: Use task_is_*
  wait: Use TASK_NORMAL
  proc/base.c: Use task_is_*
  proc/array.c: Use TASK_REPORT
  perfmon: Use task_is_*
  ...

Fixed up conflicts in NFS/sunrpc manually..
  • Loading branch information
torvalds committed Feb 1, 2008
2 parents fbdde7b + 2dfe485 commit 75659ca
Show file tree
Hide file tree
Showing 38 changed files with 282 additions and 252 deletions.
4 changes: 2 additions & 2 deletions arch/ia64/kernel/perfmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -2631,7 +2631,7 @@ pfm_task_incompatible(pfm_context_t *ctx, struct task_struct *task)
*/
if (task == current) return 0;

if ((task->state != TASK_STOPPED) && (task->state != TASK_TRACED)) {
if (!task_is_stopped_or_traced(task)) {
DPRINT(("cannot attach to non-stopped task [%d] state=%ld\n", task_pid_nr(task), task->state));
return -EBUSY;
}
Expand Down Expand Up @@ -4792,7 +4792,7 @@ pfm_check_task_state(pfm_context_t *ctx, int cmd, unsigned long flags)
* the task must be stopped.
*/
if (PFM_CMD_STOPPED(cmd)) {
if ((task->state != TASK_STOPPED) && (task->state != TASK_TRACED)) {
if (!task_is_stopped_or_traced(task)) {
DPRINT(("[%d] task not in stopped state\n", task_pid_nr(task)));
return -EBUSY;
}
Expand Down
11 changes: 4 additions & 7 deletions fs/eventpoll.c
Original file line number Diff line number Diff line change
Expand Up @@ -656,8 +656,7 @@ static int ep_poll_callback(wait_queue_t *wait, unsigned mode, int sync, void *k
* wait list.
*/
if (waitqueue_active(&ep->wq))
__wake_up_locked(&ep->wq, TASK_UNINTERRUPTIBLE |
TASK_INTERRUPTIBLE);
wake_up_locked(&ep->wq);
if (waitqueue_active(&ep->poll_wait))
pwake++;

Expand Down Expand Up @@ -780,7 +779,7 @@ static int ep_insert(struct eventpoll *ep, struct epoll_event *event,

/* Notify waiting tasks that events are available */
if (waitqueue_active(&ep->wq))
__wake_up_locked(&ep->wq, TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE);
wake_up_locked(&ep->wq);
if (waitqueue_active(&ep->poll_wait))
pwake++;
}
Expand Down Expand Up @@ -854,8 +853,7 @@ static int ep_modify(struct eventpoll *ep, struct epitem *epi, struct epoll_even

/* Notify waiting tasks that events are available */
if (waitqueue_active(&ep->wq))
__wake_up_locked(&ep->wq, TASK_UNINTERRUPTIBLE |
TASK_INTERRUPTIBLE);
wake_up_locked(&ep->wq);
if (waitqueue_active(&ep->poll_wait))
pwake++;
}
Expand Down Expand Up @@ -978,8 +976,7 @@ static int ep_send_events(struct eventpoll *ep, struct epoll_event __user *event
* wait list (delayed after we release the lock).
*/
if (waitqueue_active(&ep->wq))
__wake_up_locked(&ep->wq, TASK_UNINTERRUPTIBLE |
TASK_INTERRUPTIBLE);
wake_up_locked(&ep->wq);
if (waitqueue_active(&ep->poll_wait))
pwake++;
}
Expand Down
6 changes: 1 addition & 5 deletions fs/nfs/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ static struct nfs_client *nfs_get_client(const struct nfs_client_initdata *cl_in
if (new)
nfs_free_client(new);

error = wait_event_interruptible(nfs_client_active_wq,
error = wait_event_killable(nfs_client_active_wq,
clp->cl_cons_state != NFS_CS_INITING);
if (error < 0) {
nfs_put_client(clp);
Expand Down Expand Up @@ -589,10 +589,6 @@ static int nfs_init_server_rpcclient(struct nfs_server *server,
if (server->flags & NFS_MOUNT_SOFT)
server->client->cl_softrtry = 1;

server->client->cl_intr = 0;
if (server->flags & NFS4_MOUNT_INTR)
server->client->cl_intr = 1;

return 0;
}

Expand Down
7 changes: 1 addition & 6 deletions fs/nfs/direct.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,17 +188,12 @@ static void nfs_direct_req_release(struct nfs_direct_req *dreq)
static ssize_t nfs_direct_wait(struct nfs_direct_req *dreq)
{
ssize_t result = -EIOCBQUEUED;
struct rpc_clnt *clnt;
sigset_t oldset;

/* Async requests don't wait here */
if (dreq->iocb)
goto out;

clnt = NFS_CLIENT(dreq->inode);
rpc_clnt_sigmask(clnt, &oldset);
result = wait_for_completion_interruptible(&dreq->completion);
rpc_clnt_sigunmask(clnt, &oldset);
result = wait_for_completion_killable(&dreq->completion);

if (!result)
result = dreq->error;
Expand Down
6 changes: 1 addition & 5 deletions fs/nfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -433,15 +433,11 @@ static int nfs_wait_schedule(void *word)
*/
static int nfs_wait_on_inode(struct inode *inode)
{
struct rpc_clnt *clnt = NFS_CLIENT(inode);
struct nfs_inode *nfsi = NFS_I(inode);
sigset_t oldmask;
int error;

rpc_clnt_sigmask(clnt, &oldmask);
error = wait_on_bit_lock(&nfsi->flags, NFS_INO_REVALIDATING,
nfs_wait_schedule, TASK_INTERRUPTIBLE);
rpc_clnt_sigunmask(clnt, &oldmask);
nfs_wait_schedule, TASK_KILLABLE);

return error;
}
Expand Down
2 changes: 1 addition & 1 deletion fs/nfs/mount_clnt.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ int nfs_mount(struct sockaddr *addr, size_t len, char *hostname, char *path,
.program = &mnt_program,
.version = version,
.authflavor = RPC_AUTH_UNIX,
.flags = RPC_CLNT_CREATE_INTR,
.flags = 0,
};
struct rpc_clnt *mnt_clnt;
int status;
Expand Down
7 changes: 2 additions & 5 deletions fs/nfs/nfs3proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,14 @@
static int
nfs3_rpc_wrapper(struct rpc_clnt *clnt, struct rpc_message *msg, int flags)
{
sigset_t oldset;
int res;
rpc_clnt_sigmask(clnt, &oldset);
do {
res = rpc_call_sync(clnt, msg, flags);
if (res != -EJUKEBOX)
break;
schedule_timeout_interruptible(NFS_JUKEBOX_RETRY_TIME);
schedule_timeout_killable(NFS_JUKEBOX_RETRY_TIME);
res = -ERESTARTSYS;
} while (!signalled());
rpc_clnt_sigunmask(clnt, &oldset);
} while (!fatal_signal_pending(current));
return res;
}

Expand Down
27 changes: 7 additions & 20 deletions fs/nfs/nfs4proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,12 +316,9 @@ static void nfs4_opendata_put(struct nfs4_opendata *p)

static int nfs4_wait_for_completion_rpc_task(struct rpc_task *task)
{
sigset_t oldset;
int ret;

rpc_clnt_sigmask(task->tk_client, &oldset);
ret = rpc_wait_for_completion_task(task);
rpc_clnt_sigunmask(task->tk_client, &oldset);
return ret;
}

Expand Down Expand Up @@ -2785,36 +2782,31 @@ nfs4_async_handle_error(struct rpc_task *task, const struct nfs_server *server)
return 0;
}

static int nfs4_wait_bit_interruptible(void *word)
static int nfs4_wait_bit_killable(void *word)
{
if (signal_pending(current))
if (fatal_signal_pending(current))
return -ERESTARTSYS;
schedule();
return 0;
}

static int nfs4_wait_clnt_recover(struct rpc_clnt *clnt, struct nfs_client *clp)
{
sigset_t oldset;
int res;

might_sleep();

rwsem_acquire(&clp->cl_sem.dep_map, 0, 0, _RET_IP_);

rpc_clnt_sigmask(clnt, &oldset);
res = wait_on_bit(&clp->cl_state, NFS4CLNT_STATE_RECOVER,
nfs4_wait_bit_interruptible,
TASK_INTERRUPTIBLE);
rpc_clnt_sigunmask(clnt, &oldset);
nfs4_wait_bit_killable, TASK_KILLABLE);

rwsem_release(&clp->cl_sem.dep_map, 1, _RET_IP_);
return res;
}

static int nfs4_delay(struct rpc_clnt *clnt, long *timeout)
{
sigset_t oldset;
int res = 0;

might_sleep();
Expand All @@ -2823,14 +2815,9 @@ static int nfs4_delay(struct rpc_clnt *clnt, long *timeout)
*timeout = NFS4_POLL_RETRY_MIN;
if (*timeout > NFS4_POLL_RETRY_MAX)
*timeout = NFS4_POLL_RETRY_MAX;
rpc_clnt_sigmask(clnt, &oldset);
if (clnt->cl_intr) {
schedule_timeout_interruptible(*timeout);
if (signalled())
res = -ERESTARTSYS;
} else
schedule_timeout_uninterruptible(*timeout);
rpc_clnt_sigunmask(clnt, &oldset);
schedule_timeout_killable(*timeout);
if (fatal_signal_pending(current))
res = -ERESTARTSYS;
*timeout <<= 1;
return res;
}
Expand Down Expand Up @@ -3069,7 +3056,7 @@ int nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, const nfs4
static unsigned long
nfs4_set_lock_task_retry(unsigned long timeout)
{
schedule_timeout_interruptible(timeout);
schedule_timeout_killable(timeout);
timeout <<= 1;
if (timeout > NFS4_LOCK_MAXTIMEOUT)
return NFS4_LOCK_MAXTIMEOUT;
Expand Down
3 changes: 0 additions & 3 deletions fs/nfs/nfsroot.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,7 @@ static int __init root_nfs_parse(char *name, char *buf)
nfs_data.flags &= ~NFS_MOUNT_SOFT;
break;
case Opt_intr:
nfs_data.flags |= NFS_MOUNT_INTR;
break;
case Opt_nointr:
nfs_data.flags &= ~NFS_MOUNT_INTR;
break;
case Opt_posix:
nfs_data.flags |= NFS_MOUNT_POSIX;
Expand Down
19 changes: 5 additions & 14 deletions fs/nfs/pagelist.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ nfs_create_request(struct nfs_open_context *ctx, struct inode *inode,
struct page *page,
unsigned int offset, unsigned int count)
{
struct nfs_server *server = NFS_SERVER(inode);
struct nfs_page *req;

for (;;) {
Expand All @@ -67,7 +66,7 @@ nfs_create_request(struct nfs_open_context *ctx, struct inode *inode,
if (req != NULL)
break;

if (signalled() && (server->flags & NFS_MOUNT_INTR))
if (fatal_signal_pending(current))
return ERR_PTR(-ERESTARTSYS);
yield();
}
Expand Down Expand Up @@ -177,11 +176,11 @@ void nfs_release_request(struct nfs_page *req)
kref_put(&req->wb_kref, nfs_free_request);
}

static int nfs_wait_bit_interruptible(void *word)
static int nfs_wait_bit_killable(void *word)
{
int ret = 0;

if (signal_pending(current))
if (fatal_signal_pending(current))
ret = -ERESTARTSYS;
else
schedule();
Expand All @@ -192,26 +191,18 @@ static int nfs_wait_bit_interruptible(void *word)
* nfs_wait_on_request - Wait for a request to complete.
* @req: request to wait upon.
*
* Interruptible by signals only if mounted with intr flag.
* Interruptible by fatal signals only.
* The user is responsible for holding a count on the request.
*/
int
nfs_wait_on_request(struct nfs_page *req)
{
struct rpc_clnt *clnt = NFS_CLIENT(req->wb_context->path.dentry->d_inode);
sigset_t oldmask;
int ret = 0;

if (!test_bit(PG_BUSY, &req->wb_flags))
goto out;
/*
* Note: the call to rpc_clnt_sigmask() suffices to ensure that we
* are not interrupted if intr flag is not set
*/
rpc_clnt_sigmask(clnt, &oldmask);
ret = out_of_line_wait_on_bit(&req->wb_flags, PG_BUSY,
nfs_wait_bit_interruptible, TASK_INTERRUPTIBLE);
rpc_clnt_sigunmask(clnt, &oldmask);
nfs_wait_bit_killable, TASK_KILLABLE);
out:
return ret;
}
Expand Down
4 changes: 0 additions & 4 deletions fs/nfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,6 @@ static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss,
const char *nostr;
} nfs_info[] = {
{ NFS_MOUNT_SOFT, ",soft", ",hard" },
{ NFS_MOUNT_INTR, ",intr", ",nointr" },
{ NFS_MOUNT_NOCTO, ",nocto", "" },
{ NFS_MOUNT_NOAC, ",noac", "" },
{ NFS_MOUNT_NONLM, ",nolock", "" },
Expand Down Expand Up @@ -708,10 +707,7 @@ static int nfs_parse_mount_options(char *raw,
mnt->flags &= ~NFS_MOUNT_SOFT;
break;
case Opt_intr:
mnt->flags |= NFS_MOUNT_INTR;
break;
case Opt_nointr:
mnt->flags &= ~NFS_MOUNT_INTR;
break;
case Opt_posix:
mnt->flags |= NFS_MOUNT_POSIX;
Expand Down
2 changes: 1 addition & 1 deletion fs/nfs/write.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ int nfs_reschedule_unstable_write(struct nfs_page *req)
/*
* Wait for a request to complete.
*
* Interruptible by signals only if mounted with intr flag.
* Interruptible by fatal signals only.
*/
static int nfs_wait_on_requests_locked(struct inode *inode, pgoff_t idx_start, unsigned int npages)
{
Expand Down
7 changes: 1 addition & 6 deletions fs/proc/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,7 @@ static const char *task_state_array[] = {

static inline const char *get_task_state(struct task_struct *tsk)
{
unsigned int state = (tsk->state & (TASK_RUNNING |
TASK_INTERRUPTIBLE |
TASK_UNINTERRUPTIBLE |
TASK_STOPPED |
TASK_TRACED)) |
tsk->exit_state;
unsigned int state = (tsk->state & TASK_REPORT) | tsk->exit_state;
const char **p = &task_state_array[0];

while (state) {
Expand Down
2 changes: 1 addition & 1 deletion fs/proc/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ static int proc_root_link(struct inode *inode, struct dentry **dentry, struct vf
(task == current || \
(task->parent == current && \
(task->ptrace & PT_PTRACED) && \
(task->state == TASK_STOPPED || task->state == TASK_TRACED) && \
(task_is_stopped_or_traced(task)) && \
security_ptrace(current,task) == 0))

struct mm_struct *mm_for_maps(struct task_struct *task)
Expand Down
5 changes: 4 additions & 1 deletion fs/readdir.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ int vfs_readdir(struct file *file, filldir_t filler, void *buf)
if (res)
goto out;

mutex_lock(&inode->i_mutex);
res = mutex_lock_killable(&inode->i_mutex);
if (res)
goto out;

res = -ENOENT;
if (!IS_DEADDIR(inode)) {
res = file->f_op->readdir(file, buf, filler);
Expand Down
2 changes: 1 addition & 1 deletion fs/smbfs/request.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ struct smb_request *smb_alloc_request(struct smb_sb_info *server, int bufsize)
if (nfs_try_to_free_pages(server))
continue;

if (signalled() && (server->flags & NFS_MOUNT_INTR))
if (fatal_signal_pending(current))
return ERR_PTR(-ERESTARTSYS);
current->policy = SCHED_YIELD;
schedule();
Expand Down
1 change: 1 addition & 0 deletions include/linux/completion.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ static inline void init_completion(struct completion *x)

extern void wait_for_completion(struct completion *);
extern int wait_for_completion_interruptible(struct completion *x);
extern int wait_for_completion_killable(struct completion *x);
extern unsigned long wait_for_completion_timeout(struct completion *x,
unsigned long timeout);
extern unsigned long wait_for_completion_interruptible_timeout(
Expand Down
5 changes: 5 additions & 0 deletions include/linux/mutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,20 @@ static inline int fastcall mutex_is_locked(struct mutex *lock)
extern void mutex_lock_nested(struct mutex *lock, unsigned int subclass);
extern int __must_check mutex_lock_interruptible_nested(struct mutex *lock,
unsigned int subclass);
extern int __must_check mutex_lock_killable_nested(struct mutex *lock,
unsigned int subclass);

#define mutex_lock(lock) mutex_lock_nested(lock, 0)
#define mutex_lock_interruptible(lock) mutex_lock_interruptible_nested(lock, 0)
#define mutex_lock_killable(lock) mutex_lock_killable_nested(lock, 0)
#else
extern void fastcall mutex_lock(struct mutex *lock);
extern int __must_check fastcall mutex_lock_interruptible(struct mutex *lock);
extern int __must_check fastcall mutex_lock_killable(struct mutex *lock);

# define mutex_lock_nested(lock, subclass) mutex_lock(lock)
# define mutex_lock_interruptible_nested(lock, subclass) mutex_lock_interruptible(lock)
# define mutex_lock_killable_nested(lock, subclass) mutex_lock_killable(lock)
#endif

/*
Expand Down
Loading

0 comments on commit 75659ca

Please sign in to comment.