Received: by 2002:ab2:7444:0:b0:1ef:eae8:a797 with SMTP id f4csp57774lqn; Fri, 15 Mar 2024 12:41:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXeQlb5UZO0kjaiVCrVsV5vqsJxAM5ifxC0APM+RA/60J0rukm3Hu2m6iUR3C1UGA8PHVqDuZyXRY3D533YU9/Wg2/oH6g0490lWVeB0w== X-Google-Smtp-Source: AGHT+IEVTIwsyUg/5vIV1AXMGszDze25D2OMA3Og762W7paRd4lIuza4mE9OkxNDWa13JPoVrfDF X-Received: by 2002:ac2:5b8e:0:b0:513:dc68:effd with SMTP id o14-20020ac25b8e000000b00513dc68effdmr63352lfn.42.1710531678622; Fri, 15 Mar 2024 12:41:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710531678; cv=pass; d=google.com; s=arc-20160816; b=Kajl3QTxA+XFNir1xJYWZj61uOeWtgX+mVxbnBa/OhiUkR3XLYhowmd4cvSjVkQvTz ogxe6GdhUnuz5Kxeznb9vUyKL9Kw7wijp9JaYaW69v79LFvDkHPafKHR7+9+slYVsvnD pyPEkEO5ZOKJVXvz5OTEbBCWu+U02iHo3lX1L1H4Bnk4IlriPU7TywPJTmToEO2HbeV8 GV//NQuti2WF/uF5T1EPg6Z7wL/VLP4j9EnK9jQk3MAkS5GL8suQKj0AhMnJL7sBwtqR ml/GzTZFoT7FeIM9BsA1BkjZWEIEO+By0klecMoAV7ioRPdGB9TwJfIHnRttGvQaCBvo FaRQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:subject:cc:to:from:content-language :user-agent:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:date:message-id; bh=aiQBsDD5f3b1VBJB0HUvAlPgpSthbmbJbgAs+fvJQhI=; fh=KJ5ObJeOvAunWF6/5mLouvR9YlPKrUXdFZzCnLg32v0=; b=DuMdPAA7MZckSz9lSUsVZGQhK5kE0LgjFizYXFe83UdKNpyGoYqzs7ytfzrxX7xfXA 8q39H41mrl4Awf0H1zmsVeV6t8iNSMN8ipo0D9loxHmu1YYIm+LnqF1mWlfrV0PovVXG SlAPDTJ2kmN0kJJu3DePsLj5fh+mfwtoJOMeBR99kx9Bh2rUWTuxc32XjfbJ/4439Pzw +pMhrlPdVbiyi++pZNyPLjTYBFqGEpS2QOfzVcL6arG7bDdz6g0j35yGLbEsbwd8g51H 1msOAaODn1IVGvbclhHXRTcCBLEazaopHjXnAE9zWDcjQrXZpoD7D0rayUXXc3XuwKlc qQpg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=ancud.ru); spf=pass (google.com: domain of linux-kernel+bounces-104851-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-104851-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id qa9-20020a170907868900b00a4439ecbc1esi2119654ejc.797.2024.03.15.12.41.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 12:41:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-104851-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=ancud.ru); spf=pass (google.com: domain of linux-kernel+bounces-104851-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-104851-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 1968D1F23681 for ; Fri, 15 Mar 2024 19:41:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 41C9F537FF; Fri, 15 Mar 2024 19:40:53 +0000 (UTC) Received: from relay164.nicmail.ru (relay164.nicmail.ru [91.189.117.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 889F352F62; Fri, 15 Mar 2024 19:40:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.189.117.8 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710531652; cv=none; b=BubqsL1sQCeLUsWIbdrrVC4MLRuq9uVQslSD19kK6LUu+zqcuo4xhC4nlXAiBMqthdcHnE+S9h5m0zigSKb+sDC7/JBdjHG/8xvgfFBksZYrE4Jh34VKa4KDX5iUwWTiTIKsfxGIrI8BWQEdMC4ucEA90pMsk2Qy1WxZzGVHTDo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710531652; c=relaxed/simple; bh=aiQBsDD5f3b1VBJB0HUvAlPgpSthbmbJbgAs+fvJQhI=; h=Message-ID:Date:MIME-Version:From:To:Cc:Subject:Content-Type; b=WlWzq/Vle/mPNUv3wAt7ULSlFhI/yrYB1Wf4AmRToOkxUg4KSOLBYSW38JSqGywqhA7cZsDVJ3aT5yGrvecowlCV3E1XBcalyU+kMOmzGucWark3hPsvOyeo2A1go/N41P8dXitLL0eeWXtyoEPU5xeYtSTLGHgL7TXLnWfhlSc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ancud.ru; spf=pass smtp.mailfrom=ancud.ru; arc=none smtp.client-ip=91.189.117.8 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ancud.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ancud.ru Received: from [10.28.138.152] (port=61310 helo=[192.168.95.111]) by relay.hosting.mail.nic.ru with esmtp (Exim 5.55) (envelope-from ) id 1rlDPx-0005RW-Cw; Fri, 15 Mar 2024 22:40:37 +0300 Received: from [87.245.155.195] (account kiryushin@ancud.ru HELO [192.168.95.111]) by incarp1104.mail.hosting.nic.ru (Exim 5.55) with id 1rlDPw-00C3au-31; Fri, 15 Mar 2024 22:40:36 +0300 Message-ID: <4d459714-734b-4cee-8ce6-d6abb9cff220@ancud.ru> Date: Fri, 15 Mar 2024 22:40:35 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US From: Nikita Kiryushin To: linux-scsi@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Lee Duncan , "James E.J. Bottomley" , "Martin K. Petersen" Subject: ida_alloc result as scsi host_no Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-MS-Exchange-Organization-SCL: -1 Hi all, Today I was reading documentation on struct Scsi_Host, as I was interested in possible values for host_no. The documentation says that: > host_no - system wide unique number that is used for identifying this host. Issued in ascending order from 0. In the code (scsi/hosts.c: scsi_host_alloc()) host_no is set as non-error result of ida_alloc() call (as added in Commit 126a4fe010fd ("scsi: Use ida for host number management") with a good reason of reusing invalidated host_no ids). My question is about implications of using ida_alloc(). As I understand, ida does not guarantee the order of id issuing, only that id is unclaimed in the pool and is within limits (which is 0 - INT_MAX for ida_alloc). Given that, my questions are: 1) Should it be mentioned in the documentation, that host_no is now reclaimable? The current wording is not clear about it; 2) The documentation mentions > sh_list - a double linked list of pointers to all struct Scsi_Host instances (currently ordered by ascending host_no) I could not find what it would be now in the code, but it seems that maintaining such a thing ordered should be a little less trivial with reclaimable ids; 3) Does ida_alloc() ensure ascending order? Is there a possibility of some new-more-effective ida implementation in the future, that honors id uniqueness and limits, but does not guarantee any particular ordering of id issuing? If it is possible, what would it break? 4) Should host_no really be limited only by int capacity (as it is now) or maybe some additional limits would make sense? There is at least one case in the current code with a buffer overrun if huge host_no is used (which led me to the research on host_no). Any clarification on the matter would be appreciated!