OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
From: Konstantin Khorenko <khorenko@virtuozzo.com>
To: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>,
	Eva Kurchatova <eva.kurchatova@virtuozzo.com>
Cc: devel@openvz.org
Subject: Re: [Devel] [PATCH hci-8.1 v2 1/1] block: let container root set the block size of and flush its device
Date: Thu, 29 Oct 2026 16:49:51 +0100	[thread overview]
Message-ID: <830d0a54-508e-47c9-bd63-5e15b379aec2@virtuozzo.com> (raw)
In-Reply-To: <f7c0b8ba-9854-45ce-b426-ee486f0b92f2@virtuozzo.com>

On 10/23/26 12:52, Pavel Tikhomirov wrote:
> On 10/22/26 04:25, Eva Kurchatova wrote:
>>  static int blkdev_flushbuf(struct block_device *bdev, unsigned cmd,
>>  		unsigned long arg)
>>  {
>> -	if (!capable(CAP_SYS_ADMIN))
>> +	if (!blkdev_admin_capable(bdev))
>>  		return -EACCES;
>>  
>>  	mutex_lock(&bdev->bd_holder_lock);
>> -	if (bdev->bd_holder_ops && bdev->bd_holder_ops->sync)
>> +	if (bdev->bd_holder_ops && bdev->bd_holder_ops->sync) {
>> +		/* A filesystem on the device is synced by its own mount, not from a container */
>> +		if (!ve_is_super(get_exec_env())) {
>> +			mutex_unlock(&bdev->bd_holder_lock);
>> +			return -EBUSY;
>> +		}
>>  		bdev->bd_holder_ops->sync(bdev);
> 
> This looks a bit overprotective, if we allow writing to this disk directly, why not allow syncing it directly, mounted fs or not.
> 
> Not a blocker though, fine either way.
> 
> Reviewed-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>

> This looks a bit overprotective, if we allow writing to this disk
> directly, why not allow syncing it directly, mounted fs or not.

Agreed, we will open this path.

It is reachable only with a device cgroup write grant on that very
device, bdev_permission(BLK_OPEN_WRITE) is checked at ioctl time. CT
disks from vzctl have W (write for mount only), so they stay at -EACCES.

With a write grant the CT can already overwrite the filesystem under
the mount. Forcing its writeback is strictly less than that.

fs_bdev_sync() is what syncfs() does: sync_filesystem() under s_umount
shared, with bd_holder_lock dropped before. Nothing the host does not
already get from any syncfs() on that mount.

invalidate_bdev() drops clean pages only, the dirty ones went through
the sync first, and busy buffers of a mounted fs are skipped. The cost
is a metadata re-read, not data.

The only thing it bypasses is the VE sync filter in ksys_sync(), and
raw write access to the device makes that filter moot anyway. On the
CT's own mounted loop it restores host parity: blockdev --flushbufs
behaves as on the host.

> Not a blocker though, fine either way.
>
> Reviewed-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>

Thanks.


--
Best regards,

Konstantin Khorenko,
Virtuozzo Linux Kernel Team
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

      reply	other threads:[~2026-10-29 15:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-22  2:25 [Devel] [PATCH hci-8.1 v2 0/1] " Eva Kurchatova
2026-10-22  2:25 ` [Devel] [PATCH hci-8.1 v2 1/1] " Eva Kurchatova
2026-10-22  2:29   ` no-reply
2026-10-23 10:52   ` Pavel Tikhomirov
2026-10-29 15:49     ` Konstantin Khorenko [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=830d0a54-508e-47c9-bd63-5e15b379aec2@virtuozzo.com \
    --to=khorenko@virtuozzo.com \
    --cc=devel@openvz.org \
    --cc=eva.kurchatova@virtuozzo.com \
    --cc=ptikhomirov@virtuozzo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox