From patchwork Tue Jul 9 19:24:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1958575 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=OF9AA7C+; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::337; helo=mail-wm1-x337.google.com; envelope-from=swupdate+bncbd2zdgn6sekrb344w22amgqece2liay@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-wm1-x337.google.com (mail-wm1-x337.google.com [IPv6:2a00:1450:4864:20::337]) (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 4WJWC96CXyz1xr9 for ; Wed, 10 Jul 2024 05:24:37 +1000 (AEST) Received: by mail-wm1-x337.google.com with SMTP id 5b1f17b1804b1-42668857c38sf19151955e9.1 for ; Tue, 09 Jul 2024 12:24:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1720553072; cv=pass; d=google.com; s=arc-20160816; b=OYcxpt/NsXIor++6ZBJKBBuVxMcNc5TOp/3uZqBa9jLI+l25wNTFlsLQ2PqKxEf/pl 0MLUWC1zy89HrWQWB/W80SAZFmJF8vFzTc4gsIrrPrb9tniGypTsP7zL5HYCcyRF4asI YZUf/XL5Fgg0trKCSLY34Hm5eELy5NVKvKu/mPDSwPjG4qsMufPc4EUokTtCbjL3ZLPr ygkAQMeJ/U39DYmRHNhkMKeuVXJaxbyUAlPxk8XLYb/MEqE/ql2Hpv/moD4Hx2ZXoZ7z rP5o6vcx9In61OHG50eKa2Q92YLHEB2mfTGtXFk4GUUpqSIdaA7nU2eXzCMXqe06Fc0C 2BzA== ARC-Message-Signature: i=2; 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:ui-outboundreport:mime-version :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=yW6vrxed5J3PGzDSVs+doul3oV9oBFnak6686kTbcDo=; fh=5jUa1gDWkRIYNOWudx5S2Ecw162/efvBbd1psA+k9Lg=; b=J4KzyLNtby87zQP7CNxw+Fa+6jodGnqhCvt6NAaVknKBzAiXj0AMgled28ialZ/LmT jUIB18N/dRz0KII+QNqCt8HmoIw+vJufAHleLK9qdvsVNv1rs/AwCHoTv+kusTDvdcgy OuBW5OUmkNznpAkcP52Bv9qyEa8cVVtpp6DjvNCkPzbvOCoEyyd6QCZkNvOMK82dF9xv yhFNqPhb6wy6h7U0TAwGrm48UVm878+ARqHWBUUK9QGyIpC1Yxjp5JTQwe6VgOihWdP4 uvM8TWQEBkyM1oS5HMr2cerD4zPl9YUbc21VQmUqTHOVQAZdXmQZeHVAM+DDhyNCJj3+ IIDA==; darn=patchwork.ozlabs.org ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b="K2MXS/ds"; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.130 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1720553072; x=1721157872; 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:ui-outboundreport:mime-version:message-id:date :subject:cc:to:from:sender:from:to:cc:subject:date:message-id :reply-to; bh=yW6vrxed5J3PGzDSVs+doul3oV9oBFnak6686kTbcDo=; b=OF9AA7C+YHlVFB14RdKu9oH2pVMBx3Za0AXiTv7ws3tIzoxdb0CqiQbcbXq0oUZ4/V tjWQC6yywBTGfs0nhPaCvFQ1l2V6iVB0Ipc7Qn1ZsYPvTWRaJS4t7JYhnMKc2bXHuphN KUWyQvN1cV9za3KtFkifwchK54zJOLnGWTLYMDn2T30ouUoLGVpbAIyMe8VJ39vgYev/ jWvVcLwJmTxf9ZtOdXtES9fc573ijUEt73iuVkzACneHIuOnIRgUxlh2DaSEeP3/lOhO MFN9puwhsoMgQx9HtyMUbMV5Y9Pp445sHbDTnTX3qEFAavxvTPIbY3lLcgZoGmE6v2WO LwDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720553072; x=1721157872; 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 :ui-outboundreport:mime-version:message-id:date:subject:cc:to:from :x-beenthere:x-gm-message-state:sender:from:to:cc:subject:date :message-id:reply-to; bh=yW6vrxed5J3PGzDSVs+doul3oV9oBFnak6686kTbcDo=; b=U7Swk0kn/HUT53o6+43ZHnM1LQLZe77cY2/TB87ss4JlObynm5R5s0WhcPnx/b6vBj 6L7Y7XrMW+g0dnyuIzfyVd99gOBV3qoLXB9mg9EnkTBwg6iE5u56K9MNL71RN9O7S+mP zYr9OCKfAuDWN0cIpuyTuIbLufR10+eGkUtIIFyY4scc9BMEB4amDStTmp3rs9v/l4Kj txySJ6slfx1oSE6aA6gO0K9yzzLQ74D+o/GfX14nBkO2A/YdCh1UXFqug3AP5+ha8EyE 3ahDWkwjof22noVrBetaC0UfjQ6auJOfZI81P0Klxr4WIAehq7ErI6H3SnPYC+JqMww6 emew== Sender: swupdate@googlegroups.com X-Forwarded-Encrypted: i=2; AJvYcCUWcVCLHlE3+yfE6zIK/rXPafpgFa3jCJ8WzHLWrv5VD8x5fI4VnfTLKCPkZyn/UXCN97dvcVIitSAx1eP264y02hG7wUvtA16Ikie61g== X-Gm-Message-State: AOJu0YwqCaV/pnUj7C4tDh/xA7fPFppcu86qnLH7FJdQeuPP9kLja3dK iFhoMrvfz0fxPhjwxJ++zvO9+np6so4qwS+LPHC0L7xICFPw1+p7 X-Google-Smtp-Source: AGHT+IFnbxVfB8I9CvCbCpv+YANtOuDv1COKdIKBmWpb87GlX58QWY6rIR+QUVZadNKclnhfD0TXDw== X-Received: by 2002:adf:fdc3:0:b0:366:ec2c:8646 with SMTP id ffacd0b85a97d-367cead10b1mr2312643f8f.43.1720553071855; Tue, 09 Jul 2024 12:24:31 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:600c:4fd2:b0:426:73d7:f1f5 with SMTP id 5b1f17b1804b1-42673d7f4e8ls4727405e9.1.-pod-prod-07-eu; Tue, 09 Jul 2024 12:24:29 -0700 (PDT) X-Received: by 2002:a05:600c:4927:b0:426:97e2:345d with SMTP id 5b1f17b1804b1-42697e238c0mr15301405e9.40.1720553069058; Tue, 09 Jul 2024 12:24:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720553069; cv=none; d=google.com; s=arc-20160816; b=gFuOznTtJakRYpPcXW+IGxdAyG9TI4oIaWfYuSxJsqugdqh7vuhkZF/JhvGWe7MD1F rneJ9QMApCWeGopE48Oug8aGDupxh4Q+teaBS0JLfuPbnrI6flvMoYNlRQrAzp8iiKFy DxZSp+mCmf8I+kn6gwaBrEkvT/Ktfjf9s9Fe5NTVJ9fo0eZ0nZZBtJ0+Vfk7kSAQ1OL9 5hs8DSJKe3G97PKk8293ZD8VEkEkvTEDfyktmxdt2dN6U/yXD7HHWGOj+Km4qGPwc/xr swTkTwnX01gEuZ5YbOg37s6ayOr8gwiYthgpe24I3X9SsAhByEhdUx+Xb7goJgU310j/ Ptng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:mime-version:message-id :date:subject:cc:to:from:dkim-signature; bh=d+NvaI/aPPdyhxm4Jx/5DW/2CHeeN78LlRngJARWPeI=; fh=B1tLJRnpVURVF77rcFTt56FaA+ftMwJCVZP7QR8V05A=; b=Q7XhizPP36mlTamgCRJkQnZcLPvSi6EiQIhVr03n6qF3tyw71jotM164ahX2xp99nD TalNSTfxgNizQhBb3Ja9kVvyjQqsEIAknxe0zFM9QIcH3WTTXkgl7ZTOw4jG0pSvsZZS KJBXQIB0evdzQ9A8t1t/6ruG4k4jVLcAVowWUIp0QxoQaRfr7z55StaGcDF89WGkpM/I SNmibHOzTBqo1U3NknKMkFSERyqgKJLm+uUcm0pnxjvFXgLdsTbQXohXEaZ9rBcPEHz6 BmQh4KM7+qUTK9u/WMT8nJHXgF8L8269ha3jbwww3VtIfFSF+AVa0+UbkONBJvXCowjb icrw==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b="K2MXS/ds"; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.130 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Received: from mout.kundenserver.de (mout.kundenserver.de. [212.227.126.130]) by gmr-mx.google.com with ESMTPS id 5b1f17b1804b1-4266f736460si560215e9.2.2024.07.09.12.24.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jul 2024 12:24:28 -0700 (PDT) Received-SPF: pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.130 as permitted sender) client-ip=212.227.126.130; X-UI-Sender-Class: 55c96926-9e95-11ee-ae09-1f7a4046a0f6 Received: from paperino.fritz.box ([88.217.136.221]) by mrelayeu.kundenserver.de (mreue009 [213.165.67.97]) with ESMTPSA (Nemesis) id 1M8QNs-1sVgIm2Q2y-003Zj0; Tue, 09 Jul 2024 21:24:28 +0200 From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic , Christian Eggers Subject: [swupdate] [PATCH] handler: ubivol: relax accessing UBI volume Date: Tue, 9 Jul 2024 21:24:25 +0200 Message-Id: <20240709192425.2939878-1-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Provags-ID: V03:K1:6D8FY/btGBuhDZxlt7a9sGASV0+EcKYZAqKbXrtMMa3X386YXVL BTFRaSGB9f4I2It7mxv2H51lAPICcN2odWEc0lXjJ6gYANN+GgV1MfAcYbXTYDrWIUk7aXX QQkx/C5I5CyYXH+eSsWhgJ/sfYQYE6GYWbSvUDFKLrf9BGDUw3KIHq/h5UCVdyNQBeFLFKZ pT0YFtlm0a89eQAQ1lloA== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:RUegAZIlisE=;gj/QKveLby3XzfUai+yH7gYJtFe 7DaCGQGjhor5sa1vVT3KCdsv/2A71FCc7Ds1+aizDTMNbTY71zp+kOdWtxGS7IjD+3y8v41pR 3HQ3wFScQRi35NGhqdQPDaIEygCUuGddwmH6iyYGgT8m2kwy77PpKi2zZYPVYzmDltfuERSlC CHayTjJ2Mmh3Rg+DUP8jTr6j2he5A39EtsqDbMm+gD1P9wYTgmrRWr5SlbUcYfiW2+fsEc+za yO42pJRGzPbPT0L68IOTP9o74SSoUZkBgswpnf8XIv7v7g6RO2zQTWmCDkW7mNH9YSnrZjQ/G 3qAZDNzAHWnA+we8j115ZsSJQzhv3xuddzgAgAqRMWiNfnw9Hh1yi/suh6kAITfG/u3hgo4r4 DDcVDNd5oEAimwWcZiufEmk6e1MFScKsCyDVay9iJfcfQ3ZeB65qQR9VS7bW78gIgOWLJzOwZ cQkLOnnOn5UsrVm5wVyjNSu8qk8pJJdHnA/bzRovcHq8ddDifmAsZk7SYyFuFIxlqD8NQ3bOJ wT+Wlwr6mk8vIYaM018TPy0aNtXRKrfDlP3TjHwaM5EFKv0X0qYmCjZD6fhG9YG+qy/rnwHcw IwtACVZAX8Lgqp6KjdHCdCmiLReEV1TbW3rf9LEsnuulXIVfURCKJZO//oFpvasTxI8Sw8vez JmJH3ctgkGhi1tQRfYYQ4JFyYvuRpAVrc3JTic5Do35qO1u6qIiURx90sahHv5lJoc8wUcKTQ OsCC7QGbT7NNsB0bqS3UwhjLCJJCrb1pw== X-Original-Sender: stefano.babic@swupdate.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b="K2MXS/ds"; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.130 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org 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: , 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(-) -- 2.34.1 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 + * Simply retries in case of error if the volume + * was locked by another process + */ + 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); return -1;