Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dbf847ec authored by J. Bruce Fields's avatar J. Bruce Fields
Browse files

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: default avatarNeilBrown <neilb@suse.de>
Signed-off-by: default avatarJ. Bruce Fields <bfields@citi.umich.edu>
parent ffe9386b
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -1637,13 +1637,19 @@ exp_verify_string(char *cp, int max)
/*
 * Initialize the exports module.
 */
void
int
nfsd_export_init(void)
{
	int rv;
	dprintk("nfsd: initializing export module.\n");

	cache_register(&svc_export_cache);
	cache_register(&svc_expkey_cache);
	rv = cache_register(&svc_export_cache);
	if (rv)
		return rv;
	rv = cache_register(&svc_expkey_cache);
	if (rv)
		cache_unregister(&svc_export_cache);
	return rv;

}

+10 −3
Original line number Diff line number Diff line
@@ -464,11 +464,18 @@ nametoid_update(struct ent *new, struct ent *old)
 * Exported API
 */

void
int
nfsd_idmap_init(void)
{
	cache_register(&idtoname_cache);
	cache_register(&nametoid_cache);
	int rv;

	rv = cache_register(&idtoname_cache);
	if (rv)
		return rv;
	rv = cache_register(&nametoid_cache);
	if (rv)
		cache_unregister(&idtoname_cache);
	return rv;
}

void
+9 −3
Original line number Diff line number Diff line
@@ -707,9 +707,13 @@ static int __init init_nfsd(void)
	retval = nfsd_reply_cache_init();
	if (retval)
		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_idmap_init();      /* Name to ID mapping */
	retval = nfsd_idmap_init();
	if (retval)
		goto out_free_lockd;
	retval = create_proc_exports_entry();
	if (retval)
		goto out_free_idmap;
@@ -720,10 +724,12 @@ static int __init init_nfsd(void)
out_free_all:
	remove_proc_entry("fs/nfs/exports", NULL);
	remove_proc_entry("fs/nfs", NULL);
	nfsd_idmap_shutdown();
out_free_idmap:
	nfsd_idmap_shutdown();
out_free_lockd:
	nfsd_lockd_shutdown();
	nfsd_export_shutdown();
out_free_cache:
	nfsd_reply_cache_shutdown();
out_free_stat:
	nfsd_stat_shutdown();
+1 −1
Original line number Diff line number Diff line
@@ -122,7 +122,7 @@ __be32 check_nfsd_access(struct svc_export *exp, struct svc_rqst *rqstp);
/*
 * Function declarations
 */
void			nfsd_export_init(void);
int			nfsd_export_init(void);
void			nfsd_export_shutdown(void);
void			nfsd_export_flush(void);
void			exp_readlock(void);
+8 −3
Original line number Diff line number Diff line
@@ -44,11 +44,16 @@
#define IDMAP_NAMESZ 128

#ifdef CONFIG_NFSD_V4
void nfsd_idmap_init(void);
int nfsd_idmap_init(void);
void nfsd_idmap_shutdown(void);
#else
static inline void nfsd_idmap_init(void) {};
static inline void nfsd_idmap_shutdown(void) {};
static inline int nfsd_idmap_init(void)
{
	return 0;
}
static inline void nfsd_idmap_shutdown(void)
{
}
#endif

int nfsd_map_name_to_uid(struct svc_rqst *, const char *, size_t, __u32 *);
Loading