fuse: Drop permission changes in fuse_do_truncate
This function is always called with writable == true. This makes add_resize_perm always false, and thus we can drop the quite ugly permission-changing code. Signed-off-by: Hanna Czenczek <hreitz@redhat.com> Message-ID: <20260309150856.26800-17-hreitz@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Hanna Czenczek committed
Mar 9, 2026 at 16:08 UTC
bea1163decf81cda4e9b09dad7090bf585f2ed10
1 file changed
+2
-32
block/export/fuse.c
+2
-32
@@ -503,44 +503,14 @@ static void fuse_getattr(fuse_req_t req, fuse_ino_t inode,
503
static int fuse_do_truncate(const FuseExport *exp, int64_t size,
504
bool req_zero_write, PreallocMode prealloc)
505
{
506
- uint64_t blk_perm, blk_shared_perm;
506
BdrvRequestFlags truncate_flags = 0;
508
- bool add_resize_perm;
509
- int ret, ret_check;
510
-
511
- /* Growable and writable exports have a permanent RESIZE permission */
512
- add_resize_perm = !exp->growable && !exp->writable;
507
508
if (req_zero_write) {
509
truncate_flags |= BDRV_REQ_ZERO_WRITE;
510
}
511
518
- if (add_resize_perm) {
519
- if (!qemu_in_main_thread()) {
520
- /* Changing permissions like below only works in the main thread */
521
- return -EPERM;
522
- }
523
-
524
- blk_get_perm(exp->common.blk, &blk_perm, &blk_shared_perm);
525
-
526
- ret = blk_set_perm(exp->common.blk, blk_perm | BLK_PERM_RESIZE,
527
- blk_shared_perm, NULL);
528
- if (ret < 0) {
529
- return ret;
530
- }
531
- }
532
-
533
- ret = blk_truncate(exp->common.blk, size, true, prealloc,
534
- truncate_flags, NULL);
535
-
536
- if (add_resize_perm) {
537
- /* Must succeed, because we are only giving up the RESIZE permission */
538
- ret_check = blk_set_perm(exp->common.blk, blk_perm,
539
- blk_shared_perm, &error_abort);
540
- assert(ret_check == 0);
541
- }
542
-
543
- return ret;
512
+ return blk_truncate(exp->common.blk, size, true, prealloc,
513
+ truncate_flags, NULL);
514
}
515
516
/**