On Wed, Nov 13, 2019 at 11:27:25AM +0100, Johannes Thumshirn wrote:
> close_fs_devices() will be able to return an error instead of crashing
> after the following patch.
>
> Prepare btrfs_close_devices() for this.
>
> Signed-off-by: Johannes Thumshirn <jthumshirn@xxxxxxx>
> ---
> fs/btrfs/volumes.c | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index e5864ca3bb3b..be1fd935edf7 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -1143,10 +1143,10 @@ static int close_fs_devices(struct btrfs_fs_devices *fs_devices)
> int btrfs_close_devices(struct btrfs_fs_devices *fs_devices)
> {
> struct btrfs_fs_devices *seed_devices = NULL;
> - int ret;
> + int err, err2 = 0;
Please use ret and ret2.
> mutex_lock(&uuid_mutex);
> - ret = close_fs_devices(fs_devices);
> + err = close_fs_devices(fs_devices);
> if (!fs_devices->opened) {
> seed_devices = fs_devices->seed;
> fs_devices->seed = NULL;
> @@ -1156,10 +1156,13 @@ int btrfs_close_devices(struct btrfs_fs_devices *fs_devices)
> while (seed_devices) {
> fs_devices = seed_devices;
> seed_devices = fs_devices->seed;
> - close_fs_devices(fs_devices);
> + err2 = close_fs_devices(fs_devices);
So only the last error value gets propagated to the return statements.
Is that intentional?
> free_fs_devices(fs_devices);
> }
> - return ret;
> +
> + if (err2)
> + return err2;
> + return err;