[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <448079fd-ac31-4a6e-99f8-9021c0a92476@oracle.com>
Date: Mon, 8 Sep 2025 08:53:59 +0100
From: John Garry <john.g.garry@...cle.com>
To: Ojaswin Mujoo <ojaswin@...ux.ibm.com>
Cc: Zorro Lang <zlang@...hat.com>, fstests@...r.kernel.org,
Ritesh Harjani <ritesh.list@...il.com>, djwong@...nel.org,
tytso@....edu, linux-xfs@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-ext4@...r.kernel.org
Subject: Re: [PATCH v5 04/12] ltp/fsx.c: Add atomic writes support to fsx
On 05/09/2025 17:29, Ojaswin Mujoo wrote:
>>> +
>>> +/*
>>> + * Round down n to nearest power of 2.
>>> + * If n is already a power of 2, return n;
>>> + */
>>> +static int rounddown_pow_of_2(int n) {
>>> + int i = 0;
>>> +
>>> + if (is_power_of_2(n))
>>> + return n;
>>> +
>>> + for (; (1 << i) < n; i++);
>>> +
>>> + return 1 << (i - 1);
>> Is this the neatest way to do this?
> Well it is a straigforward o(logn) way. Do you have something else in
> mind?
check what the kernel does is always a good place to start...
Thanks
Powered by blists - more mailing lists