Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1487969imm; Mon, 3 Sep 2018 01:36:15 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbPap+up70MGz3lvN+1R4xL49amjQxWK5eIhm3Bsj4XoyUkcfeZJzycdcyC9yw8FxAnPTo9 X-Received: by 2002:a63:4386:: with SMTP id q128-v6mr24707149pga.353.1535963775713; Mon, 03 Sep 2018 01:36:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535963775; cv=none; d=google.com; s=arc-20160816; b=Dq5gCMh89CuC0bo8SpUtOJzngMoRysvn4QDiqLfGWUVbJ9Strm/4C7TYtwOh7rDnjw d6UMvZKWNhf4iIwIBYCnGn5YPFqY9EsrOTFE/4houSycEmLnKNy9caLBUGmIbX5ZxpsL 9rGEDGOthldXiCeHuttChhbPvWwl7gQTidrOj3WbNtZebaaaMSNdRgitY34pRafEXBK4 wKjZNq2d8hL2YU1bYA9ETUFxN9Wd4jV3PFc3lx3f7OmfowJGVX0R4JQTu7pSlxpU0GZZ BTD5L2AEOimWRKj/n8LejGAPdVZySuGC9V9W3F/CwtYBCjC+FGCVHnNv/B4EryzfAwFn X/hQ== 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 :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=qOnnW28q9L9jgWagZfM00l8k+/0G0cItbeqZVIVUPsE=; b=NwWSFXVOO2j8OIQW7yGqMR45EVLk7BWLHTRlQkTSVWMaK0NtGtUP6VHFPt6M4OPwkD ZGB2p/AwDPoRXiB6RcKNntwFd2xNv4WzfoTYWGJ3af8wzzkovzkH0M7ORPbAXD4ZxWNn yNZZafpy58mx6doAvzZUIsNUcJ2UQHpUKZAF0acYycEF+jlOb/PtYx/Q1mHGZRCPrO+6 L9MCkcoLz70cVcdssZkaQuL31km0qL8QKNuouMHTIV8qb95L8hEkMqnheadWvkHC5cck RXTXkCGLbJti8AdrO4cl2uHY3FG4K4kWmsk3URdTsIg7s+pacP6+VGLwYVFGJ0IHwn5V GPEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infinidat-com.20150623.gappssmtp.com header.s=20150623 header.b=UdihlNBm; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n5-v6si15922620plp.186.2018.09.03.01.36.00; Mon, 03 Sep 2018 01:36:15 -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=@infinidat-com.20150623.gappssmtp.com header.s=20150623 header.b=UdihlNBm; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727141AbeICMxy (ORCPT + 99 others); Mon, 3 Sep 2018 08:53:54 -0400 Received: from mail-oi0-f68.google.com ([209.85.218.68]:44638 "EHLO mail-oi0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726160AbeICMxx (ORCPT ); Mon, 3 Sep 2018 08:53:53 -0400 Received: by mail-oi0-f68.google.com with SMTP id l82-v6so32228713oih.11 for ; Mon, 03 Sep 2018 01:34:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=infinidat-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=qOnnW28q9L9jgWagZfM00l8k+/0G0cItbeqZVIVUPsE=; b=UdihlNBmiqemF2Z5N+XUMV/DYPjwonaPEyJrGhj9L52LrTNUpxS03ET9nU3JL18GoJ ZE6F/8cCbcqNOUw2tWq4zpHv8nyL1EfqroUTJW53382mXiExYEJ2tiChbnX+F3R4GSJ9 FNskjwVxY/OSH5q2NIyxVP3StVRZljafxsfnPwfB7tKEWN1p7o+uS9WtGexdJxQGXz+N /H4F2akv2nbM/bXKha1xMwlrwzdIllC2S6ALHuluvcPxL/y8uf+MrawTuaB61bbQz0Il EbFZ+JxFBmOrwUY5vGAD1TH3v1+s9J4+dKJ0/iERd5DI0vrisAdyTC2zLMI/Wm7/WByZ ENSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=qOnnW28q9L9jgWagZfM00l8k+/0G0cItbeqZVIVUPsE=; b=eOsKzx+sezA/GEPdz3S+2pmbK5PGY0g8qfZF70j5DGC9+X24iAhvpaVyMun11HR5Af 7t61edVLJ3zsd5UB6A9jHyY/3nMb4GZpbYu4eJ6rhHR8wCOKeIPd9V6qfG0AJwY4X/Oc mbNCBp8lQGBO3LLbsy9LEk7zu7UxIvB/ndthq8B32bIaKb88jIBntGCe+wMbFx8ROiOH YvXoq3/nUf2w3yygjx1oOejeef1b6oRgPNFZOAKHkT7ebonAFhYFK4MJxfiz1tt63yoO DQeYNa9DOL1DrrkVVXKp+BarDMTmCkRo+UDz4AEgWfUcoTfhgQE3vEdVzXnmuVLpxcHA fFmg== X-Gm-Message-State: APzg51AsucITExDX8Hc+AYZcrjBDZmoh4/mZkfrz8Z/266DfbCxO1sSn rqbqzLlI2gMEY0EE85lVdWwCG9GqhrdONenWkl7y X-Received: by 2002:aca:3407:: with SMTP id b7-v6mr17596889oia.345.1535963687773; Mon, 03 Sep 2018 01:34:47 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Dror Levin Date: Mon, 3 Sep 2018 11:34:48 +0300 Message-ID: Subject: Re: Recent removal of bsg read/write support To: torvalds@linux-foundation.org Cc: richard.weinberger@gmail.com, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, hch@infradead.org, axboe@kernel.dk 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 Sun, Sep 2, 2018 at 8:55 PM Linus Torvalds wrote: > > On Sun, Sep 2, 2018 at 4:44 AM Richard Weinberger > wrote: > > > > CC'ing relevant people. Otherwise your mail might get lost. > > Indeed. Sorry for that. > > On Sun, Sep 2, 2018 at 1:37 PM Dror Levin wrote: > > > > > > We have an internal tool that uses the bsg read/write interface to > > > issue SCSI commands as part of a test suite for a storage device. > > > > > > After recently reading on LWN that this interface is to be removed we > > > tried porting our code to use sg instead. However, that raises new > > > issues - mainly getting ENOMEM over iSCSI for unknown reasons. > > Is there any chance that you can make more data available? Sure, I can try. We use writev() to send up to SG_MAX_QUEUE tasks at a time. Occasionally not all tasks are written at which point we wait for tasks to return before sending more, but then writev() fails with ENOMEM and we see this in the syslog: Sep 1 20:58:14 gdc-qa-io-017 kernel: sd 441:0:0:5: [sg73] sg_common_write: start_req err=-12 Failing tasks are reads of 128KiB. > I'd rather fix the sg interface (which while also broken garbage, we > can't get rid of) than re-surrect the bsg interface. > > That said, the removed bsg code looks a hell of a lot prettier than > the nasty sg interface code does, although it also lacks ansolutely > _any_ kind of security checking. For us the bsg interface also has several advantages over sg: 1. The device name is its HCTL which is nicer than an arbitrary integer. 2. write() supports writing more than one sg_io_v4 struct so we don't have to resort to writev(). 3. Queue size is the device's queue depth and not SG_MAX_QUEUE which is 16. > > > Because of this we would like to continue using the bsg interface, > > > even if some changes are required to meet security concerns. > > I wonder if we could at least try to unify the bsg/sg code - possibly > by making sg use the prettier bsg code (but definitely have to add all > the security measures). > > And dammit, the SCSI people need to get their heads out of their > arses. This whole "stream random commands over read/write" needs to go > the f*ck away. > > Could we perhaps extend the SG_IO interace to have an async mode? > Instead of "read/write", have "SG_IOSUBMIT" and "SG_IORECEIVE" and > have the SG_IO ioctl just be a shorthand of "both". Just my two cents - having an interface other than read/write won't allow users to treat this fd as a regular file with epoll() and read(). This is a major bonus for this interface - an sg/bsg device can be used just like a socket or pipe in any reactor (we use boost asio for example). Thanks, Dror