All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cong Wang <amwang@redhat.com>
To: Dave Hansen <dave@linux.vnet.ibm.com>
Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
	Hugh Dickins <hughd@google.com>,
	linux-mm@kvack.org, Lennart Poettering <lennart@poettering.net>,
	KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Subject: Re: [Patch] tmpfs: add fallocate support
Date: Wed, 16 Nov 2011 15:21:56 +0800	[thread overview]
Message-ID: <4EC36494.30803@redhat.com> (raw)
In-Reply-To: <1321379039.12374.11.camel@nimitz>

于 2011年11月16日 01:43, Dave Hansen 写道:
> On Tue, 2011-11-15 at 18:23 +0800, Cong Wang wrote:
>>> +static long shmem_fallocate(struct file *file, int mode,
>>> +			    loff_t offset, loff_t len)
>>> +{
>>> +	struct inode *inode = file->f_path.dentry->d_inode;
>>> +	struct address_space *mapping = inode->i_mapping;
>>> +	struct shmem_inode_info *info = SHMEM_I(inode);
>>> +	struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb);
>>> +	pgoff_t start = DIV_ROUND_UP(offset, PAGE_CACHE_SIZE);
>>> +	pgoff_t end = DIV_ROUND_UP((offset + len), PAGE_CACHE_SIZE);
>>> +	pgoff_t index = start;
>>> +	gfp_t gfp = mapping_gfp_mask(mapping);
>>> +	loff_t i_size = i_size_read(inode);
>>> +	struct page *page = NULL;
>>> +	int ret;
>>> +
>>> +	if ((offset + len)<= i_size)
>>> +		return 0;
>
> This seems to say that if the fallocate() call ends before the end of
> the file we should ignore the call.  In other words, this can only be
> used to extend the file, but could not be used to fill in the holes of a
> sparse file.
>
> Is there a reason it was done that way?

Hmm, I missed the case of sparse file, so you are right, I need to fix it.

>
>>> +	if (!(mode&   FALLOC_FL_KEEP_SIZE)) {
>>> +		ret = inode_newsize_ok(inode, (offset + len));
>>> +		if (ret)
>>> +			return ret;
>>> +	}
>
> inode_newsize_ok()'s comments say:
>
>   * inode_newsize_ok must be called with i_mutex held.
>
> But I don't see any trace of it.
>

Hmm, even for tmpfs? I see none of the tmpfs code takes
i_mutex lock though...

>>> +	if (start == end) {
>>> +		if (!(mode&   FALLOC_FL_KEEP_SIZE))
>>> +			i_size_write(inode, offset + len);
>>> +		return 0;
>>> +	}
>
> There's a whitespace borkage like that 'mode&' all over this patch.
> Probably needs a little love.

Odd, it is fine in my local patch, and it passed checkpatch.pl
check before I sent it.

<...>	
>
> This seems to have borrowed quite generously from shmem_getpage_gfp().
> Seems like some code consolidation is in order before this level of
> copy-n-paste.

Yes, I will separate the similar code.

Thanks for review!

WARNING: multiple messages have this Message-ID (diff)
From: Cong Wang <amwang@redhat.com>
To: Dave Hansen <dave@linux.vnet.ibm.com>
Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
	Hugh Dickins <hughd@google.com>,
	linux-mm@kvack.org, Lennart Poettering <lennart@poettering.net>,
	KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Subject: Re: [Patch] tmpfs: add fallocate support
Date: Wed, 16 Nov 2011 15:21:56 +0800	[thread overview]
Message-ID: <4EC36494.30803@redhat.com> (raw)
In-Reply-To: <1321379039.12374.11.camel@nimitz>

