All of lore.kernel.org
 help / color / mirror / Atom feed
From: majianpeng <majianpeng@gmail.com>
To: "Yan, Zheng" <ukernel@gmail.com>
Cc: sage <sage@inktank.com>, "Yan, Zheng" <zheng.z.yan@intel.com>,
	ceph-devel <ceph-devel@vger.kernel.org>
Subject: Re: Re: [PATCH] ceph: fix sync read eof check deadlock
Date: Tue, 24 Sep 2013 10:43:26 +0800	[thread overview]
Message-ID: <201309241043226589572@gmail.com> (raw)
In-Reply-To: CAAM7YA=bg=T0s3kagEquXfSdnxWT2-4Yv6863dhVhuTW0MNQjg@mail.gmail.com

>On Mon, Sep 23, 2013 at 9:39 AM, majianpeng <majianpeng@gmail.com> wrote:
>> As Yan,Zheng said, commit 0913444208db intruoduce a bug:"getattr need to
>> "read lock" inode's filelock. But the lock can be in unstable state.
>> the getattr request waits for lock's state to become stable, the lock
>> waits for client to release Fr cap."
>>
>> Commit 6a026589ba333185c466c90 resolved the same bug also.
>> Before doing getattr, it must put the caps which already hold avoid
>> deadlock.
>>
>> Reported-by: Yan, Zheng <zheng.z.yan@intel.com>
>> Signed-off-by: Jianpeng Ma <majianpeng@gmail.com>
>> ---
>>  fs/ceph/file.c | 25 ++++++++++++++++++++-----
>>  1 file changed, 20 insertions(+), 5 deletions(-)
>>
>> diff --git a/fs/ceph/file.c b/fs/ceph/file.c
>> index 7da35c7..bc00ace 100644
>> --- a/fs/ceph/file.c
>> +++ b/fs/ceph/file.c
>> @@ -839,7 +839,15 @@ again:
>>                 ret = ceph_sync_read(iocb, &i, &checkeof);
>>
>>                 if (checkeof && ret >= 0) {
>> -                       int statret = ceph_do_getattr(inode,
>> +                       int statret;
>> +                       /*
>> +                        *Before getattr,it should put caps avoid
>> +                        *deadlock.
>> +                        */
>> +                       ceph_put_cap_refs(ci, got);
>> +                       got = 0;
>> +
>> +                       statret = ceph_do_getattr(inode,
>>                                                       CEPH_STAT_CAP_SIZE);
>>
>>                         /* hit EOF or hole? */
>> @@ -851,16 +859,23 @@ again:
>>
>>                                 read += ret;
>>                                 checkeof = 0;
>> -                               goto again;
>> +                               ret = ceph_get_caps(ci, CEPH_CAP_FILE_RD,
>> +                                                       want, &got, -1);
>> +                               if (ret < 0)
>> +                                       ret = 0;
>> +                               else
>> +                                       goto again;
>
>I think we should try getting Frc caps here, because mds may issue Fc
>cap to the client while requesting the size.
>
Yes,it maybe get Fc.My though whether or not, the later read only using sync_mode.
The reason:
A:for requesting size only for sync-read not cache-read
B:By the original, it will make the cache-read to do the same thing which sync-read alread done.

Thanks!
Jianpeng Ma
>Your previous patch moved the getattr code to here. please revert the
>code to its original shape. I think it does the right thing.
>
>
>Regards
>Yan, Zheng
>
>
>>                         }
>>                 }
>>
>>         } else
>>                 ret = generic_file_aio_read(iocb, iov, nr_segs, pos);
>>
>> -       dout("aio_read %p %llx.%llx dropping cap refs on %s = %d\n",
>> -            inode, ceph_vinop(inode), ceph_cap_string(got), (int)ret);
>> -       ceph_put_cap_refs(ci, got);
>> +       if (got) {
>> +               dout("aio_read %p %llx.%llx dropping cap refs on %s = %d\n",
>> +                    inode, ceph_vinop(inode), ceph_cap_string(got), (int)ret);
>> +               ceph_put_cap_refs(ci, got);
>> +       }
>
>
>
>
>>
>>         if (ret >= 0)
>>                 ret += read;
>> --
>> 1.8.4-rc0

  reply	other threads:[~2013-09-24  2:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-23  1:39 [PATCH] ceph: fix sync read eof check deadlock majianpeng
2013-09-24  1:32 ` Yan, Zheng
2013-09-24  2:43   ` majianpeng [this message]
2013-09-24  5:29     ` Yan, Zheng

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=201309241043226589572@gmail.com \
    --to=majianpeng@gmail.com \
    --cc=ceph-devel@vger.kernel.org \
    --cc=sage@inktank.com \
    --cc=ukernel@gmail.com \
    --cc=zheng.z.yan@intel.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.