From: alex chen <alex.chen@huawei.com>
To: ocfs2-devel@oss.oracle.com
Subject: [Ocfs2-devel] [PATCH v2] ocfs2: the ip_alloc_sem should be taken in ocfs2_get_block()
Date: Tue, 24 Oct 2017 11:39:44 +0800 [thread overview]
Message-ID: <59EEB600.2030902@huawei.com> (raw)
In-Reply-To: <59EE07CD020000F9000945D8@prv-mh.provo.novell.com>
Hi Everybody,
Thanks for your reviews.
I agree with Gang to make function name ocfs2_get_block_lock() more
readable. But the ocfs2_get_block_lock() may be called by the
ocfs2_dio_get_block() in re-write sitiation, so I don't think the
ocfs2_dio_rd_get_block() is a better name. I agree with Joseph and
rename it to ocfs2_lock_get_block().
BTW, I think the ocfs2_dio_wr_get_block() is more suitable for the
ocfs2_dio_get_block().
Please give me any feedback if you have any suggestions.
Thanks
Alex
On 2017/10/23 15:16, Gang He wrote:
> Hello Alex,
>
> Base on your bug description, I think that the fix should be OK.
> But I suggest you to use more clear function name in this patch.
> 1) For new-added function ocfs2_get_block_lock(), I think that it is better if the function name is ocfs2_dio_rd_get_block().
> 2) Then, rename the original function ocfs2_dio_get_block() to ocfs2_dio_wr_get_block().
> Why?
> Since this function looks to only be used by direct IO (read) mode,
> we should make the function name more clear, do NOT make other developer to misunderstand/misuse it in the future.
>
> Thanks
> Gang
>
>
>>>>
>> The ip_alloc_sem should be taken in ocfs2_get_block() when reading file
>> in DIRECT mode to prevent concurrent access to extent tree with
>> ocfs2_dio_end_io_write(), which may cause BUGON in
>> ocfs2_get_clusters_nocache()->BUG_ON(v_cluster < le32_to_cpu(rec->e_cpos))
>>
>> Fixes: c15471f79506 ("ocfs2: fix sparse file & data ordering issue in direct
>> io")
>>
>> Signed-off-by: Alex Chen <alex.chen@huawei.com>
>> Reviewed-by: Jun Piao <piaojun@huawei.com>
>> Acked-by: Changwei Ge <ge.changwei@h3c.com>
>>
>> ---
>> fs/ocfs2/aops.c | 22 ++++++++++++++++------
>> 1 file changed, 16 insertions(+), 6 deletions(-)
>>
>> diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
>> index 88a31e9..29607d9 100644
>> --- a/fs/ocfs2/aops.c
>> +++ b/fs/ocfs2/aops.c
>> @@ -134,6 +134,19 @@ static int ocfs2_symlink_get_block(struct inode *inode,
>> sector_t iblock,
>> return err;
>> }
>>
>> +static int ocfs2_get_block_lock(struct inode *inode, sector_t iblock,
>> + struct buffer_head *bh_result, int create)
>> +{
>> + int ret = 0;
>> + struct ocfs2_inode_info *oi = OCFS2_I(inode);
>> +
>> + down_read(&oi->ip_alloc_sem);
>> + ret = ocfs2_get_block(inode, iblock, bh_result, create);
>> + up_read(&oi->ip_alloc_sem);
>> +
>> + return ret;
>> +}
>> +
>> int ocfs2_get_block(struct inode *inode, sector_t iblock,
>> struct buffer_head *bh_result, int create)
>> {
>> @@ -2154,12 +2167,9 @@ static int ocfs2_dio_get_block(struct inode *inode,
>> sector_t iblock,
>> * while file size will be changed.
>> */
>> if (pos + total_len <= i_size_read(inode)) {
>> - down_read(&oi->ip_alloc_sem);
>> - /* This is the fast path for re-write. */
>> - ret = ocfs2_get_block(inode, iblock, bh_result, create);
>> -
>> - up_read(&oi->ip_alloc_sem);
>>
>> + /* This is the fast path for re-write. */
>> + ret = ocfs2_get_block_lock(inode, iblock, bh_result, create);
>> if (buffer_mapped(bh_result) &&
>> !buffer_new(bh_result) &&
>> ret == 0)
>> @@ -2424,7 +2434,7 @@ static ssize_t ocfs2_direct_IO(struct kiocb *iocb,
>> struct iov_iter *iter)
>> return 0;
>>
>> if (iov_iter_rw(iter) == READ)
>> - get_block = ocfs2_get_block;
>> + get_block = ocfs2_get_block_lock;
>> else
>> get_block = ocfs2_dio_get_block;
>>
>> --
>> 1.9.5.msysgit.1
>>
>>
>> _______________________________________________
>> Ocfs2-devel mailing list
>> Ocfs2-devel at oss.oracle.com
>> https://oss.oracle.com/mailman/listinfo/ocfs2-devel
>
>
> .
>
prev parent reply other threads:[~2017-10-24 3:39 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-20 9:03 [Ocfs2-devel] [PATCH] ocfs2: the ip_alloc_sem should be taken in ocfs2_get_block() alex chen
2017-10-20 9:23 ` Changwei Ge
2017-10-23 2:39 ` alex chen
2017-10-21 3:27 ` Changwei Ge
2017-10-23 3:09 ` alex chen
2017-10-23 3:31 ` Joseph Qi
2017-10-23 4:06 ` Eric Ren
2017-10-23 5:40 ` [Ocfs2-devel] [PATCH v2] " alex chen
2017-10-23 7:16 ` Gang He
2017-10-24 3:39 ` alex chen [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=59EEB600.2030902@huawei.com \
--to=alex.chen@huawei.com \
--cc=ocfs2-devel@oss.oracle.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 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.