diff mbox

Ceph: Avoid data inconsistency due to d-cache aliasing in readpage()

Message ID 1384327335-18812-1-git-send-email-liwang@ubuntukylin.com (mailing list archive)
State New, archived
Headers show

Commit Message

Li Wang Nov. 13, 2013, 7:22 a.m. UTC
If the length of data to be read in readpage() is exactly
PAGE_CACHE_SIZE, the original code does not flush d-cache
for data consistency after finishing reading. This patches fixes
this.

Signed-off-by: Li Wang <liwang@ubuntukylin.com>
---
 fs/ceph/addr.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Yan, Zheng Nov. 13, 2013, 1:19 p.m. UTC | #1
On Wed, Nov 13, 2013 at 3:22 PM, Li Wang <liwang@ubuntukylin.com> wrote:
> If the length of data to be read in readpage() is exactly
> PAGE_CACHE_SIZE, the original code does not flush d-cache
> for data consistency after finishing reading. This patches fixes
> this.
>
> Signed-off-by: Li Wang <liwang@ubuntukylin.com>
> ---
>  fs/ceph/addr.c |    8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
> index 6df8bd4..7b0000a 100644
> --- a/fs/ceph/addr.c
> +++ b/fs/ceph/addr.c
> @@ -210,9 +210,13 @@ static int readpage_nounlock(struct file *filp, struct page *page)
>         if (err < 0) {
>                 SetPageError(page);
>                 goto out;
> -       } else if (err < PAGE_CACHE_SIZE) {
> +       } else {
> +               if (err < PAGE_CACHE_SIZE) {
>                 /* zero fill remainder of page */
> -               zero_user_segment(page, err, PAGE_CACHE_SIZE);
> +                       zero_user_segment(page, err, PAGE_CACHE_SIZE);
> +               } else {
> +                       flush_dcache_page(page);
> +               }

this doesn't make sense for me. why not call flush_dcache_page unconditionally?

Regards
Yan, Zheng
>         }
>         SetPageUptodate(page);
>
> --
> 1.7.9.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Li Wang Nov. 13, 2013, 2:37 p.m. UTC | #2
Hi Yan,
   zero_user_segment() has invoked flush_dcache_page() for us, we donnot 
wanna flush d-cache twice.

Cheers,
Li Wang

On 11/13/2013 09:19 PM, Yan, Zheng wrote:
> On Wed, Nov 13, 2013 at 3:22 PM, Li Wang <liwang@ubuntukylin.com> wrote:
>> If the length of data to be read in readpage() is exactly
>> PAGE_CACHE_SIZE, the original code does not flush d-cache
>> for data consistency after finishing reading. This patches fixes
>> this.
>>
>> Signed-off-by: Li Wang <liwang@ubuntukylin.com>
>> ---
>>   fs/ceph/addr.c |    8 ++++++--
>>   1 file changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
>> index 6df8bd4..7b0000a 100644
>> --- a/fs/ceph/addr.c
>> +++ b/fs/ceph/addr.c
>> @@ -210,9 +210,13 @@ static int readpage_nounlock(struct file *filp, struct page *page)
>>          if (err < 0) {
>>                  SetPageError(page);
>>                  goto out;
>> -       } else if (err < PAGE_CACHE_SIZE) {
>> +       } else {
>> +               if (err < PAGE_CACHE_SIZE) {
>>                  /* zero fill remainder of page */
>> -               zero_user_segment(page, err, PAGE_CACHE_SIZE);
>> +                       zero_user_segment(page, err, PAGE_CACHE_SIZE);
>> +               } else {
>> +                       flush_dcache_page(page);
>> +               }
>
> this doesn't make sense for me. why not call flush_dcache_page unconditionally?
>
> Regards
> Yan, Zheng
>>          }
>>          SetPageUptodate(page);
>>
>> --
>> 1.7.9.5
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at  http://www.tux.org/lkml/
>
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index 6df8bd4..7b0000a 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -210,9 +210,13 @@  static int readpage_nounlock(struct file *filp, struct page *page)
 	if (err < 0) {
 		SetPageError(page);
 		goto out;
-	} else if (err < PAGE_CACHE_SIZE) {
+	} else {
+		if (err < PAGE_CACHE_SIZE) {
 		/* zero fill remainder of page */
-		zero_user_segment(page, err, PAGE_CACHE_SIZE);
+			zero_user_segment(page, err, PAGE_CACHE_SIZE);
+		} else {
+			flush_dcache_page(page);
+		}
 	}
 	SetPageUptodate(page);