From patchwork Wed Jul 10 09:38:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Eggers X-Patchwork-Id: 1958782 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20230601 header.b=QK1Dtf6P; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2001:4860:4864:20::3f; helo=mail-oa1-x3f.google.com; envelope-from=swupdate+bncbdk7hq7yrekrbgvnxg2amgqey7om7ey@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-oa1-x3f.google.com (mail-oa1-x3f.google.com [IPv6:2001:4860:4864:20::3f]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WJt8c0780z1xqj for ; Wed, 10 Jul 2024 19:38:38 +1000 (AEST) Received: by mail-oa1-x3f.google.com with SMTP id 586e51a60fabf-25e3d3730d2sf5100849fac.0 for ; Wed, 10 Jul 2024 02:38:38 -0700 (PDT) ARC-Seal: i=3; a=rsa-sha256; t=1720604315; cv=pass; d=google.com; s=arc-20160816; b=IDF6U6yVUu6zMqgFV9nBgZSEfugt1Ze3WWs+tq+NWfZ/tvrIm06crVJB7/JlfJXZh7 Q5gqY+hf26DCVM8VHGJ1SMrk2v9UH04tFXRuYNIAI67a2mewwcXyvzL9R+daS8MEMNPW Tf8n6oc53rKIG9AQF5COW9zryyJCsPMWnaEAcOBTwLNzTO8EdKutxHM3xLxyzO9ZfgNr zpy9uZ/NCEiWp2QU2TbsNwdAu5TTqgRAP9WxtxWuFhGsbPyLdgKLulXguK4giBeX/+5w 3tYl7LAWVicWmmqcKklp0kv/5rzl62x2gBXQalLKbh4IfxQ1NRsCA9BMe3SoyNbtGAhW YUjA== ARC-Message-Signature: i=3; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:content-transfer-encoding :mime-version:references:in-reply-to:organization:message-id:date :subject:to:from:sender:dkim-signature; bh=iDUsxE+IvgJmg61Nq+LfTpCfyUOy2S1DpQS0HglYTrA=; fh=Vy2LHxVTmk7k/m9Xx0+eFXn/t5hmfvyWRpXzAkXbJVg=; b=Aka+n7NmvjS5f9oNj8/isfkTVjqgifJRsHtkuoT/Yl/Ix+yqnK1N3KC/3HYZU5omhW Hn+3vwdBTX6NIH6lOtMlE3rkN+hcPGDXCBRRa6mlsQmhckk5GTQgokxhcWLKE4Cl2BAp s6nUIZ0544zD3DvDOhIaGOaiBUzDZZv/fauXjxn3pw/JmfkQJwItFg8ZoWka6dZ/K0T2 yhOxHmCogkD8HDABMWCkW5AaqZsnplBYK/3VKctq7jlFF+PTwp++fF2TDBW+HmX/gXeL EU3T44HaHKAuWcwzUODwkvv87iby3mJrD6fzc5uQP9EKAbzzsBwwXrT8JtLX8EcbpK7R uA0A==; darn=patchwork.ozlabs.org ARC-Authentication-Results: i=3; gmr-mx.google.com; dkim=pass header.i=@arri.de header.s=selector1 header.b=YQPD5CX+; arc=pass (i=1); spf=pass (google.com: domain of ceggers@arri.de designates 2a01:111:f403:2613::600 as permitted sender) smtp.mailfrom=CEggers@arri.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=arri.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1720604315; x=1721209115; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:content-transfer-encoding:mime-version:references :in-reply-to:organization:message-id:date:subject:to:from:sender :from:to:cc:subject:date:message-id:reply-to; bh=iDUsxE+IvgJmg61Nq+LfTpCfyUOy2S1DpQS0HglYTrA=; b=QK1Dtf6PEVgyapRcKP/zY5WyUgTTROLdzdNnZCvTvoVKLgv2d9tNxq+Nj/ul2iwsQh QTqnbFXSL9uitaqnPFZ/AhgV0BWuQffRTx3cEkhsTDd0DDYN/kV1FgnSQvrED0YLyzQf irYYlQbhxB0vsU4ovQ1SVvrWpo+U5t0LUeJh6CtEcXOkLQlyGglzn3yKNk+krVk8WE6Z E8hACNBZQJBkSuuFEImTKr8XHy5qlYylLX7mtPVgjRTRKyJdNAIx3lwiqLrYjuhq6/oB jvF2epdcrDlJPW0jgdoSFZvtuQ9xVzKZbxTbbSbKfnARLsVC+djOL1T0Sj1FFoYbsDBa Viiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720604315; x=1721209115; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender :content-transfer-encoding:mime-version:references:in-reply-to :organization:message-id:date:subject:to:from:x-beenthere :x-gm-message-state:sender:from:to:cc:subject:date:message-id :reply-to; bh=iDUsxE+IvgJmg61Nq+LfTpCfyUOy2S1DpQS0HglYTrA=; b=mDPH4qPb2Q1X98PKFunMlbQ+vQMFj72PINzJBp9oEbmR6KXIlG8R9Q26AanXVibJVs WWLex5rvWRBcFl35eRTeauw1Dp6bbnCdppjtm8zDFCRWPr2ePMo06eS7YRAxRnDhH1KO 30GYQD+LKwdeGgDqZH1r7+cN4T1a/0A5IPmHHNt9Si+7Hg9oUzJnoNCtxCmXzED6au0k lRzvixIeJ85f9xQBv2/r2eZt2YUyKJKuRyWRILEkJpjF3xpHRyyF8xEoRJHD1X+WJCsm lmmD+Os9jR1+amY3m6b3xY8+oq85720gIgq6lCPOwGVT+tzpvce0VPg25w9oXQar7chT vMBg== Sender: swupdate@googlegroups.com X-Forwarded-Encrypted: i=3; AJvYcCWdkLJgzk0O3gluQmvrvIHZKOdhb+4vzMQ/LVrjckLnQ8ChKjrAsE94IQmjQct+YvoFbY7U19iqCDuAcpqima7Wz6rpa/XhB5hqE/YEcg== X-Gm-Message-State: AOJu0Yx7mLg/KPBhoA1tIsb9tZROyYIwCtnrlFKT9VtzgoDmIg1F4puo C5/flZqt+QUEB43FE3dAx4EXGZoXtRHeg5w7BvbWzztns0kCRzwA X-Google-Smtp-Source: AGHT+IH+Z/9S/z/JNsGwkkSH5N1dBetWjmEeoofbucQlanxPqNsLi6h4OxzkNZ51MUDiLfa55vC36Q== X-Received: by 2002:a05:6870:f71d:b0:25d:ef22:980a with SMTP id 586e51a60fabf-25eaec16b8dmr4166940fac.43.1720604314854; Wed, 10 Jul 2024 02:38:34 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6871:b0d:b0:25c:a475:98e6 with SMTP id 586e51a60fabf-25e2876a623ls3892052fac.1.-pod-prod-02-us; Wed, 10 Jul 2024 02:38:33 -0700 (PDT) X-Received: by 2002:a05:6808:11c8:b0:3d9:296d:c1e5 with SMTP id 5614622812f47-3d93c111578mr4252992b6e.58.1720604313543; Wed, 10 Jul 2024 02:38:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1720604313; cv=pass; d=google.com; s=arc-20160816; b=Bi/9QXX5LJiyGTrzQoh80wB3INKpkj2QHjeW/j/7xPqpgqc5Pdnll/rJa7v6ZR4GHk /REi0At76pOGFw+oqeXUlfD+3Syc4AYdznXmPW18jphgGEe3QS4Z66cTi9CtpUGmoT3s KEmuz5RGEZmjnH0jDy/6kC2BRyKdEfR9E4wz3PFkAi3AY6DcbJuBbrHkucRSXW1oYh2D O93wGJWkc9ZCz79MZELP+XhYNexyhSDJhxSpZYEq6TZZZW2Z207YfwosmZybayd/mp5N 4sObZIXNG2UUJ1xY9v/lcM2kZeKO0wS8ndNI8xG/c37QaFknfLwriSQqjzbRLUw7An21 r0UQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :organization:message-id:date:subject:to:from:dkim-signature; bh=rFZh8+ezWehL7t0/9Ha4aeLZIK2MZI/qAhZJqZmvACk=; fh=sRONOy7xMjfMb3d2crplomEYWhgheBE41QTUUoiG2lQ=; b=Wx826smxoJT7F1LAbIa0VvohQ1o3wLgvbYLLxuHRmHCiAhx2ht6JC1IPp2ry4nZDLn rYvQQmaDvI1oql2Akn6MV48u8AkmxWFDftbw+Z9NLRK75AeDfl8tJk2F708bXpeazdSe gsAJVCn7dMPQvsyr+EdHkMlIEbZ/ExD/Hv66G8f5n5ordhQDRSKZa2BFx/oFY+v/7u6z EfLFOe7X+l+O541R1AMhFkTU2/2ROdMadQxc30ZegbSF6NwzTMpXscpv3H95O9hXRW85 WJpDVjtwnvvAaclO2Pa2JwTe5PIcarrPdQ7CqoD8tO/jp9zGK1t+Qk35yHBrGs3Erktl 9r5A==; dara=google.com ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@arri.de header.s=selector1 header.b=YQPD5CX+; arc=pass (i=1); spf=pass (google.com: domain of ceggers@arri.de designates 2a01:111:f403:2613::600 as permitted sender) smtp.mailfrom=CEggers@arri.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=arri.de Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on20600.outbound.protection.outlook.com. [2a01:111:f403:2613::600]) by gmr-mx.google.com with ESMTPS id d2e1a72fcca58-70b4370a575si137565b3a.0.2024.07.10.02.38.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Jul 2024 02:38:33 -0700 (PDT) Received-SPF: pass (google.com: domain of ceggers@arri.de designates 2a01:111:f403:2613::600 as permitted sender) client-ip=2a01:111:f403:2613::600; ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PMAyhWU1T9xFu3zlZ7VmOLx/bT4tuPiU4rAX/axguTP4HdWbdzpIBGqW7JgOkN1Dshz9TANeqT1D1ArR9glVDXN7HCMiBDP7yAOLCfkId00QPgH0SszqDChzCqm9a1/ZGGXOZp63FjlJWmLGjmo7MJ3SN3YinOAjYtxDmlu9EsGwaBApurhHWupRleyQ8iF1CKvzTl+93eURUG+Hkvh6fzE5f6IQdsATPBn//o6jWUzBXWZcQg24Ffy9rz3efWf1CSOmqiBr4s/XZEPYSQe1XS/S3LOiIQk+BwN0yKtyCHoGRHeADdUgkcDkzoox2n5/QK8XncQaQF/fyF3dRUSNDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rFZh8+ezWehL7t0/9Ha4aeLZIK2MZI/qAhZJqZmvACk=; b=OIocsU+ETm9SkNAJumwbsM1KgFQPx4HwPlfb00c9Bi6pA1peJRYG0bh3rL0Gz0454Xcg06LfFHS8E3vDNKVNpsMNsXamMszbsJ8M9XJZKo0CXbUHLjLta+NamFnsBzQQPt8my3rWpIqAUB5OU5yFX4om3PrqApql8bv6j4g6ACkUKXgf1NpVciEThVENoGYPGsEnQ/cR1QzuTabT2h4nh2ErLDKIBLSZjZixkZqR0SZr7ICiqK3nlHHbE5HOG/mUNMVBNDsu3JmlmKzLRDVlghVAPaFfKQWDRX9PKPl2WWa/0NNmdWINM5eiRG8pUOa4nRXJNjAycKSO/ejlQD2BkA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=fail (sender ip is 217.111.95.7) smtp.rcpttodomain=googlegroups.com smtp.mailfrom=arri.de; dmarc=fail (p=none sp=none pct=100) action=none header.from=arri.de; dkim=none (message not signed); arc=none (0) Received: from DU2P250CA0023.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:231::28) by DU2PR07MB9487.eurprd07.prod.outlook.com (2603:10a6:10:490::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.5; Wed, 10 Jul 2024 09:38:28 +0000 Received: from DB1PEPF00039230.eurprd03.prod.outlook.com (2603:10a6:10:231:cafe::c4) by DU2P250CA0023.outlook.office365.com (2603:10a6:10:231::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.36 via Frontend Transport; Wed, 10 Jul 2024 09:38:28 +0000 X-MS-Exchange-Authentication-Results: spf=fail (sender IP is 217.111.95.7) smtp.mailfrom=arri.de; dkim=none (message not signed) header.d=none;dmarc=fail action=none header.from=arri.de; Received-SPF: Fail (protection.outlook.com: domain of arri.de does not designate 217.111.95.7 as permitted sender) receiver=protection.outlook.com; client-ip=217.111.95.7; helo=mta.arri.de; Received: from mta.arri.de (217.111.95.7) by DB1PEPF00039230.mail.protection.outlook.com (10.167.8.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.17 via Frontend Transport; Wed, 10 Jul 2024 09:38:27 +0000 Received: from n9w6sw14.localnet (10.30.4.252) by mta.arri.de (10.10.18.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.34; Wed, 10 Jul 2024 11:38:27 +0200 From: Christian Eggers To: , Stefano Babic Subject: [swupdate] Re: [PATCH] handler: ubivol: relax accessing UBI volume Date: Wed, 10 Jul 2024 11:38:27 +0200 Message-ID: <8405030.T7Z3S40VBb@n9w6sw14> Organization: Arnold & Richter Cine Technik GmbH & Co. Betriebs KG In-Reply-To: <20240709192425.2939878-1-stefano.babic@swupdate.org> References: <20240709192425.2939878-1-stefano.babic@swupdate.org> MIME-Version: 1.0 X-Originating-IP: [10.30.4.252] X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB1PEPF00039230:EE_|DU2PR07MB9487:EE_ X-MS-Office365-Filtering-Correlation-Id: 04c36158-f200-4e00-0f37-08dca0c40d82 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: zQTQfzBW/wbshNL68xDMWJuziedsnZvPhHVtkf+4vOkzfkGdlM1h8PBpOGvBnDPwXj4na0nBf2Eu35LMyVX2w9gytY3lYpuWX6SYIdZrgH/dYYmuR0Zaq9vqL2l07qdVwpmnHM0OSif9fsyUhLuScQRQdfZHEsu8JoceOL4PkaW2Hd1cQESPM2JigfEYaHPoMNZ3sVZxOxNvEfQ6+rgAZtgi6YzJTdthF4IAqZ0lMbKT4cDycXZSLTjLdZpyXVoBar2tafDtnDTW5hid3SsN7FsX+UsSBEeqUq7SMvVgcyT3ZlCICmsoEnZcZTLEnSllH0iqqEq44Niz1TAdV8z8TMrTwAb1zC072F0uHzVbb6+dgoT2K8mnclnmTR44IxWKiI0ti72MxGsgO7ype1kwuHrqtUFjxYJgi+o6IUDCWJuwm8Qt49am+XRt5NGeZqJtJxwtWoQlSsrEqXovbX/tjThrtGhJ4cyseUAPQoDZ5AKHqcIpgvB4/GOGBdRmtCjQue2eXn6DOxYiMPHjE5d46SQAvAN8y/T21I/7FaI4hXi/5Oo4rf/ZdDNe+LovYLg3ofongV1WhYBBYMg9ujXOrZiJWW6008aCML61N6s1hnK8kWTFJFQe4wMkpbL5t+VA/Av14vj4vxAvr+PXSzQwt3rIhYLBUhPLnJ/iZcjNaLDbZDQxTIu04fD7uem5QmsMuCwnVE/jnaaDKQ4ckdgEzrchVGdbowgiCgmgRtS+KIiAqwvwTqZDILzOUgyvy3Hhxvu6aJkZDks3UOpWnVtdBdzHD0uhUa4tUmwQGD2gsGO8RCHTApv9RiE0Q66D6b0P5WT3jp7gmXFl8mgg8hcVIvlfX3z9WhWHNkXz3zdgaFgspg+qs/vDIiK2OOW3Ncg6n3AKLAO1L8wTakgh+tvlTentzgWutSsmK2RYSwgDde6QvEtfoQ3LLZUbYrfYLeyash6VqvqSg0bDu0j4VBW/kG8Up79blG+rITGCMV2U5KtocPzGfHFkvgAKD4EIuetQVIOvYL9h+8Iz9rXj5rLyoZ4uicMq6xJ3VhLNNU7XHzfFaBu//NQewm5+P2+T0W9Qs+HJ0eJh7gGWKyK2iUJfLjcWJC51B0IaQpleOeAky75iyNOZu4e668ZR8028jjxrCrt/oin8JrsOPuFLFfE4/4XEZXHLGknDYFKKwtKahBOkD2DV+QodCW1mRy60u2tI7eSgPyoF6Kmf18uzGYX37PtaKckvuDpUNysz4WUDOnEP6x7f3Vl/xs5rP/4om2WxBpvQSbNq3dniULZrkCBCU0CeQvkqCh5Lc1StNtCXdi3PqvipCOabu0LM3T3eqZiUxB1WdG+HCjTCPmNx1bsm85wkiuoadL0UTnhnzgv3C0NcUzFrkJbiG8JygG+/Hcw/VZKmET8lRyldB7QAus9J7HxkfNyAPi2p3Jxc8bdfITh1BKWM+IshXoXjLTJb9AYk X-Forefront-Antispam-Report: CIP:217.111.95.7;CTRY:DE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mta.arri.de;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(1800799024)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: arri.de X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jul 2024 09:38:27.9804 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 04c36158-f200-4e00-0f37-08dca0c40d82 X-MS-Exchange-CrossTenant-Id: e6a73a5a-614d-4c51-b3e3-53b660a9433a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=e6a73a5a-614d-4c51-b3e3-53b660a9433a;Ip=[217.111.95.7];Helo=[mta.arri.de] X-MS-Exchange-CrossTenant-AuthSource: DB1PEPF00039230.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR07MB9487 X-Original-Sender: ceggers@arri.de X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@arri.de header.s=selector1 header.b=YQPD5CX+; arc=pass (i=1); spf=pass (google.com: domain of ceggers@arri.de designates 2a01:111:f403:2613::600 as permitted sender) smtp.mailfrom=CEggers@arri.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=arri.de Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Hi Stefano, thanks for preparing the patch. On Tuesday, 9 July 2024, 21:24:25 CEST, Stefano Babic wrote: > It could be that some race conditions happens when SWUpdate tries to > lock the UBI volume for updating, for example after creating the volume > if udev is running and it accesses for some milliseconds. This is not an > issue inside SWUpdate, but SWUpdate can retry to get exclusive access of > the volume before giving up, making the update itself more robust. > > Signed-off-by: Stefano Babic > Reported-by: Christian Eggers > --- > handlers/ubivol_handler.c | 17 ++++++++++++++++- > 1 file changed, 16 insertions(+), 1 deletion(-) > > diff --git a/handlers/ubivol_handler.c b/handlers/ubivol_handler.c > index 0ad0321e..6d27c89f 100644 > --- a/handlers/ubivol_handler.c > +++ b/handlers/ubivol_handler.c > @@ -248,7 +248,22 @@ static int update_volume(libubi_t libubi, struct img_type *img, > ERROR("cannot open UBI volume \"%s\"", node); > return -1; > } > - err = ubi_update_start(libubi, fdout, bytes); > + > + unsigned int retries = 3; > + do { > + /* > + * libubi just returns -1, no check is possible I am quite sure that the value of errno (EBUSY) can be used in this case. > + * Simply retries in case of error if the volume > + * was locked by another process s/was locked/is currently accessed/ > + */ > + err = ubi_update_start(libubi, fdout, bytes); > + retries--; > + if (err) { > + WARN("Not possible to lock UBI, retry"); > + sleep(1); > + } > + } while (err && retries > 0); > + > if (err) { > ERROR("cannot start volume \"%s\" update", node); Additionally here should be a close() statement. > return -1; > -- > 2.34.1 > > Based on your patch, I have developed and tested a slightly improved version (attached). Do you like to post this as v2 (please set the *-by: tags as you like)? Now I get the following output: ... [TRACE] : SWUPDATE running : [resize_volume] : Removed UBI Volume kernel1 [TRACE] : SWUPDATE running : [resize_volume] : Created dynamic UBI volume kernel1 of 2671473 bytes (old size 2793472) [ 65.530992] ubi0 error: 0xc02587b9: 2 users for volume 1 [WARN ] : SWUPDATE running : [update_volume] : Not possible to lock UBI, retry [INFO ] : SWUPDATE running : Installing image lios-fitimage-ubifs-orbiter.fitimg into volume /dev/ubi0_1(kernel1) [TRACE] : SWUPDATE running : [update_volume] : Updating UBI : lios-fitimage-ubifs-orbiter.fitimg 2671473 [TRACE] : SWUPDATE running : [extract_files] : END INSTALLING STREAMING [TRACE] : SWUPDATE running : [extract_files] : Found file [TRACE] : SWUPDATE running : [extract_files] : filename lios-rootfs-release-orbiter.ubifs [TRACE] : SWUPDATE running : [extract_files] : size 33013760 required [TRACE] : SWUPDATE running : [extract_files] : Installing STREAM lios-rootfs-release-orbiter.ubifs, 33013760 bytes [TRACE] : SWUPDATE running : [install_single_image] : Found installer for stream lios-rootfs-release-orbiter.ubifs ubivol [TRACE] : SWUPDATE running : [resize_volume] : Removed UBI Volume rootfs1 [TRACE] : SWUPDATE running : [resize_volume] : Created dynamic UBI volume rootfs1 of 33013760 bytes (old size 33013760) [ 67.583171] ubi0 error: 0xc02587b9: 2 users for volume 4 [WARN ] : SWUPDATE running : [update_volume] : Not possible to lock UBI, retry [INFO ] : SWUPDATE running : Installing image lios-rootfs-release-orbiter.ubifs into volume /dev/ubi0_4(rootfs1) [TRACE] : SWUPDATE running : [update_volume] : Updating UBI : lios-rootfs-release-orbiter.ubifs 33013760 [TRACE] : SWUPDATE running : [extract_files] : END INSTALLING STREAMING ... At next I'll switch from v2023.12.1 to v2024.05.2. regards, Christian From fd2e8f9cc862aa33b3b819180762306ef69f0028 Mon Sep 17 00:00:00 2001 From: Christian Eggers Date: Wed, 10 Jul 2024 09:57:27 +0200 Subject: [PATCH 2/2] handler: ubivol: relax accessing UBI volume It could be that some race conditions happens when SWUpdate tries to lock the UBI volume for updating, for example after creating the volume if udev is running and it accesses for some milliseconds. This is not an issue inside SWUpdate, but SWUpdate can retry to get exclusive access of the volume before giving up, making the update itself more robust. Co-developed-by: Stefano Babic Signed-off-by: Stefano Babic Signed-off-by: Christian Eggers --- handlers/ubivol_handler.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/handlers/ubivol_handler.c b/handlers/ubivol_handler.c index 2ad0bc3c9db1..5f2aacf60ec4 100644 --- a/handlers/ubivol_handler.c +++ b/handlers/ubivol_handler.c @@ -225,9 +225,23 @@ static int update_volume(libubi_t libubi, struct img_type *img, ERROR("cannot open UBI volume \"%s\"", node); return -1; } - err = ubi_update_start(libubi, fdout, bytes); + + unsigned int retries = 3; + do { + /* + * Retry only in case of error if the volume + * is currently accessed by another process (e.g. udevd) + */ + err = ubi_update_start(libubi, fdout, bytes); + if (!err || errno != EBUSY || !--retries ) + break; + + WARN("Not possible to lock UBI, retry"); + sleep(1); + } while (1); + if (err) { - ERROR("cannot start volume \"%s\" update", node); + ERROR("cannot start volume \"%s\" update: %s", node, strerror(errno)); close(fdout); return -1; } -- 2.44.0