Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp1029212pxb; Thu, 9 Sep 2021 18:27:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyvg3uz5kDNRoooZaJ34NuAHAq4J8+DRrpU9+OJdw6VzVqHuivKL8X7dan4N9yuHD4f83ms X-Received: by 2002:a02:a18d:: with SMTP id n13mr2386271jah.120.1631237233025; Thu, 09 Sep 2021 18:27:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631237233; cv=none; d=google.com; s=arc-20160816; b=T4RSLzydvX5SKZLRiIKYQYA6/VUEAIGqPNXNsYH2bxxDTLvAdcNz3+Ei3gyncQpxh1 iY91uy1SEm5iN7LCXNENX93+PjLfRd54UNK6CqXDGGPTxYZBcHPzPu0PtmW9MchwJNoT KAvLgIL6saPXBUTeIZFEL2338mmzIkYB1zJE//MuRVASsNPkOPD+qBWxMmXLoz2Xm1HB RSM77cuMU3ORaWJeHGf1/vhZWnjUDq4qckNmYmgGwqf/W3I4ztWqCH/v+1LKFV3ZhcyX qLYs3ou7h1qtlo5L/7ycpjB/yq28srT5uFcDWy0xnvmjlM5YIgXqwPn8Q7gw/pM490mt otoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=AP1zZ/vEmIdYS+BpkjYpRIVz0XdIP7X4XRX+FiLpwj8=; b=iFPLGR4RLyHXqZEAyYsy1/JjGIT5nLRuJ+jm7AcMk738JTyf/ASK4jZSRXpKKBKP3P Rz+g1L9cwmykz84It8QXnC31nyns1qVIrhB+T36uRUWGrjWybK/2JbgrbnCGBDpmVC91 YGvwIN5sWPcR/6hA6OfWWrHkQ/s3nM7UMtf/PyD1oPAENiua49+w1kUdrcwWbMpPRqvV LpYCduMi0uuJVvFIzMQMHg5NkJpe1RfCKz3CP98uhph6+EdRcAbrDRY+o2NM9qVSFn3p I2mCP8Ekg4Xv+O4Lh/mB7xPFtP/196zF0etkKLePmUoKaeuAvecKPn3rwNDQPbVe2f1P PDWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=EUchTFp+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d7si3517360ila.10.2021.09.09.18.27.00; Thu, 09 Sep 2021 18:27:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=EUchTFp+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230009AbhIJB0z (ORCPT + 99 others); Thu, 9 Sep 2021 21:26:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229658AbhIJB0y (ORCPT ); Thu, 9 Sep 2021 21:26:54 -0400 Received: from bombadil.infradead.org (unknown [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D28ADC061574 for ; Thu, 9 Sep 2021 18:25:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: Content-Type:In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To: Subject:Sender:Reply-To:Content-ID:Content-Description; bh=AP1zZ/vEmIdYS+BpkjYpRIVz0XdIP7X4XRX+FiLpwj8=; b=EUchTFp+D0cHzj641tWHvT8h6x s/r5lU93njCOeDFHnCO7Z5OknEL1yJIYGukSpks4+oGOVvLmsO3i+H+ap6jOUOUfpWahH9GstOIE7 HhtvpCaYbn7Lq21vnU+UBOdqvGpxoSyILqBjI5isgulyLcnerWp+4XwRf9rTVOanldU0Idz8FAXDx GJGC/T8zT4SourA57fwYWESgiYJq6CSSVwnGclh4tvHzXDJIp5eImeHEwntA6bTAL1uomgG2P5v3P O5mjlMwG5sHryGuNPeiE7UWbU/3dl3Z7/A4Uwo+JOXP8K+vJ/zWh31aufHEKP1hrfsGkxH8H88lxh rmONNikA==; Received: from [2601:1c0:6280:3f0::aa0b] by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mOVIO-00BWXJ-80; Fri, 10 Sep 2021 01:25:36 +0000 Subject: Re: [PATCH v2] drivers/cdrom: improved ioctl for media change detection To: Lukas Prediger Cc: axboe@kernel.dk, hch@infradead.org, linux-kernel@vger.kernel.org, phil@philpotter.co.uk References: <409876e1-1293-932d-8d37-0211bef07749@infradead.org> <20210909180553.8299-1-lumip@lumip.de> From: Randy Dunlap Message-ID: <10f60086-2be0-d26d-dfa6-fe128772a409@infradead.org> Date: Thu, 9 Sep 2021 18:25:35 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20210909180553.8299-1-lumip@lumip.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/9/21 11:05 AM, Lukas Prediger wrote: >>> As this is not a packed struct, would not a smaller value still take up >>> the same space? >> Might as well be explicit about it and also make it obvious that there >> is some space available for other fields. > I had this as a __u8 in the first submission but Jens asked me to change it. > From his feedback on this: > > "The struct layout should be modified such that there are no holes or > padding in it. Probably just make the has_changed a flags thing, and > make it u64 as well. Then you can define bit 0 to be HAS_CHANGED, and > that leaves you room to add more flags in the future." > https://lore.kernel.org/lkml/6d6c533d-465e-33ee-5801-cb7ea84924a8@kernel.dk/ > > I changed it to __u64 to address this. We could think about turning it > back to a __u8 (or bool) and add some explicit padding members > (a __u8 reserved[3]?), but honestly I don't see much real benefit in that > compared to how it is now. I have no problem with Jens's suggestion. It would look more like this: +{ + __s64 last_media_change; /* Timestamp of the last detected media + * change in ms. May be set by caller, updated + * upon successful return of ioctl. + */ + __u64 media_flags; /* various flags */ #define MEDIA_CHANGED 0x1 /* Set to 1 by ioctl if last detected media */ /* other bits of media_flags available for future use */ and not having __u64 has_changed; which is overkill for a flag. -- ~Randy