From patchwork Mon Jul 23 23:50:44 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kent Overstreet X-Patchwork-Id: 1229331 Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by patchwork1.kernel.org (Postfix) with ESMTP id 91CFD40075 for ; Mon, 23 Jul 2012 23:54:55 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q6NNpoCF028008; Mon, 23 Jul 2012 19:51:51 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q6NNpnW5026119 for ; Mon, 23 Jul 2012 19:51:49 -0400 Received: from mx1.redhat.com (ext-mx15.extmail.prod.ext.phx2.redhat.com [10.5.110.20]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q6NNphJI011864 for ; Mon, 23 Jul 2012 19:51:43 -0400 Received: from mail-yw0-f46.google.com (mail-yw0-f46.google.com [209.85.213.46]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q6NNpgQw000610 for ; Mon, 23 Jul 2012 19:51:43 -0400 Received: by yhmm54 with SMTP id m54so6773508yhm.33 for ; Mon, 23 Jul 2012 16:51:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=YmKtww6CXqHScOL51+44WbzX812bWn2uTEtym8z5O7k=; b=YqWHdmNSTJd+7Vn7XlURh9r+o4SrSnWGy2kd57btZwrndXwcxBjm7RzFV06zR+2Gzu N3GvijlWUqimzKS2lnIm9ePnGLUvMqsPSlzI5IBfMMswSYzoxFKBQy9Wh0whtYapLoye IC/TImZ7G0hsj3VtrX2OsHVLinxw5ycni/ut8FNzij5VwfmNT/b7U/6pHd1ChAUie5aV hMdS0uwrtph+ryOUs31el3EmPhy8nYK7z9x6ZVeHmJeXlDBNEYXNkyQz8H0LMe2mXKti 4xbY1PjViv/hv09ReImTFFnjlc61Tl8gE8zjmISO53J1ZsHX5NGBUXyBixRaPnz0eZw+ fvSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=YmKtww6CXqHScOL51+44WbzX812bWn2uTEtym8z5O7k=; b=Ty9pC4h0Iz+4gS2eEb2aUY5nmhJnPbdjzADologMs6jow5QPHZURCi4psctU16LFs/ SP+1Dy7Jw5EP7WOqX8eTUlYKxoLPywifQNiWcF4A7nL+PXNyk/KIHf4jWS4rrhW3MuSb 5oD0SWzuohkoFHe0A1vk+nrku2RZvsiprLnqBGtTxPjT1vCJtiuLkFSxztktfCsgS+Hx OCVYXZWo4+x4mWVuNdeOP107u94r8LBJhka8Ajq0KVt/NeDwVF2Qa4/K4882dqIWrDNR QTnMIjmNSzXUv+x+PC1/+1utIajvN9DRGKY3rb/RVkC+fi1wEJ8qrbb8wzvm7BEKB74U /yFQ== Received: by 10.66.75.225 with SMTP id f1mr373743paw.35.1343087502250; Mon, 23 Jul 2012 16:51:42 -0700 (PDT) Received: by 10.66.75.225 with SMTP id f1mr373728paw.35.1343087502167; Mon, 23 Jul 2012 16:51:42 -0700 (PDT) Received: from formenos.mtv.corp.google.com (formenos.mtv.corp.google.com [172.18.110.66]) by mx.google.com with ESMTPS id tv6sm10886586pbc.24.2012.07.23.16.51.40 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 23 Jul 2012 16:51:40 -0700 (PDT) From: Kent Overstreet To: linux-bcache@vger.kernel.org, linux-kernel@vger.kernel.org, dm-devel@redhat.com Date: Mon, 23 Jul 2012 16:50:44 -0700 Message-Id: <1343087459-17645-2-git-send-email-koverstreet@google.com> In-Reply-To: <1343087459-17645-1-git-send-email-koverstreet@google.com> References: <1343087459-17645-1-git-send-email-koverstreet@google.com> X-Gm-Message-State: ALoCoQmG9h99qDKRwC2vXy3dnbZ1ULS7gBvzUtRgprjL9eUo5a1yQ6wvTVPvyjk17RF015d6FbnqmYPzp1tKMqObCY5h8N+fey7ub8RaehOT7iBgcxvRcL5HlmvjVMZSJpt5toqMP7HWvBS2dY4eSu12KLrwIKZUlC0W2a8eviuAKRTyFBvby16zjDPf71M9sThcCki5cols X-RedHat-Spam-Score: -2.711 (BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_LOW, SPF_PASS, T_RP_MATCHES_RCVD) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Scanned-By: MIMEDefang 2.68 on 10.5.110.20 X-loop: dm-devel@redhat.com Cc: tj@kernel.org, joe@perches.com, Kent Overstreet , vgoyal@redhat.com Subject: [dm-devel] [Bcache v15 01/16] Revert "rw_semaphore: remove up/down_read_non_owner" X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com This reverts commit 11b80f459adaf91a712f95e7734a17655a36bf30. Signed-off-by: Kent Overstreet --- include/linux/rwsem.h | 10 ++++++++++ kernel/rwsem.c | 16 ++++++++++++++++ 2 files changed, 26 insertions(+), 0 deletions(-) diff --git a/include/linux/rwsem.h b/include/linux/rwsem.h index 54bd7cd..ddfe46d 100644 --- a/include/linux/rwsem.h +++ b/include/linux/rwsem.h @@ -125,9 +125,19 @@ extern void downgrade_write(struct rw_semaphore *sem); */ extern void down_read_nested(struct rw_semaphore *sem, int subclass); extern void down_write_nested(struct rw_semaphore *sem, int subclass); +/* + * Take/release a lock when not the owner will release it. + * + * [ This API should be avoided as much as possible - the + * proper abstraction for this case is completions. ] + */ +extern void down_read_non_owner(struct rw_semaphore *sem); +extern void up_read_non_owner(struct rw_semaphore *sem); #else # define down_read_nested(sem, subclass) down_read(sem) # define down_write_nested(sem, subclass) down_write(sem) +# define down_read_non_owner(sem) down_read(sem) +# define up_read_non_owner(sem) up_read(sem) #endif #endif /* _LINUX_RWSEM_H */ diff --git a/kernel/rwsem.c b/kernel/rwsem.c index 6850f53..78b7915 100644 --- a/kernel/rwsem.c +++ b/kernel/rwsem.c @@ -116,6 +116,15 @@ void down_read_nested(struct rw_semaphore *sem, int subclass) EXPORT_SYMBOL(down_read_nested); +void down_read_non_owner(struct rw_semaphore *sem) +{ + might_sleep(); + + __down_read(sem); +} + +EXPORT_SYMBOL(down_read_non_owner); + void down_write_nested(struct rw_semaphore *sem, int subclass) { might_sleep(); @@ -126,6 +135,13 @@ void down_write_nested(struct rw_semaphore *sem, int subclass) EXPORT_SYMBOL(down_write_nested); +void up_read_non_owner(struct rw_semaphore *sem) +{ + __up_read(sem); +} + +EXPORT_SYMBOL(up_read_non_owner); + #endif