[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] rumpdisk: Protect device_open/close and r/w with a mutex for
From: |
Samuel Thibault |
Subject: |
Re: [PATCH] rumpdisk: Protect device_open/close and r/w with a mutex for threading |
Date: |
Sat, 26 Feb 2022 11:29:59 +0100 |
User-agent: |
NeoMutt/20170609 (1.8.3) |
Damien Zammit, le sam. 26 févr. 2022 06:29:21 +0000, a ecrit:
> @@ -233,22 +246,32 @@ rumpdisk_device_open (mach_port_t reply_port,
> mach_msg_type_name_t reply_port_ty
> bd = search_bd (name);
You also need to protect the list, against concurrent addition of
elements.
> @@ -296,6 +323,8 @@ rumpdisk_device_write (void *d, mach_port_t reply_port,
> if ((bd->mode & D_WRITE) == 0)
> return D_INVALID_OPERATION;
>
> + pthread_mutex_lock (&rumpdisk_rwlock);
> +
Does rump really need to be accessed sequentially? Isn't it thread-safe?
I guess it is thread-safe, in which case you don't need to protect
rump_sys_* calls from each other. All you need is to protect against
a concurrent device_close call. You can use an rwlock for that:
device_write/read take the rwlock in read mode (and check that the
device is still open), and device_close takes it in write mode.
Samuel