ao? 2011a1'11ae??16ae?JPY 01:43, Dave Hansen a??e??:
> On Tue, 2011-11-15 at 18:23 +0800, Cong Wang wrote:
>>> +static long shmem_fallocate(struct file *file, int mode,
>>> +			    loff_t offset, loff_t len)
>>> +{
>>> +	struct inode *inode = file->f_path.dentry->d_inode;
>>> +	struct address_space *mapping = inode->i_mapping;
>>> +	struct shmem_inode_info *info = SHMEM_I(inode);
>>> +	struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb);
>>> +	pgoff_t start = DIV_ROUND_UP(offset, PAGE_CACHE_SIZE);
>>> +	pgoff_t end = DIV_ROUND_UP((offset + len), PAGE_CACHE_SIZE);
>>> +	pgoff_t index = start;
>>> +	gfp_t gfp = mapping_gfp_mask(mapping);
>>> +	loff_t i_size = i_size_read(inode);
>>> +	struct page *page = NULL;
>>> +	int ret;
>>> +
>>> +	if ((offset + len)<= i_size)
>>> +		return 0;
>
> This seems to say that if the fallocate() call ends before the end of
> the file we should ignore the call.  In other words, this can only be
> used to extend the file, but could not be used to fill in the holes of a
> sparse file.
>
> Is there a reason it was done that way?

Hmm, I missed the case of sparse file, so you are right, I need to fix it.

>
>>> +	if (!(mode&   FALLOC_FL_KEEP_SIZE)) {
>>> +		ret = inode_newsize_ok(inode, (offset + len));
>>> +		if (ret)
>>> +			return ret;
>>> +	}
>
> inode_newsize_ok()'s comments say:
>
>   * inode_newsize_ok must be called with i_mutex held.
>
> But I don't see any trace of it.
>

Hmm, even for tmpfs? I see none of the tmpfs code takes
i_mutex lock though...

>>> +	if (start == end) {
>>> +		if (!(mode&   FALLOC_FL_KEEP_SIZE))
>>> +			i_size_write(inode, offset + len);
>>> +		return 0;
>>> +	}
>
> There's a whitespace borkage like that 'mode&' all over this patch.
> Probably needs a little love.

Odd, it is fine in my local patch, and it passed checkpatch.pl
check before I sent it.

<...>	
>
> This seems to have borrowed quite generously from shmem_getpage_gfp().
> Seems like some code consolidation is in order before this level of
> copy-n-paste.

Yes, I will separate the similar code.

Thanks for review!

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2011-11-16  7:22 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-15  8:42 [Patch] tmpfs: add fallocate support Amerigo Wang
2011-11-15  8:42 ` Amerigo Wang
2011-11-15 10:23 ` Cong Wang
2011-11-15 10:23   ` Cong Wang
2011-11-15 17:43   ` Dave Hansen
2011-11-15 17:43     ` Dave Hansen
2011-11-16  7:21     ` Cong Wang [this message]
2011-11-16  7:21       ` Cong Wang
2011-11-16 23:21       ` Dave Hansen
2011-11-16 23:21         ` Dave Hansen
2011-11-15 11:23 ` Pekka Enberg
2011-11-15 11:23   ` Pekka Enberg
2011-11-16  7:09   ` Cong Wang
2011-11-16  7:09     ` Cong Wang
2011-11-16  7:12     ` Pekka Enberg
2011-11-16  7:12       ` Pekka Enberg
2011-11-16  7:16       ` Cong Wang
2011-11-16  7:16         ` Cong Wang
2011-11-17  1:31         ` Hugh Dickins
2011-11-18 10:27           ` Cong Wang
2011-11-18 10:27             ` Cong Wang
2011-11-16  1:18 ` KAMEZAWA Hiroyuki
2011-11-16  1:18   ` KAMEZAWA Hiroyuki
2011-11-16  7:12   ` Cong Wang
2011-11-16  7:12     ` Cong Wang

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=4EC36494.30803@redhat.com \
    --to=amwang@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=dave@linux.vnet.ibm.com \
    --cc=hughd@google.com \
    --cc=kosaki.motohiro@jp.fujitsu.com \
    --cc=lennart@poettering.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /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.