From patchwork Wed Jun 4 21:01:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Weston Andros Adamson X-Patchwork-Id: 4296881 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B212F9F1D6 for ; Wed, 4 Jun 2014 21:02:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7814C201F7 for ; Wed, 4 Jun 2014 21:02:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B3A2820254 for ; Wed, 4 Jun 2014 21:02:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752073AbaFDVCc (ORCPT ); Wed, 4 Jun 2014 17:02:32 -0400 Received: from mail-ig0-f176.google.com ([209.85.213.176]:51171 "EHLO mail-ig0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752051AbaFDVCX (ORCPT ); Wed, 4 Jun 2014 17:02:23 -0400 Received: by mail-ig0-f176.google.com with SMTP id a13so2456239igq.3 for ; Wed, 04 Jun 2014 14:02:23 -0700 (PDT) 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:in-reply-to :references; bh=iU7THJ5WFuDLLcki/JLUBfU9tqDWGd3ZlYdUn4h/yQk=; b=b9tIo5FGCGF3GWlAAB1jysr5WdFdJfupsyTB9jwt3xzJb7JltS8gRnLDHsXj5wj47a x2Ypc5jsgtG7ScMmtX+2p5oNf/++7j4OChsE0QXUjBZdPYUU0bgru1R6XZGC9BdS28KZ PPs03bHvS8c5Rqj2C/Rq0wEUhE9mwI6UL+s7uSK6Nhddw6+2RmL6Jddrv2OOt+RwyykT nTCBjVdRRNAqASMhke6VNTsSuILUKIx8nK98YLFRWxSANO+dsBqtN5nHdOeXE+he8Qkf JJ3ec1W4E+SJTyM8EZH7eIJQXzRvkax9zYY8L4ranV7CZRxbe3wRXBBxd+r/sw+x8aAm 06Qw== X-Gm-Message-State: ALoCoQmAza7/dSc1iu4oSIsTsLGtKx2+uCIwKSO084UOTsicn9JOrsGuq7tFCEywKbg10viPShZA X-Received: by 10.50.23.105 with SMTP id l9mr11452188igf.46.1401915742864; Wed, 04 Jun 2014 14:02:22 -0700 (PDT) Received: from gavrio-wifi.robotsandstuff.fake (c-98-209-19-144.hsd1.mi.comcast.net. [98.209.19.144]) by mx.google.com with ESMTPSA id qh3sm47684584igb.17.2014.06.04.14.02.21 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 04 Jun 2014 14:02:22 -0700 (PDT) From: Weston Andros Adamson To: bfields@fieldses.org Cc: linux-nfs@vger.kernel.org, Weston Andros Adamson Subject: [PATCH pynfs 07/17] 4.1 server: add -v flag & silence random output Date: Wed, 4 Jun 2014 17:01:55 -0400 Message-Id: <1401915726-29092-8-git-send-email-dros@primarydata.com> X-Mailer: git-send-email 1.8.5.2 (Apple Git-48) In-Reply-To: <1401915726-29092-1-git-send-email-dros@primarydata.com> References: <1401915726-29092-1-git-send-email-dros@primarydata.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 By default the nfs4server spews so much information to stdout/stderr that it's almost useless. Add the -v flag (aka --verbose) to enable the old output. Also remove some random prints and change some to log.info(). Signed-off-by: Weston Andros Adamson --- nfs4.1/dataserver.py | 3 +-- nfs4.1/fs.py | 4 ---- nfs4.1/nfs4client.py | 11 ++-------- nfs4.1/nfs4server.py | 61 +++++++++++++++++++++++----------------------------- nfs4.1/nfs4state.py | 1 - 5 files changed, 30 insertions(+), 50 deletions(-) diff --git a/nfs4.1/dataserver.py b/nfs4.1/dataserver.py index 7f5f72c..d697631 100644 --- a/nfs4.1/dataserver.py +++ b/nfs4.1/dataserver.py @@ -181,7 +181,7 @@ class DSDevice(object): line = line.strip() if not line or line.startswith('#'): continue - print "Analyzing: %r" % line + log.info("Analyzing: %r" % line) try: server_list, path = nfs4lib.parse_nfs_url(line) except: @@ -191,7 +191,6 @@ class DSDevice(object): # for now, just use the last path for local connections server, port = server_list[-1] server_list = server_list[:-1] - print server, port, path try: log.info("Adding dataserver ip:%s port:%s path:%s" % (server, port, '/'.join(path))) diff --git a/nfs4.1/fs.py b/nfs4.1/fs.py index 3d63ce5..6ef283b 100644 --- a/nfs4.1/fs.py +++ b/nfs4.1/fs.py @@ -13,7 +13,6 @@ from xdrdef.nfs4_pack import NFS4Packer log_o = logging.getLogger("fs.obj") log_fs = logging.getLogger("fs") logging.addLevelName(5, "FUNCT") -log_fs.setLevel(20) class MetaData(object): """Contains everything that needs to be stored @@ -743,7 +742,6 @@ class ConfigObj(FSObject): line = line.strip() if line and not line.startswith("#"): lines.append(line) - print lines if len(lines) != 1: self._reset() return @@ -1154,7 +1152,6 @@ class LayoutFSObj(FSObject): disk_offset, e.state)) block_layout = pnfs_block_layout4(elist) - print block_layout p = block.Packer() p.pack_pnfs_block_layout4(block_layout) ## if self.id <= 4: @@ -1194,7 +1191,6 @@ class LayoutFSObj(FSObject): log_o.exception("Problem decoding opaque") raise NFS4Error(NFS4ERR_BADLAYOUT, tag="Error decoding opaque") upd_list = update.blu_commit_list - print upd_list # Error check for e in upd_list: if e.bex_state != block.PNFS_BLOCK_READWRITE_DATA: diff --git a/nfs4.1/nfs4client.py b/nfs4.1/nfs4client.py index 0904577..e504362 100644 --- a/nfs4.1/nfs4client.py +++ b/nfs4.1/nfs4client.py @@ -19,9 +19,7 @@ import logging logging.basicConfig(level=logging.INFO, format="%(levelname)-7s:%(name)s:%(message)s") log_cb = logging.getLogger("nfs.client.cb") -log_cb.setLevel(logging.DEBUG) -SHOW_TRAFFIC = True # Debugging aid, prints out client traffic class NFS4Client(rpc.Client, rpc.Server): def __init__(self, host='localhost', port=2049, minorversion=1, ctrl_proc=16): rpc.Client.__init__(self, 100003, 4) @@ -76,9 +74,7 @@ class NFS4Client(rpc.Client, rpc.Server): pipe = self.c1 p = packer(check_enum=checks, check_array=checks) c4 = COMPOUND4args(tag, version, ops) - if SHOW_TRAFFIC: - print - print c4 + log_cb.info("compound args = %r" % (c4,)) p.pack_COMPOUND4args(c4) return self.send_call(pipe, 1, p.get_buffer(), credinfo) @@ -86,19 +82,16 @@ class NFS4Client(rpc.Client, rpc.Server): xid = self.compound_async(*args, **kwargs) pipe = kwargs.get("pipe", None) res = self.listen(xid, pipe=pipe) - if SHOW_TRAFFIC: - print res + log_cb.info("compound result = %r" % (res,)) return res def listen(self, xid, pipe=None, timeout=10.0): if pipe is None: pipe = self.c1 header, data = pipe.listen(xid, timeout) - #print "HEADER", header if data: p = nfs4lib.FancyNFS4Unpacker(data) data = p.unpack_COMPOUND4res() - #print "DATA", repr(data) return data def handle_0(self, data, cred): diff --git a/nfs4.1/nfs4server.py b/nfs4.1/nfs4server.py index 75276f9..67adbf1 100755 --- a/nfs4.1/nfs4server.py +++ b/nfs4.1/nfs4server.py @@ -21,14 +21,11 @@ from nfs4commoncode import CompoundState, encode_status, encode_status_by_name from fs import RootFS, ConfigFS from config import ServerConfig, ServerPerClientConfig, OpsConfigServer, Actions -logging.basicConfig(level=logging.INFO, +logging.basicConfig(level=logging.WARN, format="%(levelname)-7s:%(name)s:%(message)s") log_41 = logging.getLogger("nfs.server") -log_41.setLevel(logging.DEBUG) -log_41.setLevel(9) log_cfg = logging.getLogger("nfs.server.opconfig") -log_cfg.setLevel(20) ################################################## # Set various global constants and magic numbers # @@ -116,9 +113,6 @@ class Recording(object): def add(self, call, reply): """Add call and reply strings to records""" if self.on: - print "Adding" - print repr(call) - print repr(reply) self.queue.appendleft((call, reply)) def set_stamp(self, stamp): @@ -269,13 +263,13 @@ class VerboseDict(dict): self.config = config def __setitem__(self, key, value): - if 0 or self.config.debug_state: - print "+++ Adding client.state[%r]" % key + if self.config.debug_state: + log_41.info("+++ Adding client.state[%r]" % key) dict.__setitem__(self, key, value) def __delitem__(self, key): - if 0 or self.config.debug_state: - print "+++ Removing client.state[%r]" % key + if self.config.debug_state: + log_41.info("+++ Removing client.state[%r]" % key) dict.__delitem__(self, key) class ClientRecord(object): @@ -526,6 +520,13 @@ class NFS4Server(rpc.Server): port = kwargs.pop("port", NFS4_PORT) self.is_mds = kwargs.pop("is_mds", False) self.is_ds = kwargs.pop("is_ds", False) + + self.verbose = kwargs.pop('verbose', False) + if self.verbose: + log_41.setLevel(logging.DEBUG) # XXX redundant? + log_41.setLevel(9) + log_cfg.setLevel(20) + rpc.Server.__init__(self, prog=NFS4_PROGRAM, versions=[4], port=port, **kwargs) self.root = RootFS().root # Root of exported filesystem tree @@ -552,7 +553,7 @@ class NFS4Server(rpc.Server): rpc.Server.start(self) except KeyboardInterrupt: # Put user into console where can look at state of server - if not self.config.catch_ctrlc: + if not self.config.catch_ctrlc or not self.verbose: raise import code import readline @@ -1330,9 +1331,9 @@ class NFS4Server(rpc.Server): sid, deleg, flags = self.open_file(existing, arg.owner, arg.share_access, arg.share_deny) env.set_cfh(existing, sid) - if 0 or env.session.client.config.debug_state: - print "+++ client(id=%i).state =" % env.session.client.clientid - print env.session.client.state + if env.session.client.config.debug_state: + log_41.info("+++ client(id=%i).state = %r" % + (env.session.client.clientid, env.session.client.state)) res = OPEN4resok(sid, cinfo, flags, bitmask, deleg) return encode_status(NFS4_OK, res) @@ -1452,14 +1453,13 @@ class NFS4Server(rpc.Server): ret_dict = {} info = nfs4lib.attr_info for attr in attrs: - print "handling fattr4_%s : " % nfs4lib.attr_name(attr), if attr not in info: # Ignore unknown attributes - print "Unknown" + log_41.info("Skipping unknown attr: %s" % (attr,)) continue if not info[attr].readable: # XXX How deal with write-only attrs? - print "Write only" + log_41.info("Skipping write only attr: %s" % (attr,)) continue # Attributes hide in different places, call the place 'base' if info[attr].from_fs: @@ -1471,24 +1471,14 @@ class NFS4Server(rpc.Server): name = "fattr4_%s" % nfs4lib.attr_name(attr) if hasattr(base, name) and (obj.fs.fattr4_supported_attrs & 1<