From patchwork Sat Oct 27 03:06:35 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Rees X-Patchwork-Id: 1654531 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 5EC783FD4E for ; Sat, 27 Oct 2012 03:06:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934356Ab2J0DGn (ORCPT ); Fri, 26 Oct 2012 23:06:43 -0400 Received: from mout.perfora.net ([74.208.4.195]:60724 "EHLO mout.perfora.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933342Ab2J0DGm (ORCPT ); Fri, 26 Oct 2012 23:06:42 -0400 Received: from rees.org (107-0-158-199-ip-static.hfc.comcastbusiness.net [107.0.158.199]) by mrelay.perfora.net (node=mrus4) with ESMTP (Nemesis) id 0LtJIp-1TGDGG2vTH-012g7I; Fri, 26 Oct 2012 23:06:41 -0400 From: Jim Rees To: linux-nfs@vger.kernel.org Subject: [PATCH] NFS: Reduce stack use in encode_exchange_id() Date: Fri, 26 Oct 2012 23:06:35 -0400 Message-Id: <1351307195-4197-1-git-send-email-rees@umich.edu> X-Mailer: git-send-email 1.7.9.5 X-Provags-ID: V02:K0:gBW3b2rMB2vXDr12GSIcUTNujaaqI7whGsD8iKiCuJI W/3fT/+4npUhuMTaegrSKmDwPFBWFl3q1+lHczAUdaX5OjF5C7 awaM406R074Ynri0iDdDwkgzVNb9RfqP3IQm/Zqmhb3jl0QrGi hfmvUoNusvG6AM1/yJK4mn8nwB9kRXAMrv4XeCCUSBIDQL4uOt f5Of1Tm9yWy2z76Ta7F50UUshDmlUAXrFG0FnrPWHJuxw2pC4h W/voe4E/ebyDSxltFiFQTeP8iyql+544+9BdOmzdBYdqRBN+8Z hAng/GDHmf/rfwqcinxJEnKa4VPpfusJEZao2ZB6ael1nmxdDg QgkDOMw64rHwvludjbFAUcTSpQjHweEHHmqs8QUhi Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org For comment only. I have not tested this. encode_exchange_id() uses more stack space than necessary, giving a compile time warning. Reduce the size of the static buffer for implementation name. Signed-off-by: Jim Rees --- fs/nfs/nfs4xdr.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index 8dba6bd..ccd1dde 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c @@ -1700,12 +1700,15 @@ static void encode_bind_conn_to_session(struct xdr_stream *xdr, *p = 0; /* use_conn_in_rdma_mode = False */ } +#define IMPL_NAME_LIMIT (sizeof(utsname()->sysname) + sizeof(utsname()->release) + \ + sizeof(utsname()->version) + sizeof(utsname()->machine) + 8) + static void encode_exchange_id(struct xdr_stream *xdr, struct nfs41_exchange_id_args *args, struct compound_hdr *hdr) { __be32 *p; - char impl_name[NFS4_OPAQUE_LIMIT]; + char impl_name[IMPL_NAME_LIMIT]; int len = 0; encode_op_hdr(xdr, OP_EXCHANGE_ID, decode_exchange_id_maxsz, hdr); @@ -1720,7 +1723,7 @@ static void encode_exchange_id(struct xdr_stream *xdr, if (send_implementation_id && sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) > 1 && sizeof(CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN) - <= NFS4_OPAQUE_LIMIT + 1) + <= sizeof(impl_name) + 1) len = snprintf(impl_name, sizeof(impl_name), "%s %s %s %s", utsname()->sysname, utsname()->release, utsname()->version, utsname()->machine);