From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4498C43381 for ; Thu, 28 Feb 2019 17:01:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6A222218C3 for ; Thu, 28 Feb 2019 17:01:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="tpLYOK50" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732143AbfB1RBM (ORCPT ); Thu, 28 Feb 2019 12:01:12 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:42977 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731669AbfB1RBM (ORCPT ); Thu, 28 Feb 2019 12:01:12 -0500 Received: by mail-wr1-f65.google.com with SMTP id r5so22769407wrg.9 for ; Thu, 28 Feb 2019 09:01:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=+/cYWJcR+H+xrpX8l6VdMmAS4iARnMN8PGfykIwsVWU=; b=tpLYOK50M0WA7lG0IDtK5Fty0IuRRZm24hALVzwGsL4abLIx5pcdRhAzzqUvghduFv rXCpm35pL62s1iSEo638px/a7kRx1OG8oV4emUbmNhWgiJrnMbLCS2sYHtvx2HChhEP1 Dzz7xk9rpXMt6HjqiONDAKDKduNgPqt1joOctweDgcd7s4ntvlndt1ecu31MJhvhzGqQ NTO1FWBLV9k3jNc2yqgqXvHR11eLay6/qdw49SmQlsVDf5aVAEjB28xhiNLOqHOk4dyR WZXYVOMxw9Y8OjQpjFS6tqk2WapZTaoR8B9pAnBPLUWTZTAGbXke3JYPja+rSCgLfNbz bXCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=+/cYWJcR+H+xrpX8l6VdMmAS4iARnMN8PGfykIwsVWU=; b=LfB7QfS4XJgirr7RY9wK7XzDxdh/mUOC4C7ZnfpE5j/nvXRoMDQWMyPHTHX7RGsjNT ogjC8P9JsC+c0MZxchZ2PhCSqzp89q6UplBLrvYz0FAJAU9j4Eo5IbCtotvJ5eolTrZ3 syEQjyiB59F7KAmk3gqUKgtEon5YikHOLORvtc/24RhoT2CntdQTBSw3YDnDwAlxR3jt yX5yLF58tJ6rLeX6VogKFm34lIkreII8BN56S3HA7ORICiLCQWH66pB9Lez7YO/OCZyC g27h2rLvdZEFIk3VlJbXbFgVAVx9iLAWs5t59PRYgy68aQQxgK8pSm7WF8zRveyyy+tB +6vg== X-Gm-Message-State: APjAAAVE7RRA3N9Yu/DK71tucDMXt8TL0RnYkckns9YvJx54ZMEIJTWc Z+ViMuuhMbYDBmQqItJA9Eo= X-Google-Smtp-Source: APXvYqz5Ln+UD/mvktwW7zfWUmKsGGxdK+Bc8coisvF8YqXl4QbRFxVv3/+zgEy7nx3Gbt+ADKbjAg== X-Received: by 2002:adf:a147:: with SMTP id r7mr244643wrr.5.1551373270168; Thu, 28 Feb 2019 09:01:10 -0800 (PST) Received: from [10.0.0.5] ([207.232.55.62]) by smtp.gmail.com with ESMTPSA id m189sm5699037wmf.7.2019.02.28.09.01.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Feb 2019 09:01:09 -0800 (PST) Subject: Re: [RFC PATCH 04/17] zuf: zuf-core The ZTs To: "Schumaker, Anna" , "viro@zeniv.linux.org.uk" , "boaz@plexistor.com" , "linux-fsdevel@vger.kernel.org" References: <20190219115136.29952-1-boaz@plexistor.com> <20190219115136.29952-5-boaz@plexistor.com> <19e36daae0896060c3280637d7a3fcc9aa8cee35.camel@netapp.com> Cc: "Manole, Sagi" , "swhiteho@redhat.com" , "amir73il@gmail.com" , "rwheeler@redhat.com" , "mszeredi@redhat.com" , "Golander, Amit" , "jmoyer@redhat.com" From: Boaz Harrosh Message-ID: <0d59f02e-f9ed-5d86-09ec-25f2421e3f7c@gmail.com> Date: Thu, 28 Feb 2019 19:01:07 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <19e36daae0896060c3280637d7a3fcc9aa8cee35.camel@netapp.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On 26/02/19 20:34, Schumaker, Anna wrote: > On Tue, 2019-02-19 at 13:51 +0200, Boaz harrosh wrote: <> >> zuf-core established the communication channels with the ZUS >> User Mode Server. >> >> In this patch we have the core communication mechanics. >> Which is the Novelty of this project. >> (See previous submitted documentation for more info) >> >> Users will come later in the patchset >> <> >> +static inline int relay_fss_wait(struct relay *relay) >> +{ >> + int err; >> + >> + relay->fss_waiting = true; >> + relay->fss_wakeup = false; >> + err = wait_event_interruptible(relay->fss_wq, relay->fss_wakeup); >> + >> + return err; > > Could you just do: "return wait_event_interruptible()" directly, instead of > using the err variable? > Totally there used to be a dbg_print here there for the reminder of that time Will change ... >> +} >> + <> >> +static struct zufc_thread *_zt_from_cpu(struct zuf_root_info *zri, >> + int cpu, uint chan) >> +{ >> + return per_cpu_ptr(zri->_ztp->_all_zt[chan], cpu); >> +} >> + >> +static int _zt_from_f(struct file *filp, int cpu, uint chan, >> + struct zufc_thread **ztp) >> +{ >> + *ztp = _zt_from_cpu(ZRI(filp->f_inode->i_sb), cpu, chan); >> + if (unlikely(!*ztp)) >> + return -ERANGE; >> + return 0; > > I'm curious if there is a reason you did it this way instead of making use of > the ERR_PTR() macro to return ztp directly? > For one now looking at it I hate the name its wrong. I will change that. It is done like that because it used to be used in many places and I did not want every place to have its print and invent its own error code. But now it has a single user I might just fold it into its only user. All other places must use _zt_from_f_private. Cool I'll kill it. >> +} >> + <> Thanks, will fix Boaz >> +static int _zu_init(struct file *file, void *parg) >> +{ >> + struct zufc_thread *zt; >> + int cpu = smp_processor_id(); >> + struct zufs_ioc_init zi_init; >> + int err; >> + >> + err = copy_from_user(&zi_init, parg, sizeof(zi_init)); >> + if (unlikely(err)) { >> + zuf_err("=>%d\n", err); >> + return err; >> + } >> + if (unlikely(zi_init.channel_no >= ZUFS_MAX_ZT_CHANNELS)) { >> + zuf_err("[%d] channel_no=%d\n", cpu, zi_init.channel_no); >> + return -EINVAL; >> + } >> + >> + zuf_dbg_zus("[%d] aff=0x%lx channel=%d\n", >> + cpu, zi_init.affinity, zi_init.channel_no); >> + >> + zi_init.hdr.err = _zt_from_f(file, cpu, zi_init.channel_no, &zt); >> + if (unlikely(zi_init.hdr.err)) { >> + zuf_err("=>%d\n", err); >> + goto out; >> + } >> + >> + if (unlikely(zt->hdr.file)) { >> + zi_init.hdr.err = -EINVAL; >> + zuf_err("[%d] !!! thread already set\n", cpu); >> + goto out; >> + } >> + >> + relay_init(&zt->relay); >> + zt->hdr.type = zlfs_e_zt; >> + zt->hdr.file = file; >> + zt->no = cpu; >> + zt->chan = zi_init.channel_no; >> + >> + zt->max_zt_command = zi_init.max_command; >> + zt->opt_buff = vmalloc(zi_init.max_command); >> + if (unlikely(!zt->opt_buff)) { >> + zi_init.hdr.err = -ENOMEM; >> + goto out; >> + } >> + _fill_buff(zt->opt_buff, zi_init.max_command / sizeof(ulong)); >> + >> + file->private_data = &zt->hdr; >> +out: >> + err = copy_to_user(parg, &zi_init, sizeof(zi_init)); >> + if (err) >> + zuf_err("=>%d\n", err); >> + return err; >> +} >> + >> +struct zufc_thread *_zt_from_f_private(struct file *file) >> +{ >> + struct zuf_special_file *zsf = file->private_data; >> + >> + WARN_ON(zsf->type != zlfs_e_zt); >> + return container_of(zsf, struct zufc_thread, hdr); >> +} >> + >> +/* Caller checks that file->private_data != NULL */ >> +static void zufc_zt_release(struct file *file) >> +{ >> + struct zufc_thread *zt = _zt_from_f_private(file); >> + <>