Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp1007491imm; Thu, 5 Jul 2018 12:53:09 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfJLUOtzPE1plRvb6N10mVakCNYno2a5Pc6Pktc437X4AESQUJuFOzFNUbWt3KRWEW/7ZDd X-Received: by 2002:a63:d15:: with SMTP id c21-v6mr6947334pgl.322.1530820389176; Thu, 05 Jul 2018 12:53:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530820389; cv=none; d=google.com; s=arc-20160816; b=ZMAwN9b/aE+N/hkw+N7Vxxz5oyQXweT+frXAlnpcYC914GzsboRJzZ6BKdPylENT2r ZGotdhAQJBbrGI85rwzurnPDpDJeI3VFZT5JOe9JeRcwRplsGs2WRKXUT90cHo9IfchQ qE1zbNsAaBoVBxOoem58xiuw9Y+GMkcwm0bXAx3CF5lvkzOtzkouLqjS1+MPxLXXmSaC eYQUJ5/FuuyKuL2FB+sKHilG8riPu1J2S5/50++Zen/rwokI114Fn7TM4O2wphLMIW2Y 9kUwWzUDyf/9Du9ZJ4TcqiJvGONj2hQ0UnKOBGBmKbn8oE1SCELIvB3tFxusJGl3nnY1 WTCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=ZQhz6+odNFNPJ7fo3CIkIRrMCRrU7IxUcR5cgf4FM54=; b=TqxR9r+Nec+0r1PJI0iiHSbct51z7BtL+5x1Z8qhn6qCyvSiZMbEW1w720PLa/fatH CgsBwob8Sm9Hhi14TVr6GUgacx750ZznImNotCGd/3rYl24y48YNWDQqeJQUAZjC7MmQ afAVK1e+9iYvf0p6tqbtzxExoc935Y9IGrUsEN9CSKUiaK3gbVQepFwDiJ8a/IRU9Suw LydSnwJ2bGN6mP7VQKrtvx8ltRh6KBhHidwGEVY7KGCM8+iaDUaD8H48aJFCqbV7OIAJ oLpOAdmwgm+K1/79YzEXGRmHgItlcb4/Oi0QkIHt2rWC612YR7xlPc6lsVGHb8niSryC cjwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b="E6qQ/USs"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e20-v6si7387120pfm.177.2018.07.05.12.52.54; Thu, 05 Jul 2018 12:53:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b="E6qQ/USs"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754158AbeGETwK (ORCPT + 99 others); Thu, 5 Jul 2018 15:52:10 -0400 Received: from mail-oi0-f68.google.com ([209.85.218.68]:40805 "EHLO mail-oi0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753828AbeGETwI (ORCPT ); Thu, 5 Jul 2018 15:52:08 -0400 Received: by mail-oi0-f68.google.com with SMTP id w126-v6so19148035oie.7 for ; Thu, 05 Jul 2018 12:52:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=ZQhz6+odNFNPJ7fo3CIkIRrMCRrU7IxUcR5cgf4FM54=; b=E6qQ/USsNTmiY2wAMr6z+k0Vgv7HjFxEmfZq/xz+eMuN67FHUj1O9vcKi0K/Ln11ZG ndrqHvSuwdorOvtWDwm7zQKvI52mFpgIl6ddlea23wWxsUlow49JhipsmaO/NU7efW2j 9f1AuJ32eDPBtgaebakoTXZnDetZVpBFXwk71FbHyKpUc/0LrODju3K1e+Hc9v/GfqLe zKpctXQ21IzTqZrfh7YBW6wbS+Qh8N3YOX/TCj1STP+UkM6HHctxDCO0N5P1WOISwzsV afTpukBVAkxRUUDTIcKcnUvVibyM8pXATpHr/O45BGdp1WkD/Ux9h6RvKQlikkGGv2LP /InQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=ZQhz6+odNFNPJ7fo3CIkIRrMCRrU7IxUcR5cgf4FM54=; b=EBNL72qCOuV/XP1tQMGbu8Tbv1K3jvfS/W5r40B6Py2QNRds8bTDeclegf5ozXSfVP 4TRZZiWS0l0M7VSVGBYUW5HOImMuU8gYbcR47DOET3Gc1I8dxjFZvFYrTiV5SUwXJoyD QIMn4Crw0NZeTCgEcGDf9KoVjvPGEdMyUYIYSsg77du7ApoHVtVx+nDWeGzl4nu7dl+E jTTZIYfP6ICcOMLQNvaHA+PhFLAPi4lC+W6ap189J7paN567xnS/g6LWA4c2HdCOAWfF DPifRUc3CFI2gMwlacdA2cNm1vuonlvyaSWaqpo3q2JAcquGeK/GYLG0pmzffHouCk9Q k2Tg== X-Gm-Message-State: APt69E33PjKzGcxTQT1JXAAP5jWx/vDo2FYIzXUo4ZB17nkSOMn1oGSO wNoYHapS+rIGmNM++qza0IWWdJQcWUUVaaub70gyjw== X-Received: by 2002:aca:a993:: with SMTP id s141-v6mr8614481oie.72.1530820328425; Thu, 05 Jul 2018 12:52:08 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:3495:0:0:0:0:0 with HTTP; Thu, 5 Jul 2018 12:52:07 -0700 (PDT) In-Reply-To: <20180705194936.GA28447@bombadil.infradead.org> References: <153077334130.40830.2714147692560185329.stgit@dwillia2-desk3.amr.corp.intel.com> <153077341292.40830.11333232703318633087.stgit@dwillia2-desk3.amr.corp.intel.com> <20180705082931.echvdqipgvwhghf2@linux-x5ow.site> <20180705194936.GA28447@bombadil.infradead.org> From: Dan Williams Date: Thu, 5 Jul 2018 12:52:07 -0700 Message-ID: Subject: Re: [PATCH 13/13] libnvdimm, namespace: Publish page structure init state / control To: Matthew Wilcox Cc: Johannes Thumshirn , Andrew Morton , Ross Zwisler , Vishal Verma , Dave Jiang , Jeff Moyer , Christoph Hellwig , linux-nvdimm , Linux MM , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 5, 2018 at 12:49 PM, Matthew Wilcox wrote: > On Thu, Jul 05, 2018 at 07:46:05AM -0700, Dan Williams wrote: >> On Thu, Jul 5, 2018 at 1:29 AM, Johannes Thumshirn wrote: >> > On Wed, Jul 04, 2018 at 11:50:13PM -0700, Dan Williams wrote: >> >> +static ssize_t memmap_state_store(struct device *dev, >> >> + struct device_attribute *attr, const char *buf, size_t len) >> >> +{ >> >> + int i; >> >> + struct nd_pfn *nd_pfn = to_nd_pfn_safe(dev); >> >> + struct memmap_async_state *async = &nd_pfn->async; >> >> + >> >> + if (strcmp(buf, "sync") == 0) >> >> + /* pass */; >> >> + else if (strcmp(buf, "sync\n") == 0) >> >> + /* pass */; >> >> + else >> >> + return -EINVAL; >> > >> > Hmm what about: >> > >> > if (strncmp(buf, "sync", 4)) >> > return -EINVAL; >> > >> > This collapses 6 lines into 4. >> >> ...but that also allows 'echo "syncAndThenSomeGarbage" > >> /sys/.../memmap_state' to succeed. > > if (strncmp(buf, "sync", 4)) > return -EINVAL; > if (buf[4] != '\0' && buf[4] != '\n') > return -EINVAL; > Not sure that's a win either, I'd rather just: + if (strcmp(buf, "sync") == 0 || strcmp(buf, "sync\n") == 0) + /* pass */; + else + return -EINVAL; If we're trying to save those 2 lines.