From patchwork Thu Jun 5 13:55:34 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: 4305551 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 C5E609F26E for ; Thu, 5 Jun 2014 13:56:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 815742011D for ; Thu, 5 Jun 2014 13:56:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6CDC92018B for ; Thu, 5 Jun 2014 13:56:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751706AbaFENz5 (ORCPT ); Thu, 5 Jun 2014 09:55:57 -0400 Received: from mail-ig0-f174.google.com ([209.85.213.174]:61652 "EHLO mail-ig0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751664AbaFENzz (ORCPT ); Thu, 5 Jun 2014 09:55:55 -0400 Received: by mail-ig0-f174.google.com with SMTP id h3so7583175igd.1 for ; Thu, 05 Jun 2014 06:55:54 -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=5TJW6szeP6NFv6QUl0S6Nxa7wKFqm+NqUfLpzpYwF5s=; b=C/WVWwUkV19Lp8JF/d/M//6yPbnBcJpkFj3RrRRWHdS6uMWyh0el3H0jm/dqVpL1nu O+Zv31SXdUnSFk6/sStcS7mgw4xNgFdjEEfuVm857K1QIeiBZvFSRq3GCmf4az++Q2ue 1F3bm/N1Hm2YDXb3ORAdZ/C6EPhct2w9lw9TceZz0kQ052CaQUs58d5wVpC80fde5w4K wqUwt6q+N8d3q0jCzx4LP9nJR92p6ioPyXo1EKvyz0UW183l5PRxqEDT2tdS0vreR6/f XzT/Pk2P6pn/m0Y5IDoYj4DUaLXAq0RDoT3MGCCi4B2UfFMori3XOVcjfJMqLhh9MG8V gWiw== X-Gm-Message-State: ALoCoQmWQDUdxdI6KdRy636KmfKR9PAaZ9pBSgpFsL1TK3Mn3LTPyxOcxoaSMJRmpuR/Edh7T21d X-Received: by 10.50.92.42 with SMTP id cj10mr20458554igb.34.1401976554631; Thu, 05 Jun 2014 06:55:54 -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 c8sm30697482igx.8.2014.06.05.06.55.53 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 05 Jun 2014 06:55:54 -0700 (PDT) From: Weston Andros Adamson To: bfields@fieldses.org Cc: linux-nfs@vger.kernel.org, Weston Andros Adamson Subject: [PATCH pynfs v2 06/16] 4.1 server: add -v flag & silence random output Date: Thu, 5 Jun 2014 09:55:34 -0400 Message-Id: <1401976544-36374-7-git-send-email-dros@primarydata.com> X-Mailer: git-send-email 1.8.5.2 (Apple Git-48) In-Reply-To: <1401976544-36374-1-git-send-email-dros@primarydata.com> References: <1401976544-36374-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 acca210..c400d22 100644 --- a/nfs4.1/dataserver.py +++ b/nfs4.1/dataserver.py @@ -182,7 +182,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: @@ -192,7 +192,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 7a07ab7..0ba84bd 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 2ae99fe..a495d3c 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<