Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp28040pxb; Mon, 11 Apr 2022 17:52:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8ks1DJo4gZAFnCMon7Bn5P5XPGZUcqDF9GP23DWzE78aV3/2lQ+aYaStk0x63xXkiVhVE X-Received: by 2002:a17:906:a08b:b0:6b9:2e20:f139 with SMTP id q11-20020a170906a08b00b006b92e20f139mr33740306ejy.463.1649724765283; Mon, 11 Apr 2022 17:52:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649724765; cv=none; d=google.com; s=arc-20160816; b=WauQyv0/A8eyLYOPUgbC7Ia0Wm6EUMjWCVNFGGDibM+0GTU0itcwmKdZnV9Vk9zy7D fpe4kESSfVt80iKd1B+qkaQbQDV0SXrrDYlVPvIgzAv4IaTjDk4ka5OJAVvqBAbETDLE vHj9yVckHdqa2jiRXqSsiR9OwtMzBeKKzjKO7ainiDFrsvXwFNBJLwVjodAIkbvSJR// L7cdRsw3BneMYCfDC8rE8j9NHo+Wp6v5oj24hszKSKt8jfdODss3upJo3nUh/qeg2EWh 7RETxl0Z1CcnATHRHbSzv0I6w2ERbHgGT6CaWiPxEmk/Y8PHla4B5c3WY9RGfr1405mL w++w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=xoX1XlBl8mnhwb9bFZeQrGYwWmVqHEr1GUzp3gF6nNA=; b=InHUuxg7YhKhV8pZlICivx/fGkdI3mEctG9lsF1xXUjVR5EUGyfKcSK1UbrEQbzX+S 0ea19qqeefWxheM1BCzChH/7V6hbFXSD8y8hEwBZkm53E3No+8GxUkx2hxT38r6vr0ig 9AwD6PiKJLpTpbv457Yy1viW7kdUk7FxWJy0XD8JWts6SWkSFqO7ceP9TBLL/ikh4X6T 68pEDk55s/RHEt6RBrSxRUy/otkB0f/MKHzTzHxYuN47VJLKqCe+egQd+9aj+2Yq8g0R gVmG/FYduqZanwC4c6S9Yc5Qpwf8N4AOjJgeXM4TGtVKVcdqZUEIFpfuXAjwpZouY2kT Z0uQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s8-20020a1709062ec800b006df76385cb5si7618718eji.341.2022.04.11.17.52.21; Mon, 11 Apr 2022 17:52:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242240AbiDINsm (ORCPT + 99 others); Sat, 9 Apr 2022 09:48:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231314AbiDINsl (ORCPT ); Sat, 9 Apr 2022 09:48:41 -0400 Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by lindbergh.monkeyblade.net (Postfix) with SMTP id DB2309D06B for ; Sat, 9 Apr 2022 06:46:33 -0700 (PDT) Received: (qmail 285322 invoked by uid 1000); 9 Apr 2022 09:46:32 -0400 Date: Sat, 9 Apr 2022 09:46:32 -0400 From: Alan Stern To: Maxim Devaev Cc: linux-usb@vger.kernel.org, Felipe Balbi , Greg Kroah-Hartman , Cai Huoqing , linux-kernel@vger.kernel.org Subject: Re: [PATCH] usb: gadget: f_mass_storage: break IO operations via configfs Message-ID: References: <20220406092445.215288-1-mdevaev@gmail.com> <20220406195234.4f63cb4a@reki> <20220406213634.104cae45@reki> <20220407204553.35cead72@reki> <20220409115756.4f9b015d@reki> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220409115756.4f9b015d@reki> X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Apr 09, 2022 at 11:57:56AM +0300, Maxim Devaev wrote: > В Fri, 8 Apr 2022 10:59:45 -0400 > Alan Stern wrote: > > > At least there is one situation where the behavior of f_mass_storage differs > > > from the behavior of a real drive. What happens when you click on the physical > > > "eject" button? > > > > If the host has prevented ejection, nothing happens. Otherwise the disc > > gets ejected. > > > > > Yes, the OS can block this, but the problem is that we don't have > > > an "eject" here. > > > > What do you mean? Writing an empty string to the sysfs "file" attribute > > is the virtual analog of pressing the eject button. > > But I can't eject the disc event it's not mounted on Linux host. It seems to me > it differs from the real drive behavior. It sounds like either there's a bug or else you're not doing the right thing. Tell me exactly what you do when this fails. > > ... > > I have reflected on the rest of your arguments and changed my mind. > I think that "forced_eject" for a specific lun without interrupting operations would > really be the best solution. I wrote a simple patch and tested it, everything seems > to work. What do you think about something like this? > > > static ssize_t fsg_lun_opts_forced_eject_store(struct config_item *item, > const char *page, size_t len) > { > struct fsg_lun_opts *opts = to_fsg_lun_opts(item); > struct fsg_opts *fsg_opts = to_fsg_opts(opts->group.cg_item.ci_parent); > int ret; > > opts->lun->prevent_medium_removal = 0; > ret = fsg_store_file(opts->lun, &fsg_opts->common->filesem, "", 0); > return ret < 0 ? ret : len; > } > > CONFIGFS_ATTR_WO(fsg_lun_opts_, forced_eject); The basic idea is right. But this should not be a CONFIGFS option; it should be an ordinary LUN attribute. For an example, see the definition of file_store() in f_mass_storage.c; your routine should look very similar. > If you find this acceptable, I will test this patch on my users to make sure > that its behavior meets our expectations. Okay. Alan Stern