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 7/8] fat (exportfs): rebuild directory-inode if fat_dget() fails
Date: Fri, 21 Dec 2012 19:36:33 +0900 [thread overview]
Message-ID: <87k3sblmj2.fsf@devron.myhome.or.jp> (raw)
In-Reply-To: <87obhnlmkt.fsf@devron.myhome.or.jp> (OGAWA Hirofumi's message of "Fri, 21 Dec 2012 19:35:30 +0900")
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> writes:
> Namjae Jeon <linkinjeon@gmail.com> writes:
>
>>> Yes, we can't use fat_search_long() as is, of course. However, we can
>>> share the basic algorithm and code.
>>>
>>> The both are doing,
>>>
>>> 1) traverse the blocks chained by ->i_start.
>>> 2) get the record (dirent) from blocks.
>>> 3) check the detail of record
>>>
>>> The difference is only (3), right? I know, the code has many differences
>>> though. The actual logic are almost same.
>>>
>>> And see, e.g., fat_get_cluster() is checking several unexpected
>>> state. We have to care about corrupting data. It is not only
>>> "infinite-loop" case. And why I'm saying it is better to share code.
>>
>> Regarding unexpected conditions,
>> When we compare the unexpected conditions in fat_get_cluster:
>> We get these as conditions which can arise:
>> fat_end_read() returns:
>> 1) < 0
>> 2) FAT_ENT_FREE
>> 3) FAT_ENT_EOF
>> And the last is
>> 4) Preventing the infinite looping of cluster chain.
>>
>> Our patch is already covering the cases:
>> case 1) , 2) => if (search_clus < 0 || search_clus == FAT_ENT_FREE)
>> about case 3) => while (search_clus != FAT_ENT_EOF);
>>
>> while for Case 4:
>> We can make changes like this:
>>
>> @@ -179,8 +179,9 @@ struct dentry *fat_get_parent(struct dentry *child_dir)
>> struct inode *parent_inode = NULL;
>> struct msdos_sb_info *sbi = MSDOS_SB(sb);
>> int parent_logstart;
>> - int search_clus, clus_to_match;
>> + int search_clus, clus_to_match, clus_count = 0;
>> sector_t blknr;
>> + const int limit = sb->s_maxbytes >> MSDOS_SB(sb)->cluster_bits;
>>
>> if (!fat_get_dotdot_entry(child_dir->d_inode, &dotdot_bh, &de)) {
>> parent_logstart = fat_get_start(sbi, de);
>> @@ -223,6 +224,14 @@ struct dentry *fat_get_parent(struct dentry *child_dir)
>> search_clus, clus_to_match);
>> if (IS_ERR(parent_inode) || parent_inode)
>> break;
>> + if (++clus_count > limit) {
>> + fat_fs_error_ratelimit(sb,
>> + "%s: detected the cluster chain loop"
>> + " while reading directory entries from"
>> + " cluster %d", __func__, search_clus);
>> + parent_inode = ERR_PTR(-EIO);
>> + break;
>> + }
>> fatent_init(&fatent);
>> search_clus = fat_ent_read(sb, &fatent,
>> search_clus);
>
> and it is copy of fat_get_cluster(), right? It would be sane as start
> though, it is true to increase maintain cost, and it makes more similar
> to fat_search_long() path. It is why I said, copy at first, and
> refactoring after that.
BTW, fat_search_long() was wrong as similar function. Actually it would
be fat_scan(), because we don't care longname entry.
--
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
next prev parent reply other threads:[~2012-12-21 10:36 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-21 13:25 [PATCH v5 7/8] fat (exportfs): rebuild directory-inode if fat_dget() fails Namjae Jeon
2012-12-03 9:57 ` OGAWA Hirofumi
2012-12-04 6:27 ` Namjae Jeon
2012-12-04 9:31 ` OGAWA Hirofumi
2012-12-05 6:01 ` Namjae Jeon
2012-12-05 9:02 ` OGAWA Hirofumi
2012-12-05 11:56 ` Namjae Jeon
2012-12-15 10:52 ` Namjae Jeon
2012-12-19 16:10 ` OGAWA Hirofumi
2012-12-21 5:03 ` Namjae Jeon
2012-12-21 5:08 ` Namjae Jeon
2012-12-21 8:19 ` OGAWA Hirofumi
2012-12-21 10:15 ` Namjae Jeon
2012-12-21 10:35 ` OGAWA Hirofumi
2012-12-21 10:36 ` OGAWA Hirofumi [this message]
2013-01-09 6:24 ` Namjae Jeon
2013-01-20 11:06 ` OGAWA Hirofumi
2013-01-22 10:31 ` Namjae Jeon
2013-01-26 4:22 ` OGAWA Hirofumi
2013-01-28 7:43 ` Namjae Jeon
2013-01-28 13:51 ` OGAWA Hirofumi
2013-01-29 5:05 ` 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=87k3sblmj2.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).