void nfs_umount_begin(struct super_block *sb) { struct nfs_server *server = &sb->u.nfs_sb.s_server; struct rpc_clnt *rpc; /* -EIO all pending I/O */ if ((rpc = server->client) != NULL) rpc_killall_tasks(rpc); }
/* * Properly shut down an RPC client, terminating all outstanding * requests. Note that we must be certain that cl_oneshot and * cl_dead are cleared, or else the client would be destroyed * when the last task releases it. */ int rpc_shutdown_client(struct rpc_clnt *clnt) { dprintk("RPC: shutting down %s client for %s\n", clnt->cl_protname, clnt->cl_server); while (clnt->cl_users) { #ifdef RPC_DEBUG printk("rpc_shutdown_client: client %s, tasks=%d\n", clnt->cl_protname, clnt->cl_users); #endif /* Don't let rpc_release_client destroy us */ clnt->cl_oneshot = 0; clnt->cl_dead = 0; rpc_killall_tasks(clnt); sleep_on(&destroy_wait); } return rpc_destroy_client(clnt); }
static void rpciod_killall(void) { unsigned long flags; while (all_tasks) { current->sigpending = 0; rpc_killall_tasks(NULL); __rpc_schedule(); if (all_tasks) { dprintk("rpciod_killall: waiting for tasks to exit\n"); current->state = TASK_INTERRUPTIBLE; schedule_timeout(1); } } spin_lock_irqsave(¤t->sigmask_lock, flags); recalc_sigpending(current); spin_unlock_irqrestore(¤t->sigmask_lock, flags); }
static int vsnfs_create_rpcclient(struct vsnfs_server *server) { struct rpc_clnt *clnt = NULL; struct vsnfs_fh *resp = NULL; struct vsnfs_getrootargs argp = { .path = server->mnt_path, .len = strlen(server->mnt_path), }; int ret = VSNFS_OK; struct rpc_create_args args = { .protocol = IPPROTO_TCP, .address = (struct sockaddr *)&server->cl_addr, .addrsize = server->cl_addrlen, .servername = server->ip_addr, .program = &vsnfs_program, .version = server->cl_rpc_ops->version, .authflavor = RPC_AUTH_NULL, .flags = RPC_CLNT_CREATE_NOPING, /* check the flags options */ }; printk(KERN_ERR "inside vsnfs_Create_rpcClient\n"); printk(KERN_ERR "calling rpc_create\n"); clnt = rpc_create(&args); if (IS_ERR(clnt)) { printk(KERN_ERR "%s: cannot create RPC client = %ld\n", __func__, PTR_ERR(clnt)); ret = PTR_ERR(clnt); goto out_rpcclient; } printk(KERN_ERR "RPC client created\n"); server->cl_rpcclient = clnt; /* TO DO: getting root handle should be moved outside of this function */ resp = kmalloc(sizeof(struct vsnfs_fh), GFP_KERNEL); if (!resp) { ret = -ENOMEM; goto out_rpcclient; } ret = server->cl_rpc_ops->getroot(server, &argp, resp); if (ret == 0) { vsnfs_trace(KERN_DEFAULT, "success :-) inode : %s type: %d\n", resp->data, resp->type); } else { vsnfs_trace(KERN_DEFAULT, "failure :-( %d\n", ret); ret = -VSNFSERR_REMOTE; goto out_rpcclient; } memcpy(&server->root_fh, resp, sizeof(struct vsnfs_fh)); vsnfs_trace(KERN_DEFAULT, "success :-) inode : %s\n", server->root_fh.data); out_rpcclient: kfree(resp); return ret; } /* 2. Filesystem registration and superblock operations */ static int vsnfs_get_sb(struct file_system_type *, int, const char *, void *, struct vfsmount *); static void vsnfs_kill_sb(struct super_block *); /** * vsnfs_umount_begin: - Used to unmount the filesystem */ static void vsnfs_umount_begin(struct super_block *sb) { struct vsnfs_server *server = VSNFS_SB(sb); struct rpc_clnt *rpc; if ((rpc = server->cl_rpcclient) != NULL) rpc_killall_tasks(rpc); } int vsnfs_write_inode(struct inode *inode, int sync) { printk("Inside wrrite inode\n"); return -EOPNOTSUPP; } void vsnfs_clear_inode(struct inode *inode) { printk("Inside clear inode\n"); }