knfsd: allow cache_register to return error on failure
Newer server features such as nfsv4 and gss depend on proc to work, so a failure to initialize the proc files they need should be treated as fatal. Thanks to Andrew Morton for style fix and compile fix in case where CONFIG_NFSD_V4 is undefined. Cc: Andrew Morton <akpm@linux-foundation.org> Acked-by: NeilBrown <neilb@suse.de> Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
This commit is contained in:
parent
ffe9386b6e
commit
dbf847ecb6
8 changed files with 75 additions and 26 deletions
|
@ -1637,13 +1637,19 @@ exp_verify_string(char *cp, int max)
|
||||||
/*
|
/*
|
||||||
* Initialize the exports module.
|
* Initialize the exports module.
|
||||||
*/
|
*/
|
||||||
void
|
int
|
||||||
nfsd_export_init(void)
|
nfsd_export_init(void)
|
||||||
{
|
{
|
||||||
|
int rv;
|
||||||
dprintk("nfsd: initializing export module.\n");
|
dprintk("nfsd: initializing export module.\n");
|
||||||
|
|
||||||
cache_register(&svc_export_cache);
|
rv = cache_register(&svc_export_cache);
|
||||||
cache_register(&svc_expkey_cache);
|
if (rv)
|
||||||
|
return rv;
|
||||||
|
rv = cache_register(&svc_expkey_cache);
|
||||||
|
if (rv)
|
||||||
|
cache_unregister(&svc_export_cache);
|
||||||
|
return rv;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -464,11 +464,18 @@ nametoid_update(struct ent *new, struct ent *old)
|
||||||
* Exported API
|
* Exported API
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
int
|
||||||
nfsd_idmap_init(void)
|
nfsd_idmap_init(void)
|
||||||
{
|
{
|
||||||
cache_register(&idtoname_cache);
|
int rv;
|
||||||
cache_register(&nametoid_cache);
|
|
||||||
|
rv = cache_register(&idtoname_cache);
|
||||||
|
if (rv)
|
||||||
|
return rv;
|
||||||
|
rv = cache_register(&nametoid_cache);
|
||||||
|
if (rv)
|
||||||
|
cache_unregister(&idtoname_cache);
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -707,9 +707,13 @@ static int __init init_nfsd(void)
|
||||||
retval = nfsd_reply_cache_init();
|
retval = nfsd_reply_cache_init();
|
||||||
if (retval)
|
if (retval)
|
||||||
goto out_free_stat;
|
goto out_free_stat;
|
||||||
nfsd_export_init(); /* Exports table */
|
retval = nfsd_export_init();
|
||||||
|
if (retval)
|
||||||
|
goto out_free_cache;
|
||||||
nfsd_lockd_init(); /* lockd->nfsd callbacks */
|
nfsd_lockd_init(); /* lockd->nfsd callbacks */
|
||||||
nfsd_idmap_init(); /* Name to ID mapping */
|
retval = nfsd_idmap_init();
|
||||||
|
if (retval)
|
||||||
|
goto out_free_lockd;
|
||||||
retval = create_proc_exports_entry();
|
retval = create_proc_exports_entry();
|
||||||
if (retval)
|
if (retval)
|
||||||
goto out_free_idmap;
|
goto out_free_idmap;
|
||||||
|
@ -720,10 +724,12 @@ static int __init init_nfsd(void)
|
||||||
out_free_all:
|
out_free_all:
|
||||||
remove_proc_entry("fs/nfs/exports", NULL);
|
remove_proc_entry("fs/nfs/exports", NULL);
|
||||||
remove_proc_entry("fs/nfs", NULL);
|
remove_proc_entry("fs/nfs", NULL);
|
||||||
nfsd_idmap_shutdown();
|
|
||||||
out_free_idmap:
|
out_free_idmap:
|
||||||
|
nfsd_idmap_shutdown();
|
||||||
|
out_free_lockd:
|
||||||
nfsd_lockd_shutdown();
|
nfsd_lockd_shutdown();
|
||||||
nfsd_export_shutdown();
|
nfsd_export_shutdown();
|
||||||
|
out_free_cache:
|
||||||
nfsd_reply_cache_shutdown();
|
nfsd_reply_cache_shutdown();
|
||||||
out_free_stat:
|
out_free_stat:
|
||||||
nfsd_stat_shutdown();
|
nfsd_stat_shutdown();
|
||||||
|
|
|
@ -122,7 +122,7 @@ __be32 check_nfsd_access(struct svc_export *exp, struct svc_rqst *rqstp);
|
||||||
/*
|
/*
|
||||||
* Function declarations
|
* Function declarations
|
||||||
*/
|
*/
|
||||||
void nfsd_export_init(void);
|
int nfsd_export_init(void);
|
||||||
void nfsd_export_shutdown(void);
|
void nfsd_export_shutdown(void);
|
||||||
void nfsd_export_flush(void);
|
void nfsd_export_flush(void);
|
||||||
void exp_readlock(void);
|
void exp_readlock(void);
|
||||||
|
|
|
@ -44,11 +44,16 @@
|
||||||
#define IDMAP_NAMESZ 128
|
#define IDMAP_NAMESZ 128
|
||||||
|
|
||||||
#ifdef CONFIG_NFSD_V4
|
#ifdef CONFIG_NFSD_V4
|
||||||
void nfsd_idmap_init(void);
|
int nfsd_idmap_init(void);
|
||||||
void nfsd_idmap_shutdown(void);
|
void nfsd_idmap_shutdown(void);
|
||||||
#else
|
#else
|
||||||
static inline void nfsd_idmap_init(void) {};
|
static inline int nfsd_idmap_init(void)
|
||||||
static inline void nfsd_idmap_shutdown(void) {};
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
static inline void nfsd_idmap_shutdown(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int nfsd_map_name_to_uid(struct svc_rqst *, const char *, size_t, __u32 *);
|
int nfsd_map_name_to_uid(struct svc_rqst *, const char *, size_t, __u32 *);
|
||||||
|
|
|
@ -169,7 +169,7 @@ extern int cache_check(struct cache_detail *detail,
|
||||||
extern void cache_flush(void);
|
extern void cache_flush(void);
|
||||||
extern void cache_purge(struct cache_detail *detail);
|
extern void cache_purge(struct cache_detail *detail);
|
||||||
#define NEVER (0x7FFFFFFF)
|
#define NEVER (0x7FFFFFFF)
|
||||||
extern void cache_register(struct cache_detail *cd);
|
extern int cache_register(struct cache_detail *cd);
|
||||||
extern void cache_unregister(struct cache_detail *cd);
|
extern void cache_unregister(struct cache_detail *cd);
|
||||||
|
|
||||||
extern void qword_add(char **bpp, int *lp, char *str);
|
extern void qword_add(char **bpp, int *lp, char *str);
|
||||||
|
|
|
@ -1386,10 +1386,19 @@ int
|
||||||
gss_svc_init(void)
|
gss_svc_init(void)
|
||||||
{
|
{
|
||||||
int rv = svc_auth_register(RPC_AUTH_GSS, &svcauthops_gss);
|
int rv = svc_auth_register(RPC_AUTH_GSS, &svcauthops_gss);
|
||||||
if (rv == 0) {
|
if (rv)
|
||||||
cache_register(&rsc_cache);
|
return rv;
|
||||||
cache_register(&rsi_cache);
|
rv = cache_register(&rsc_cache);
|
||||||
}
|
if (rv)
|
||||||
|
goto out1;
|
||||||
|
rv = cache_register(&rsi_cache);
|
||||||
|
if (rv)
|
||||||
|
goto out2;
|
||||||
|
return 0;
|
||||||
|
out2:
|
||||||
|
cache_unregister(&rsc_cache);
|
||||||
|
out1:
|
||||||
|
svc_auth_unregister(RPC_AUTH_GSS);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -304,20 +304,21 @@ static void remove_cache_proc_entries(struct cache_detail *cd)
|
||||||
remove_proc_entry(cd->name, proc_net_rpc);
|
remove_proc_entry(cd->name, proc_net_rpc);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void create_cache_proc_entries(struct cache_detail *cd)
|
#ifdef CONFIG_PROC_FS
|
||||||
|
static int create_cache_proc_entries(struct cache_detail *cd)
|
||||||
{
|
{
|
||||||
struct proc_dir_entry *p;
|
struct proc_dir_entry *p;
|
||||||
|
|
||||||
cd->proc_ent = proc_mkdir(cd->name, proc_net_rpc);
|
cd->proc_ent = proc_mkdir(cd->name, proc_net_rpc);
|
||||||
if (cd->proc_ent == NULL)
|
if (cd->proc_ent == NULL)
|
||||||
return;
|
goto out_nomem;
|
||||||
cd->proc_ent->owner = cd->owner;
|
cd->proc_ent->owner = cd->owner;
|
||||||
cd->channel_ent = cd->content_ent = NULL;
|
cd->channel_ent = cd->content_ent = NULL;
|
||||||
|
|
||||||
p = create_proc_entry("flush", S_IFREG|S_IRUSR|S_IWUSR, cd->proc_ent);
|
p = create_proc_entry("flush", S_IFREG|S_IRUSR|S_IWUSR, cd->proc_ent);
|
||||||
cd->flush_ent = p;
|
cd->flush_ent = p;
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
return;
|
goto out_nomem;
|
||||||
p->proc_fops = &cache_flush_operations;
|
p->proc_fops = &cache_flush_operations;
|
||||||
p->owner = cd->owner;
|
p->owner = cd->owner;
|
||||||
p->data = cd;
|
p->data = cd;
|
||||||
|
@ -327,7 +328,7 @@ static void create_cache_proc_entries(struct cache_detail *cd)
|
||||||
cd->proc_ent);
|
cd->proc_ent);
|
||||||
cd->channel_ent = p;
|
cd->channel_ent = p;
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
return;
|
goto out_nomem;
|
||||||
p->proc_fops = &cache_file_operations;
|
p->proc_fops = &cache_file_operations;
|
||||||
p->owner = cd->owner;
|
p->owner = cd->owner;
|
||||||
p->data = cd;
|
p->data = cd;
|
||||||
|
@ -337,16 +338,30 @@ static void create_cache_proc_entries(struct cache_detail *cd)
|
||||||
cd->proc_ent);
|
cd->proc_ent);
|
||||||
cd->content_ent = p;
|
cd->content_ent = p;
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
return;
|
goto out_nomem;
|
||||||
p->proc_fops = &content_file_operations;
|
p->proc_fops = &content_file_operations;
|
||||||
p->owner = cd->owner;
|
p->owner = cd->owner;
|
||||||
p->data = cd;
|
p->data = cd;
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
|
out_nomem:
|
||||||
|
remove_cache_proc_entries(cd);
|
||||||
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
#else /* CONFIG_PROC_FS */
|
||||||
void cache_register(struct cache_detail *cd)
|
static int create_cache_proc_entries(struct cache_detail *cd)
|
||||||
{
|
{
|
||||||
create_cache_proc_entries(cd);
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int cache_register(struct cache_detail *cd)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = create_cache_proc_entries(cd);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
rwlock_init(&cd->hash_lock);
|
rwlock_init(&cd->hash_lock);
|
||||||
INIT_LIST_HEAD(&cd->queue);
|
INIT_LIST_HEAD(&cd->queue);
|
||||||
spin_lock(&cache_list_lock);
|
spin_lock(&cache_list_lock);
|
||||||
|
@ -360,6 +375,7 @@ void cache_register(struct cache_detail *cd)
|
||||||
|
|
||||||
/* start the cleaning process */
|
/* start the cleaning process */
|
||||||
schedule_delayed_work(&cache_cleaner, 0);
|
schedule_delayed_work(&cache_cleaner, 0);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cache_unregister(struct cache_detail *cd)
|
void cache_unregister(struct cache_detail *cd)
|
||||||
|
|
Loading…
Add table
Reference in a new issue