From patchwork Fri Sep 7 11:55:25 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 1421821 Return-Path: X-Original-To: patchwork-v9fs-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by patchwork2.kernel.org (Postfix) with ESMTP id A26FBDF283 for ; Fri, 7 Sep 2012 12:20:50 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-2.v29.ch3.sourceforge.com) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1T9xXz-0000PL-9c; Fri, 07 Sep 2012 12:20:31 +0000 Received: from sog-mx-3.v43.ch3.sourceforge.com ([172.29.43.193] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1T9xXy-0000PF-Hn for v9fs-developer@lists.sourceforge.net; Fri, 07 Sep 2012 12:20:30 +0000 Received-SPF: softfail (sog-mx-3.v43.ch3.sourceforge.com: transitioning domain of poochiereds.net does not designate 209.85.212.47 as permitted sender) client-ip=209.85.212.47; envelope-from=jlayton@poochiereds.net; helo=mail-vb0-f47.google.com; Received: from mail-vb0-f47.google.com ([209.85.212.47]) by sog-mx-3.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1T9xXw-0003u9-A2 for v9fs-developer@lists.sourceforge.net; Fri, 07 Sep 2012 12:20:30 +0000 Received: by vbbfr13 with SMTP id fr13so3571750vbb.34 for ; Fri, 07 Sep 2012 05:20:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=1qfKqdjpezLfpgT4hakY7Bx3qgftmxh1iNT79hFBiVg=; b=h0+50ss2lYlavB2sSGj8GZWg0PtoSphtaEnF6A7Ex26Sy+9l5couh9CK6zwG8dJInT uXzgyYsQVHHD9iR1UYst2wSyfl3fPHq+RY2JrdiO3O1y+ERHs/jLRrdgZmYWSj6JwPMi t/d+ZFg1A862aZnrGqeicRiYfQ2L4b11XQI2Hyio47XA8CZZl7byHAx33ab3jfl0LqAj 2UfNfuIPYJBSrCwp6UM1z1YzbR9bXOk/hBNVl6ugE7yvMVG7A7CJT9zqZqISUy6jtQ9o vJGBg3FzoksNghsDaixbFsV4ZZKxhnIrGv9FQM5IlcSYKC2a3cYNmSqNChNOZILn4k7l hkHQ== Received: by 10.52.32.39 with SMTP id f7mr5485716vdi.120.1347018931860; Fri, 07 Sep 2012 04:55:31 -0700 (PDT) Received: from salusa.poochiereds.net (cpe-069-134-145-027.nc.res.rr.com. [69.134.145.27]) by mx.google.com with ESMTPS id n15sm3362853vdj.1.2012.09.07.04.55.30 (version=SSLv3 cipher=OTHER); Fri, 07 Sep 2012 04:55:31 -0700 (PDT) From: Jeff Layton To: v9fs-developer@lists.sourceforge.net Date: Fri, 7 Sep 2012 07:55:25 -0400 Message-Id: <1347018925-18582-1-git-send-email-jlayton@redhat.com> X-Mailer: git-send-email 1.7.11.4 X-Gm-Message-State: ALoCoQkQCW8dl+9yd1DsOA2HfbIhc5BC5dEnUIRtl7XFo8njElXtdr3uytx274Yh7SHzHnQq/M6I X-Spam-Score: 1.0 (+) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) X-Headers-End: 1T9xXw-0003u9-A2 Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [V9fs-developer] [PATCH] 9p: don't use __getname/__putname for uname/aname X-BeenThere: v9fs-developer@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: v9fs-developer-bounces@lists.sourceforge.net These are generally very small strings. We don't need an entire 4k allocation for each. Instead, just free and reallocate them on an as-needed basis. Note: This patch is untested since I don't have a 9p server available at the moment. It's mainly something I noticed while doing some getname/putname cleanup work. Signed-off-by: Jeff Layton --- fs/9p/v9fs.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c index b85efa7..b20af74 100644 --- a/fs/9p/v9fs.c +++ b/fs/9p/v9fs.c @@ -184,10 +184,20 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts) v9ses->afid = option; break; case Opt_uname: - match_strlcpy(v9ses->uname, &args[0], PATH_MAX); + kfree(v9ses->uname); + v9ses->uname = match_strdup(&args[0]); + if (!v9ses->uname) { + ret = -ENOMEM; + goto free_and_return; + } break; case Opt_remotename: - match_strlcpy(v9ses->aname, &args[0], PATH_MAX); + kfree(v9ses->aname); + v9ses->aname = match_strdup(&args[0]); + if (!v9ses->aname) { + ret = -ENOMEM; + goto free_and_return; + } break; case Opt_nodevmap: v9ses->nodev = 1; @@ -287,21 +297,21 @@ struct p9_fid *v9fs_session_init(struct v9fs_session_info *v9ses, struct p9_fid *fid; int rc; - v9ses->uname = __getname(); + v9ses->uname = kstrdup(V9FS_DEFUSER, GFP_KERNEL); if (!v9ses->uname) return ERR_PTR(-ENOMEM); - v9ses->aname = __getname(); + v9ses->aname = kstrdup(V9FS_DEFANAME, GFP_KERNEL); if (!v9ses->aname) { - __putname(v9ses->uname); + kfree(v9ses->uname); return ERR_PTR(-ENOMEM); } init_rwsem(&v9ses->rename_sem); rc = bdi_setup_and_register(&v9ses->bdi, "9p", BDI_CAP_MAP_COPY); if (rc) { - __putname(v9ses->aname); - __putname(v9ses->uname); + kfree(v9ses->aname); + kfree(v9ses->uname); return ERR_PTR(rc); } @@ -309,8 +319,6 @@ struct p9_fid *v9fs_session_init(struct v9fs_session_info *v9ses, list_add(&v9ses->slist, &v9fs_sessionlist); spin_unlock(&v9fs_sessionlist_lock); - strcpy(v9ses->uname, V9FS_DEFUSER); - strcpy(v9ses->aname, V9FS_DEFANAME); v9ses->uid = ~0; v9ses->dfltuid = V9FS_DEFUID; v9ses->dfltgid = V9FS_DEFGID; @@ -412,8 +420,8 @@ void v9fs_session_close(struct v9fs_session_info *v9ses) kfree(v9ses->cachetag); } #endif - __putname(v9ses->uname); - __putname(v9ses->aname); + kfree(v9ses->uname); + kfree(v9ses->aname); bdi_destroy(&v9ses->bdi);