All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pekka Enberg <penberg@gmail.com>
To: "ericvh@gmail.com" <ericvh@gmail.com>
Cc: linux-kernel@vger.kernel.org,
	v9fs-developer@lists.sourceforge.net,
	viro@parcelfarce.linux.theplanet.co.uk,
	linux-fsdevel@vger.kernel.org, penberg@cs.helsinki.fi
Subject: Re: [RFC][patch 4/7] v9fs: VFS superblock operations (2.0-rc6)
Date: Wed, 25 May 2005 08:17:23 +0300	[thread overview]
Message-ID: <84144f02050524221757820a18@mail.gmail.com> (raw)
In-Reply-To: <200505232225.j4NMPte1029529@ms-smtp-02-eri0.texas.rr.com>

Hi,

Some more comments follow.

On 5/24/05, ericvh@gmail.com <ericvh@gmail.com> wrote:
> +static int __init init_v9fs(void)
> +{
> +	int error;
> +
> +	v9fs_error_init();
> +
> +	printk(KERN_INFO "Installing v9fs 9P2000 file system support\n");
> +
> +	if ((error = register_filesystem(&v9fs_fs_type))) {
> +		printk(KERN_ERR "Could not register v9fs\n");
> +		return error;
> +	}
> +
> +	v9fs_rpcreq_slab = kmem_cache_create("v9fs_rpcreq_info",
> +					     sizeof(struct v9fs_rpcreq), 0,
> +					     SLAB_HWCACHE_ALIGN, NULL, NULL);
> +
> +	if (!v9fs_rpcreq_slab) {
> +		eprintk(KERN_WARNING, "Couldn't allocate v9fs_rpcreq cache\n");
> +		return -1;

Module initialization fails and you don't do unregister_filesystem. Please
shuffle the code so that you do all other initialization _before_ calling
register_filesystem. And don't forget to release the slab on error.

> +	}
> +
> +	return 0;
> +}
> +
> +/**
> + * v9fs_init - shutdown module
> + *
> + */
> +
> +static void __exit exit_v9fs(void)
> +{
> +	struct list_head *p, *n;
> +	struct v9fs_slab *s;
> +
> +	list_for_each_safe(p, n, &v9fs_slab_list) {
> +		s = list_entry(p, struct v9fs_slab, list);
> +		kmem_cache_destroy(s->slab);
> +		list_del(&s->list);
> +	}
> +
> +	kmem_cache_destroy(v9fs_rpcreq_slab);
> +	unregister_filesystem(&v9fs_fs_type);

This looks racy. You should unregister the filesystem before releasing its
resources.

> +}
> +
> +module_init(init_v9fs)
> +module_exit(exit_v9fs)
> +
> +MODULE_AUTHOR("Eric Van Hensbergen <ericvh@gmail.com>");
> +MODULE_AUTHOR("Ron Minnich <rminnich@lanl.gov>");
> +MODULE_LICENSE("GPL");

> Index: fs/9p/vfs_super.c
> ===================================================================
> --- /dev/null  (tree:0bf32353105286a5624aeea862d35a4bbae09851)
> +++ 178666ee376655ef8ec19a2ffc0490241b428110/fs/9p/vfs_super.c  (mode:100644)
> +static struct super_block *v9fs_get_sb(struct file_system_type
> +				       *fs_type, int flags,
> +				       const char *dev_name, void *data)
> +{
> +	struct super_block *sb = NULL;
> +	struct v9fs_fcall *fcall = NULL;
> +	struct inode *inode = NULL;
> +	struct dentry *root = NULL;
> +	struct v9fs_session_info *v9ses = NULL;
> +	struct v9fs_fid *root_fid = NULL;
> +	int mode = S_IRWXUGO | S_ISVTX;
> +	uid_t uid = current->fsuid;
> +	gid_t gid = current->fsgid;
> +	int stat_result = 0;
> +	int newfid = 0;
> +
> +	dprintk(DEBUG_VFS, " \n");
> +
> +	v9ses = kmalloc(sizeof(struct v9fs_session_info), GFP_KERNEL);
> +	if (!v9ses)
> +		return ERR_PTR(-ENOMEM);
> +	memset(v9ses, 0, sizeof(struct v9fs_session_info));

Please consider using kcalloc().

> +
> +	if ((newfid = v9fs_session_init(v9ses, dev_name, data)) < 0) {
> +		dprintk(DEBUG_ERROR, "problem initiating session\n");
> +		sb = ERR_PTR(newfid);
> +		goto free_session;
> +	}
> +
> +	sb = sget(fs_type, NULL, v9fs_set_super, v9ses);
> +
> +	sb->s_maxbytes = MAX_LFS_FILESIZE;
> +	sb->s_blocksize =
> +	    v9fs_block_bits(v9ses->maxdata, &sb->s_blocksize_bits);
> +	sb->s_magic = V9FS_WIRE_MAGIC;
> +	sb->s_op = &v9fs_super_ops;

Please consider extracting these to a v9fs_fill_super() function to follow
the style set by other filesystems.

> +
> +	sb->s_flags |=
> +	    MS_ACTIVE | MS_SYNCHRONOUS | MS_DIRSYNC | MS_NODIRATIME |
> +	    MS_NOATIME;
> +
> +	inode = v9fs_get_inode(sb, S_IFDIR | mode);
> +	if ((!inode) || IS_ERR(inode)) {
> +		sb = ERR_PTR(-EINVAL);

It is a good idea to return the same error (to propagate the error code)
but in this case it seems a lot simpler to make v9fs_get_inode always return
NULL on failure. You are being bit too defensive in your programming for
the kernel in other places as well.

> +
> +/**
> + * v9fs_kill_super - Kill Superblock
> + * @s: superblock
> + * 
> + */
> +
> +static void v9fs_kill_super(struct super_block *s)
> +{
> +	struct v9fs_session_info *v9ses =
> +	    (struct v9fs_session_info *)s->s_fs_info;

Redundant cast.

		Pekka

      parent reply	other threads:[~2005-05-25  5:18 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-23 22:25 [RFC][patch 4/7] v9fs: VFS superblock operations (2.0-rc6) ericvh
2005-05-24  7:11 ` Pekka Enberg
2005-05-24 19:08   ` Eric Van Hensbergen
2005-05-25  4:54     ` Pekka Enberg
2005-05-25 11:55       ` Eric Van Hensbergen
2005-05-25 12:15         ` Pekka J Enberg
2005-05-25 14:41           ` Eric Van Hensbergen
2005-05-25  5:17 ` Pekka Enberg [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=84144f02050524221757820a18@mail.gmail.com \
    --to=penberg@gmail.com \
    --cc=ericvh@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=penberg@cs.helsinki.fi \
    --cc=v9fs-developer@lists.sourceforge.net \
    --cc=viro@parcelfarce.linux.theplanet.co.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.