linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
To: Namjae Jeon <linkinjeon@gmail.com>
Cc: akpm@linux-foundation.org, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Namjae Jeon <namjae.jeon@samsung.com>,
	Ravishankar N <ravi.n1@samsung.com>,
	Amit Sahrawat <a.sahrawat@samsung.com>
Subject: Re: [PATCH v5 5/8] fat: restructure export_operations
Date: Mon, 03 Dec 2012 18:51:16 +0900	[thread overview]
Message-ID: <87hao35uqz.fsf@devron.myhome.or.jp> (raw)
In-Reply-To: <1353504277-5947-1-git-send-email-linkinjeon@gmail.com> (Namjae Jeon's message of "Wed, 21 Nov 2012 22:24:37 +0900")

Namjae Jeon <linkinjeon@gmail.com> writes:

> +	if (MSDOS_SB(inode->i_sb)->options.nfs == FAT_NFS_NOSTALE_RO) {
> +		/* Use i_pos for ino. This is used as fileid of nfs. */
> +		stat->ino = fat_i_pos_read(MSDOS_SB(inode->i_sb), inode);

BTW, what number is used for root dir? If it is 0 (0 is special ino in
glibc), we have to use MSDOS_ROOT_INO instead.

> +#define FAT_FID_SIZE_WITHOUT_PARENT (offsetof(struct fat_fid, \
> +					      parent_i_pos_hi)/4)

(offset parent_i_pos_hi) / 4 == 2. Wrong.

> +#define FAT_FID_SIZE_WITH_PARENT (sizeof(struct fat_fid)/4)

4 should be sizeof(u32). Or simplely use immediate value.

> +static int
> +fat_encode_fh_nostale(struct inode *inode, __u32 *fh, int *lenp,
> +		      struct inode *parent)
> +{
> +	int len = *lenp;
> +	struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb);
> +	struct fat_fid *fid = (struct fat_fid *) fh;
> +	loff_t i_pos;
> +	int type = FILEID_FAT_WITHOUT_PARENT;
> +
> +	if (parent && (len < FAT_FID_SIZE_WITH_PARENT)) {
> +		*lenp = FAT_FID_SIZE_WITH_PARENT;
> +		return 255;

255 is now FILEID_INVALID, I think.

> +	} else if (len < FAT_FID_SIZE_WITHOUT_PARENT) {
> +		*lenp = FAT_FID_SIZE_WITHOUT_PARENT;
> +		return 255;
> +	}
> +
> +	i_pos = fat_i_pos_read(sbi, inode);
> +	*lenp = FAT_FID_SIZE_WITHOUT_PARENT;
> +	fid->i_gen = inode->i_generation;
> +	fid->i_pos_low = i_pos & 0xFFFFFFFF;
> +	fid->i_pos_hi = (i_pos >> 32) & 0xFFFF;
> +	if (parent) {
> +		i_pos = fat_i_pos_read(sbi, parent);
> +		fid->parent_i_pos_hi = (i_pos >> 32) & 0xFFFF;
> +		fid->parent_i_pos_low = i_pos & 0xFFFFFFFF;
> +		fid->parent_i_gen = parent->i_generation;
> +		type = FILEID_FAT_WITH_PARENT;
> +		*lenp = FAT_FID_SIZE_WITH_PARENT;
> +	}
> +
> +	return type;
> +}
> +
>  /**
>   * Map a NFS file handle to a corresponding dentry.
>   * The dentry may or may not be connected to the filesystem root.
>   */
> -struct dentry *fat_fh_to_dentry(struct super_block *sb, struct fid *fid,
> +static struct dentry *fat_fh_to_dentry(struct super_block *sb, struct fid *fid,
>  				int fh_len, int fh_type)
>  {
>  	return generic_fh_to_dentry(sb, fid, fh_len, fh_type,
>  				    fat_nfs_get_inode);
>  }
>  
> +static struct dentry *fat_fh_to_dentry_nostale(struct super_block *sb,
> +					       struct fid *fh, int fh_len,
> +					       int fh_type)
> +{
> +	struct inode *inode = NULL;
> +	struct fat_fid *fid = (struct fat_fid *)fh;
> +	loff_t i_pos;
> +
> +	switch (fh_type) {
> +	case FILEID_FAT_WITHOUT_PARENT:
> +		if (fh_len < FAT_FID_SIZE_WITHOUT_PARENT)
> +			return NULL;
> +	case FILEID_FAT_WITH_PARENT:
> +		if ((fh_len < FAT_FID_SIZE_WITH_PARENT) &&
> +			(fh_type == FILEID_FAT_WITH_PARENT))
> +			return NULL;

Do we have to care (FILEID_FAT_WITH_PARENT and fh_len < 5) here?

	if (fh_len < 2)
		return NULL;

	switch (fh_type) {
	case FILEID_INO32_GEN:
	case FILEID_INO32_GEN_PARENT:
		inode = get_inode(sb, fid->i32.ino, fid->i32.gen);
		break;
	}

	return d_obtain_alias(inode);

generic_fh_to_dentry() is above. I wonder why we have to care
fat_fid->parent* here.
-- 
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

  reply	other threads:[~2012-12-03  9:51 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-21 13:24 [PATCH v5 5/8] fat: restructure export_operations Namjae Jeon
2012-12-03  9:51 ` OGAWA Hirofumi [this message]
2012-12-04  6:23   ` Namjae Jeon
2012-12-04  9:28     ` OGAWA Hirofumi
2012-12-05  5:58       ` Namjae Jeon
2012-12-05  8:56         ` OGAWA Hirofumi
2012-12-05 11:45           ` Namjae Jeon
2012-12-05 12:11             ` OGAWA Hirofumi
2012-12-06  7:37               ` Namjae Jeon
2012-12-06  9:24                 ` OGAWA Hirofumi
2012-12-06  9:43                   ` Namjae Jeon

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=87hao35uqz.fsf@devron.myhome.or.jp \
    --to=hirofumi@mail.parknet.co.jp \
    --cc=a.sahrawat@samsung.com \
    --cc=akpm@linux-foundation.org \
    --cc=linkinjeon@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=namjae.jeon@samsung.com \
    --cc=ravi.n1@samsung.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).