afs: use kthread_ API
PATCH 1/1 afs: use kthread_ API
Use the kthread_ API instead of opencoding lots of hairy code for kernel thread creation and teardown.
Signed-off-by Christoph Hellwig <[email protected]>
fs/afs/file.c +0 -30
@@ -31,24 +31,10 @@static int afs_file_invalidatepage (struct page *page,unsigned long offset);static int afs_file_releasepage (struct page *page,gfp_t gfp_flags); -static ssize_t afs_file_write (struct file *file,const char __user *buf, -size_t size,loff_t *off); -struct inode_operations afs_file_inode_operations = { .getattr = afs_inode_getattr, }; -struct file_operations afs_file_file_operations = { - .read = generic_file_read, - .write = afs_file_write, - .mmap = generic_file_mmap, -#if 0 - .open = afs_file_open, - .release = afs_file_release, - .fsync = afs_file_fsync, -#endif -}; -struct address_space_operations afs_fs_aops = { .readpage = afs_file_readpage, .sync_page = block_sync_page,
@@ -59,22 +45,6 @@/*****************************************************************************/ /* -* AFS file write -*/ -static ssize_t afs_file_write (struct file *file,const char __user *buf, -size_t size,loff_t *off) -{ -struct afs_vnode *vnode; - - vnode =AFS_FS_I (file->f_dentry->d_inode); -if (vnode->flags &AFS_VNODE_DELETED ) -return -ESTALE ; - -return -EIO ; -}/* end afs_file_write() */ - -/*****************************************************************************/ -/* * deal with notification that a page was read from the cache */ #ifdef AFS_CACHING_SUPPORT
fs/afs/inode.c +1 -1
@@ -49,7 +49,7 @@case AFS_FTYPE_FILE : inode->i_mode =S_IFREG | vnode->status.mode; inode->i_op = &afs_file_inode_operations; - inode->i_fop = &afs_file_file_operations; + inode->i_fop = &generic_ro_fops;break ;case AFS_FTYPE_DIR : inode->i_mode =S_IFDIR | vnode->status.mode;
fs/afs/internal.h +0 -1
@@ -71,7 +71,6 @@*/ extern struct address_space_operations afs_fs_aops;extern struct inode_operations afs_file_inode_operations; -extern struct file_operations afs_file_file_operations;#ifdef AFS_CACHING_SUPPORT extern int afs_cache_get_page_cookie(struct page *page,
David Howells
maintainerQuoted 2 lines · Christoph Hellwig
Use the
kthread_API instead of opencoding lots of hairy code for kernel thread creation and teardown.
NAK. The kthread API appears nowhere in the patch.
David
Quoted 6 lines · David Howells
Quoted 2 lines · Christoph Hellwig
Use the
kthread_API instead of opencoding lots of hairy code for kernel thread creation and teardown.NAK. The kthread API appears nowhere in the patch.
Sorry, I accidentally attached a different afs patch. Here's the correct one:
fs/afs/cmservice.c +13 -31
@@ -13,6 +13,7 @@#include <linux/init.h> #include <linux/sched.h> #include <linux/completion.h> +#include <linux/kthread.h> #include "server.h" #include "cell.h" #include "transport.h"
@@ -97,14 +98,11 @@ .ops_end = &AFSCM_ops[sizeof(AFSCM_ops) / sizeof(AFSCM_ops[0])], }; -static DECLARE_COMPLETION (kafscmd_alive); -static DECLARE_COMPLETION (kafscmd_dead); -static DECLARE_WAIT_QUEUE_HEAD (kafscmd_sleepq); +static struct task_struct *kafscmd_thread;static LIST_HEAD (kafscmd_attention_list);static LIST_HEAD (afscm_calls);static DEFINE_SPINLOCK (afscm_calls_lock);static DEFINE_SPINLOCK (kafscmd_attention_lock); -static int kafscmd_die;/*****************************************************************************/ /*
@@ -112,39 +110,31 @@*/ static int kafscmd (void *arg) { -DECLARE_WAITQUEUE (myself, current); -struct rxrpc_call *call;_SRXAFSCM_xxxx_t func;int die;printk (KERN_INFO "kAFS: Started kafscmd %d\n" , current->pid); -daemonize ("kafscmd" ); - -complete (&kafscmd_alive); -/* loop around looking for things to attend to */ do { if (list_empty(&kafscmd_attention_list)) { set_current_state(TASK_INTERRUPTIBLE); - add_wait_queue(&kafscmd_sleepq, &myself); for (;;) { set_current_state(TASK_INTERRUPTIBLE); if (!list_empty(&kafscmd_attention_list) || signal_pending(current) || - kafscmd_die) + kthread_should_stop()) break; schedule(); } - remove_wait_queue(&kafscmd_sleepq, &myself); set_current_state(TASK_RUNNING); } - die = kafscmd_die; + die = kthread_should_stop(); /* dequeue the next call requiring attention */ call = NULL;
@@ -175,9 +165,7 @@ }while (!die); -/* and that's all */ -complete_and_exit (&kafscmd_dead,0 ); - +return 0 ; }/* end kafscmd() */ /*****************************************************************************/
@@ -223,7 +211,7 @@spin_unlock (&kafscmd_attention_lock); -wake_up (&kafscmd_sleepq); +wake_up_process (kafscmd_thread);_leave (" {u=%d}" ,atomic_read (&call->usage)); }/* end afscm_attention() */
@@ -263,7 +251,7 @@if (removed)rxrpc_put_call (call); -wake_up (&kafscmd_sleepq); +wake_up_process (kafscmd_thread);_leave ("" ); }/* end afscm_error() */
@@ -297,11 +285,11 @@down_write (&afscm_sem);if (!afscm_usage) { - ret =kernel_thread (kafscmd,NULL ,0 ); -if (ret <0 ) + kafscmd_thread =kthread_run (kafscmd,NULL ,"kafscmd" ); +if (IS_ERR (kafscmd_thread)) { + ret =PTR_ERR (kafscmd_thread); goto out; - -wait_for_completion (&kafscmd_alive); + } ret =rxrpc_add_service (afs_transport, &AFSCM_service);if (ret <0 )
@@ -317,10 +305,7 @@return 0 ; kill: - kafscmd_die =1 ; -wake_up (&kafscmd_sleepq); -wait_for_completion (&kafscmd_dead); - +kthread_stop (kafscmd_thread); out:up_write (&afscm_sem);return ret;
@@ -369,10 +354,7 @@ }spin_unlock (&afscm_calls_lock); -/* get rid of my daemon */ - kafscmd_die =1 ; -wake_up (&kafscmd_sleepq); -wait_for_completion (&kafscmd_dead); +kthread_stop (kafscmd_thread);/* dispose of any calls waiting for attention */ spin_lock (&kafscmd_attention_lock);
fs/afs/kafsasyncd.c +12 -35
123 lines not on this page · raw message
fs/afs/kafstimod.c +11 -30
102 lines not on this page · raw message