From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: ACJfBot1cTyuoOLiTK9pGTk6aKghm1HIWZrc33Q2GfMgKSAPGOYkxxtJXlKtvwPgGhFiRGvwXyKF ARC-Seal: i=1; a=rsa-sha256; t=1516203131; cv=none; d=google.com; s=arc-20160816; b=0CD/WKlJPyzn8S4cEGv8f7vGgFLWiwepTNucH0zhMqmZ+2VpXt/qr/Y4HdTQJxFfI8 iRP47Bg2KM9ghUptk2xm4AEqoRFNI4rsqHldU2JFIFvsBxnv05wJBRB7BQBZYj+b1jyS 7TYyCoaLP8CeHB82XoPykySSRRXjA2DmYXANEFYk4uow03xeyIvrPxDtexTPPZ1Jk7Tp giaw8CD/8WM3klGQ7UH2fIXnJNd+uNScIEmBFz8Wz0FcPKHuW68KSfVluWGcDWfv0rBq Naw9yxptR7JCiB3gKu6mxSqG0DggSMp4/hUeaCSUYRYGeRSYTCzRMNNj8J68s4MWbDK/ 4aMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:references:message-id:in-reply-to:subject :cc:to:from:date:dkim-signature:arc-authentication-results; bh=+pJeVWDdek90bbJc2gvSR9H9BGp5pug9WM+Hxxoppw8=; b=xUSD1DEQq2Au4oK75j3bb+41zT6O3owEunDTY1wk4oD/NnSyy7QuiNNKSX9EGJAfax QhrzuxHvNaCugM/kZL4dJj0JThG5wTB0/9yqOmPlHdtsVjO2X91swmMKBXmwNrRpHViK OkrJcD51HsuOBLJQTSpln8s4Sj9KZXSnMqIen/P6d4ouwBGCJx38hzm0Fbqo7m3IQYM3 0WzSx7dN5+W4Yg4ya/YkkB/zwgeIXIdH9ulvWYN77umxuDIUOt0WzB+4Jk9PwPx6xjAG +1L3f2i85RgMwQQoH7uc+GB/EfGZl6F76yTrRHvi+t5AluGsxvdhezTLNu8o392TLK9y 5qIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=uTBL7U+O; spf=pass (google.com: best guess record for domain of jsimmons@infradead.org designates 2001:8b0:10b:1236::1 as permitted sender) smtp.mailfrom=jsimmons@infradead.org Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=uTBL7U+O; spf=pass (google.com: best guess record for domain of jsimmons@infradead.org designates 2001:8b0:10b:1236::1 as permitted sender) smtp.mailfrom=jsimmons@infradead.org Date: Wed, 17 Jan 2018 15:32:04 +0000 (GMT) From: James Simmons To: NeilBrown cc: Oleg Drokin , Andreas Dilger , Greg Kroah-Hartman , lkml , lustre Subject: Re: [PATCH 09/19] staging: lustre: open code polling loop instead of using l_wait_event() In-Reply-To: <151538209364.23920.15335820464811680168.stgit@noble> Message-ID: References: <151538168618.23920.8261096424342988792.stgit@noble> <151538209364.23920.15335820464811680168.stgit@noble> User-Agent: Alpine 2.21 (LFD 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180117_153205_055979_26D93721 X-CRM114-Status: GOOD ( 13.71 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.1 on casper.infradead.org summary: Content analysis details: (-1.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 NO_RELAYS Informational: message was not relayed via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: =?utf-8?q?1588993419015050119?= X-GMAIL-MSGID: =?utf-8?q?1589854214791735787?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: > Two places that LWI_TIMEOUT_INTERVAL() is used, the outcome is a > simple polling loop that polls every second for some event (with a > limit). > > So write a simple loop to make this more apparent. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lustre/llite/llite_lib.c | 11 +++++------ > drivers/staging/lustre/lustre/lov/lov_request.c | 12 +++++------- > 2 files changed, 10 insertions(+), 13 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c > index 33dc15e9aebb..f6642fa30428 100644 > --- a/drivers/staging/lustre/lustre/llite/llite_lib.c > +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c > @@ -1984,8 +1984,7 @@ void ll_umount_begin(struct super_block *sb) > struct ll_sb_info *sbi = ll_s2sbi(sb); > struct obd_device *obd; > struct obd_ioctl_data *ioc_data; > - wait_queue_head_t waitq; > - struct l_wait_info lwi; > + int cnt = 0; > > CDEBUG(D_VFSTRACE, "VFS Op: superblock %p count %d active %d\n", sb, > sb->s_count, atomic_read(&sb->s_active)); > @@ -2021,10 +2020,10 @@ void ll_umount_begin(struct super_block *sb) > * and then continue. For now, we just periodically checking for vfs > * to decrement mnt_cnt and hope to finish it within 10sec. > */ > - init_waitqueue_head(&waitq); > - lwi = LWI_TIMEOUT_INTERVAL(10 * HZ, > - HZ, NULL, NULL); > - l_wait_event(waitq, may_umount(sbi->ll_mnt.mnt), &lwi); > + while (cnt < 10 && !may_umount(sbi->ll_mnt.mnt)) { > + schedule_timeout_uninterruptible(HZ); > + cnt ++; > + } > > schedule(); > } > diff --git a/drivers/staging/lustre/lustre/lov/lov_request.c b/drivers/staging/lustre/lustre/lov/lov_request.c > index fb3b7a7fa32a..c1e58fcc30b3 100644 > --- a/drivers/staging/lustre/lustre/lov/lov_request.c > +++ b/drivers/staging/lustre/lustre/lov/lov_request.c > @@ -99,8 +99,7 @@ static int lov_check_set(struct lov_obd *lov, int idx) > */ > static int lov_check_and_wait_active(struct lov_obd *lov, int ost_idx) > { > - wait_queue_head_t waitq; > - struct l_wait_info lwi; > + int cnt = 0; > struct lov_tgt_desc *tgt; > int rc = 0; > > @@ -125,11 +124,10 @@ static int lov_check_and_wait_active(struct lov_obd *lov, int ost_idx) > > mutex_unlock(&lov->lov_lock); > > - init_waitqueue_head(&waitq); > - lwi = LWI_TIMEOUT_INTERVAL(obd_timeout * HZ, > - HZ, NULL, NULL); > - > - rc = l_wait_event(waitq, lov_check_set(lov, ost_idx), &lwi); > + while (cnt < obd_timeout && !lov_check_set(lov, ost_idx)) { > + schedule_timeout_uninterruptible(HZ); > + cnt ++; > + } > if (tgt->ltd_active) > return 1; > > > > From mboxrd@z Thu Jan 1 00:00:00 1970 From: James Simmons Date: Wed, 17 Jan 2018 15:32:04 +0000 (GMT) Subject: [lustre-devel] [PATCH 09/19] staging: lustre: open code polling loop instead of using l_wait_event() In-Reply-To: <151538209364.23920.15335820464811680168.stgit@noble> References: <151538168618.23920.8261096424342988792.stgit@noble> <151538209364.23920.15335820464811680168.stgit@noble> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: NeilBrown Cc: Oleg Drokin , Andreas Dilger , Greg Kroah-Hartman , lkml , lustre > Two places that LWI_TIMEOUT_INTERVAL() is used, the outcome is a > simple polling loop that polls every second for some event (with a > limit). > > So write a simple loop to make this more apparent. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lustre/llite/llite_lib.c | 11 +++++------ > drivers/staging/lustre/lustre/lov/lov_request.c | 12 +++++------- > 2 files changed, 10 insertions(+), 13 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c > index 33dc15e9aebb..f6642fa30428 100644 > --- a/drivers/staging/lustre/lustre/llite/llite_lib.c > +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c > @@ -1984,8 +1984,7 @@ void ll_umount_begin(struct super_block *sb) > struct ll_sb_info *sbi = ll_s2sbi(sb); > struct obd_device *obd; > struct obd_ioctl_data *ioc_data; > - wait_queue_head_t waitq; > - struct l_wait_info lwi; > + int cnt = 0; > > CDEBUG(D_VFSTRACE, "VFS Op: superblock %p count %d active %d\n", sb, > sb->s_count, atomic_read(&sb->s_active)); > @@ -2021,10 +2020,10 @@ void ll_umount_begin(struct super_block *sb) > * and then continue. For now, we just periodically checking for vfs > * to decrement mnt_cnt and hope to finish it within 10sec. > */ > - init_waitqueue_head(&waitq); > - lwi = LWI_TIMEOUT_INTERVAL(10 * HZ, > - HZ, NULL, NULL); > - l_wait_event(waitq, may_umount(sbi->ll_mnt.mnt), &lwi); > + while (cnt < 10 && !may_umount(sbi->ll_mnt.mnt)) { > + schedule_timeout_uninterruptible(HZ); > + cnt ++; > + } > > schedule(); > } > diff --git a/drivers/staging/lustre/lustre/lov/lov_request.c b/drivers/staging/lustre/lustre/lov/lov_request.c > index fb3b7a7fa32a..c1e58fcc30b3 100644 > --- a/drivers/staging/lustre/lustre/lov/lov_request.c > +++ b/drivers/staging/lustre/lustre/lov/lov_request.c > @@ -99,8 +99,7 @@ static int lov_check_set(struct lov_obd *lov, int idx) > */ > static int lov_check_and_wait_active(struct lov_obd *lov, int ost_idx) > { > - wait_queue_head_t waitq; > - struct l_wait_info lwi; > + int cnt = 0; > struct lov_tgt_desc *tgt; > int rc = 0; > > @@ -125,11 +124,10 @@ static int lov_check_and_wait_active(struct lov_obd *lov, int ost_idx) > > mutex_unlock(&lov->lov_lock); > > - init_waitqueue_head(&waitq); > - lwi = LWI_TIMEOUT_INTERVAL(obd_timeout * HZ, > - HZ, NULL, NULL); > - > - rc = l_wait_event(waitq, lov_check_set(lov, ost_idx), &lwi); > + while (cnt < obd_timeout && !lov_check_set(lov, ost_idx)) { > + schedule_timeout_uninterruptible(HZ); > + cnt ++; > + } > if (tgt->ltd_active) > return 1; > > > >