From patchwork Wed Feb 17 17:55:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Brandenburg X-Patchwork-Id: 8341781 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 375EB9F38B for ; Wed, 17 Feb 2016 17:56:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1167C20380 for ; Wed, 17 Feb 2016 17:56:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BF5CB20375 for ; Wed, 17 Feb 2016 17:56:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1422717AbcBQR4O (ORCPT ); Wed, 17 Feb 2016 12:56:14 -0500 Received: from mail-yw0-f171.google.com ([209.85.161.171]:33537 "EHLO mail-yw0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030315AbcBQR4N (ORCPT ); Wed, 17 Feb 2016 12:56:13 -0500 Received: by mail-yw0-f171.google.com with SMTP id u200so19505152ywf.0 for ; Wed, 17 Feb 2016 09:56:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=omnibond-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=Rhdt+mJ2oRVnvtw5zX9GYHB0fZZ/vbG9JaGl1dCJXZw=; b=WIEGVLlMkC/zFdnBqBWIcrd1hhGZv4fIcUZYFl6z/2bTip007bv03a+iNeRXGXgTHq ewHCoAh/Rdd/KlUOogbNOhuO9CGqcQY+GLNLbQyjTSiVAUCQfFDejS4vDOJPVWvk/aQm cDm4GHMqr/vAe0vuTIiGZenQFncU81EdTQQmQbuwO/fRcl14pR4CzIyO/kEOTGtjhMvK 1SAKP5a3VAwzbvFUbWGN1bgDhOx18bGeijd/4PFi278Y5KKPQ8uCcKf0WWLnMGWPIDHO CDc/Us93SDao6jPlvfLmSfEv9Wc3HZfAVYKXybUf1C8suepWp2w+gcyy2cnptnL0QmAq eZVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Rhdt+mJ2oRVnvtw5zX9GYHB0fZZ/vbG9JaGl1dCJXZw=; b=gqDT61S9FafbjghtfwBkvHlgA0RloUZhv7+Aa4nVIKdJQ0jo8xNUCv0+qFeBoNqkSI Zpjx3uuaSZgDl5LJDNnU2lLmKymFIv2MMKitG1WGnjRGr/LS1iV53O4xycplc/rzzZqP VCSKnvInnlO1+MOnrFHyEudNw5ReCFHncFoJl4rGoe/+MPC5i8u5JfQwSVQxZ7HFfB5b KGbAbVFU3ocsN6u4IdftQf0ZlNycaAuyTaHcGE1c0oELryGAOjZyHpyU14l1jz9lrnVY Md4AuCnoEfG319hvt9xWIQhCZuYeUNsdR/TAF7r09oJASYxE3Kol3aakmXxy4KCV4lFb JgUg== X-Gm-Message-State: AG10YOSCwbd3FgjH6Aj3JLwVrsOM9kUlHs0hMIoeoacEC2c5tN6wBhrXyJB1RW9PZivchQ== X-Received: by 10.13.250.193 with SMTP id k184mr1617051ywf.163.1455731772637; Wed, 17 Feb 2016 09:56:12 -0800 (PST) Received: from marbranpc.clemson.edu.edu ([130.127.148.139]) by smtp.gmail.com with ESMTPSA id v63sm1534389ywf.40.2016.02.17.09.56.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Feb 2016 09:56:12 -0800 (PST) From: Martin Brandenburg To: hubcap@omnibond.com Cc: Martin Brandenburg , linux-fsdevel@vger.kernel.org Subject: [PATCH] orangefs: free readdir buffer index before the dir_emit loop Date: Wed, 17 Feb 2016 12:55:42 -0500 Message-Id: <1455731742-14789-1-git-send-email-martin@omnibond.com> X-Mailer: git-send-email 1.8.3.1 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We only need it while the service operation is actually in progress since it is only used to co-ordinate the client-core's memory use. The kernel allocates its own space. Also clean up some comments which mislead the reader into thinking the readdir buffers are shared memory. Signed-off-by: Martin Brandenburg --- fs/orangefs/dir.c | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/fs/orangefs/dir.c b/fs/orangefs/dir.c index c9b8d0c..43e3aeb 100644 --- a/fs/orangefs/dir.c +++ b/fs/orangefs/dir.c @@ -9,7 +9,6 @@ #include "orangefs-bufmap.h" struct readdir_handle_s { - int buffer_index; struct orangefs_readdir_response_s readdir_response; void *dents_buf; }; @@ -143,7 +142,7 @@ out: } static long readdir_handle_ctor(struct readdir_handle_s *rhandle, void *buf, - size_t size, int buffer_index) + size_t size) { long ret; @@ -152,17 +151,10 @@ static long readdir_handle_ctor(struct readdir_handle_s *rhandle, void *buf, ("Invalid NULL buffer specified in readdir_handle_ctor\n"); return -ENOMEM; } - if (buffer_index < 0) { - gossip_err - ("Invalid buffer index specified in readdir_handle_ctor\n"); - return -EINVAL; - } - rhandle->buffer_index = buffer_index; rhandle->dents_buf = buf; ret = decode_dirents(buf, size, &rhandle->readdir_response); if (ret < 0) { gossip_err("Could not decode readdir from buffer %ld\n", ret); - rhandle->buffer_index = -1; gossip_debug(GOSSIP_DIR_DEBUG, "vfree %p\n", buf); vfree(buf); rhandle->dents_buf = NULL; @@ -179,10 +171,6 @@ static void readdir_handle_dtor(struct readdir_handle_s *rhandle) kfree(rhandle->readdir_response.dirent_array); rhandle->readdir_response.dirent_array = NULL; - if (rhandle->buffer_index >= 0) { - orangefs_readdir_index_put(rhandle->buffer_index); - rhandle->buffer_index = -1; - } if (rhandle->dents_buf) { gossip_debug(GOSSIP_DIR_DEBUG, "vfree %p\n", rhandle->dents_buf); @@ -236,7 +224,6 @@ static int orangefs_readdir(struct file *file, struct dir_context *ctx) "orangefs_readdir called on %s (pos=%llu)\n", dentry->d_name.name, llu(pos)); - rhandle.buffer_index = -1; rhandle.dents_buf = NULL; memset(&rhandle.readdir_response, 0, sizeof(rhandle.readdir_response)); @@ -244,6 +231,10 @@ static int orangefs_readdir(struct file *file, struct dir_context *ctx) if (!new_op) return -ENOMEM; + /* + * Only the indices are shared. No memory is actually shared, but the + * mechanism is used. + */ new_op->uses_shared_memory = 1; new_op->upcall.req.readdir.refn = orangefs_inode->refn; new_op->upcall.req.readdir.max_dirent_count = @@ -274,23 +265,19 @@ get_new_buffer_index: new_op->downcall.status, ret); + orangefs_readdir_index_put(buffer_index); + if (ret == -EAGAIN && op_state_purged(new_op)) { - /* - * readdir shared memory aread has been wiped due to - * pvfs2-client-core restarting, so we must get a new - * index into the shared memory. - */ + /* Client-core indices are invalid after it restarted. */ gossip_debug(GOSSIP_DIR_DEBUG, "%s: Getting new buffer_index for retry of readdir..\n", __func__); - orangefs_readdir_index_put(buffer_index); goto get_new_buffer_index; } if (ret == -EIO && op_state_purged(new_op)) { gossip_err("%s: Client is down. Aborting readdir call.\n", __func__); - orangefs_readdir_index_put(buffer_index); goto out_free_op; } @@ -298,7 +285,6 @@ get_new_buffer_index: gossip_debug(GOSSIP_DIR_DEBUG, "Readdir request failed. Status:%d\n", new_op->downcall.status); - orangefs_readdir_index_put(buffer_index); if (ret >= 0) ret = new_op->downcall.status; goto out_free_op; @@ -307,13 +293,11 @@ get_new_buffer_index: bytes_decoded = readdir_handle_ctor(&rhandle, new_op->downcall.trailer_buf, - new_op->downcall.trailer_size, - buffer_index); + new_op->downcall.trailer_size); if (bytes_decoded < 0) { gossip_err("orangefs_readdir: Could not decode trailer buffer into a readdir response %d\n", ret); ret = bytes_decoded; - orangefs_readdir_index_put(buffer_index); goto out_free_op; }