From patchwork Fri Jul 12 08:07:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1959696 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=qXGAVi7x; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::23c; helo=mail-lj1-x23c.google.com; envelope-from=swupdate+bncbd2zdgn6sekrbsgiyo2amgqebixxfgy@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-lj1-x23c.google.com (mail-lj1-x23c.google.com [IPv6:2a00:1450:4864:20::23c]) (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 4WL42n2T4Rz1xqc for ; Fri, 12 Jul 2024 18:07:43 +1000 (AEST) Received: by mail-lj1-x23c.google.com with SMTP id 38308e7fff4ca-2ee8f22ef7csf16527671fa.2 for ; Fri, 12 Jul 2024 01:07:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1720771658; cv=pass; d=google.com; s=arc-20160816; b=y78BqgomgF/E9cedCBmPAjWWXmpW0/TAE9pp2OyGIYV0CVkVXBCw3btIJj/NFxrqPk LKV+FEssWJFrWJL5tIR/FRxV/t3ziG4cXPtPoyi775PImkjtNiQ1GcjvuwOJZY7wEvuT k9LKaU4LhjoG9KkzpslbgD0nGkc3/7HLN37/Luk3j9+r13BGMsZILAMchOl2Hgcs0HLG rGBmAaGau8UUg2pZiE4q0FNxYk8/t0K1rau88/TMAPCzTfayho0DbZHgaIRdRNKLAc4Z M2+BZvoJK7l0WiVuLoQwQt8k6m1WZMujLExNZCDYRNp/Sw3tRJhZbGGEpycLlzn/yb+D dJeA== 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=dl422h7V8FKPczYl0wg+Vmwk8xee4EevOkrX4hD5Ok0=; fh=87BTvTuCWosWv8TpCiMkjFH4no4Jx3Df5lPYam8q5K8=; b=NoNhH4SMXYxl/5Td/5D9bTqsWyezSP/87X2E/FVDZY5Eoy/LLQG/splKEUOFPDDmFV eUGehQvMvQiWTJX/DeD7IeA9PU2yNskQdvvMTKIDs7j2+xXzKL6nmbHSWtr9kRzEXbUL 6zw+Q0ZIiQ6Xx3uALI/Bj/kiid1ZrbeLvYokvV5kTUARTOnErnZP+FfAe84QmGzu8G3H u4opkQgAP+i1+039go+IaU8O6j6gV0jWwdL70YmuLn+b6vm1kbxwMaJnLZzUttj06t0Q Bmgz9Bav3ViGCJYH/jygsRDnAPDYBxgcum1WCP7V9T05z6MwM2rIDqtQ2ixT5dsy1czW 794w==; 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=m70Z2LSA; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.10 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=1720771658; x=1721376458; 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=dl422h7V8FKPczYl0wg+Vmwk8xee4EevOkrX4hD5Ok0=; b=qXGAVi7xdQLg/LpLi9/WPA3V6xddeiDC1Sog2fgGSFyrhmAcNkG2vRJF3fxTD/Oefp 0DG2CiRqyz75l9RPkYunIuZwHBx9maO6CkKxVSMp4/Ptax9h7HaXBh4SLAv/s99kUrcV dd/4vtZCXDPmK3mvhYm8/dGivKm0ykDv+wuvnwt3p5JedtpIF6tDxdXRWWS86I6GBuPn Fg9rNLs9duYBxOdwUP+Et0YZ9ut45sbqZ1/5kbauVJuna7D+pwQnwL3EfeUF88AYuwZO ZrOh6dvwl1wi3izYk0+Cd8zM8Z/SEPouJUemjAI2H1YgU4SM7FkSxE1EQkPFjbi3479s d7+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720771658; x=1721376458; 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=dl422h7V8FKPczYl0wg+Vmwk8xee4EevOkrX4hD5Ok0=; b=egfCOLKUblnbyTuiW2gJoXfzc6+dpS0gU3vZ6+CS5rOO28njjW68c6mAzADLRonCgg u+bAj3rZgQIWboF1jlTktEd+vJiO53OjEFNIAF2ZSlQnmDbFU2BL1zmmIqxsiV6HucHT GcwHSo+67zeNX68HWbEHYwQY/cbxDir8gxJ6JazStNn3OS62pnRnTr7gDwiSxiCNDQbc cx7ZAO2CPSu0+i0NgJL4GGew21DlTzvhBveb3JYg9tS815ILo6VPii9foAmrCsIYr+nU IVhJupP9Tx8RdV+AbAIiE7W+RWhheo4QFXDft3yHT+1BUanJR+ssFf3o/xKCfoMiUQHr 41FA== Sender: swupdate@googlegroups.com X-Forwarded-Encrypted: i=2; AJvYcCVGCwD68zvgN+RJ4MmG3mkTwFkm5+DHhKedOdkaLIfu28kWR4z3776/JKaxOBowCn2bFWbc/lD6VEqAfa3tG/oaaVkb4MIUk6fN9UCWWQ== X-Gm-Message-State: AOJu0Ywgw/9Ao+i09R+62isvUjI7ssn/JsW49Wf/d9up7Pa7GhMNnLH2 KY4eXO/yljRAUD6PBqlo3PUb9OspzURoIfKSvDhdduk+uNXcIotn X-Google-Smtp-Source: AGHT+IGOQRt515ozvLxXHxmWrRpLo+7yfhSjIvQUBZMx9gJpGyUmpOnb3IVHPwhodfnGNIxNomAuLA== X-Received: by 2002:a2e:2e10:0:b0:2ee:7255:5048 with SMTP id 38308e7fff4ca-2eeb319872dmr70838941fa.48.1720771657395; Fri, 12 Jul 2024 01:07:37 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:651c:31a:b0:2ec:43dc:d0a8 with SMTP id 38308e7fff4ca-2eec938fbeels8747571fa.1.-pod-prod-07-eu; Fri, 12 Jul 2024 01:07:34 -0700 (PDT) X-Received: by 2002:a2e:9317:0:b0:2ed:59af:ecb7 with SMTP id 38308e7fff4ca-2eeb30e5104mr66824781fa.15.1720771654267; Fri, 12 Jul 2024 01:07:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720771654; cv=none; d=google.com; s=arc-20160816; b=kAfEI93FJ6hliuvbn9sN9vfQ1JPEFXt/vcceUeD27uu/IxOkP+qwkdHonSFoKa9QZX LZEXpZW2/x0MDBuj0rgMZq84OSmZXrQKeK7jnLVUDlgAFDX9Z7aB4rlj3/kUVGNvY5Az eZ2+UWqA9YTdDkhEXtUzYEeTqfN/WFMt1MuCtsmPhIUraVPfQjZFha4wshdOtZ2a6EGh 0dtT2catItJWMp61daRd6H/pBTlGHO7m+qID4QyLIbPNmkQKg8SDIH+TnU/8TJTlj6Zm nAqoMQsVGeV6nVUbuJsk7BjX7kAByQnp0CnbyOQfvPK83q9IdM0mGgAp2m3WZ1tsw72j Zo7w== 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=X/Dd9608vtTtkgdgVuy5aaD+v4a/QDnWXbo8kfYcvUY=; fh=B1tLJRnpVURVF77rcFTt56FaA+ftMwJCVZP7QR8V05A=; b=MqNrlVeNEcvDpWTGSxGGZPRV3YNe7jeiToiTDu71WLAUuANpRxGBsU/9mTZwm9+R+E KFhTpNpEJ7A66Oc1pGTRV8hW1y6A44okWsB4vGxLBdKJSztNomfGaNMpIC0XLDrx76cp HXlGiqYrt5UnjNAL4na3RtGCCEz6qYQ88WoTgvIU2RDaS0UcpEqE7tsh4JwW+aeHKgXl Z+0XRd+x1Nm7vjh/GvGL7/n/Z9aUfRhBgy7fctW+AeDzGscQPwXSDm4XS3I1INIEQFcI pL2n73jeBWzjk6nke8UCZv6Hkqo//HNCT0WufmPKN3RvHB4TiWsTp9SjbYIQrbhD/jUr 9IAQ==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=m70Z2LSA; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.10 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Received: from mout.kundenserver.de (mout.kundenserver.de. [212.227.17.10]) by gmr-mx.google.com with ESMTPS id 5b1f17b1804b1-426740d995asi4779435e9.1.2024.07.12.01.07.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jul 2024 01:07:34 -0700 (PDT) Received-SPF: pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.10 as permitted sender) client-ip=212.227.17.10; X-UI-Sender-Class: 55c96926-9e95-11ee-ae09-1f7a4046a0f6 Received: from paperino.fritz.box ([88.217.136.221]) by mrelayeu.kundenserver.de (mreue109 [213.165.67.113]) with ESMTPSA (Nemesis) id 1Mdvyi-1ruUip2vFG-00bNtG; Fri, 12 Jul 2024 10:07:33 +0200 From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic , Christian Eggers Subject: [swupdate] [PATCH V3] handler: ubivol: relax accessing UBI volume Date: Fri, 12 Jul 2024 10:07:31 +0200 Message-Id: <20240712080731.2238837-1-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Provags-ID: V03:K1:92lp9xLJPB2AmsKrsnYWSZBWYalSLsoHUE2Q2VzUSZhJ22btA9x mmqKkfYbrRE/SQ1j5B+PR8VHpojW9Yo0VC2xaIlaoJaEWn2wbQofqWg3NG85PbHrGVdmxwt mFkgltarTElxoOJBcn9OAaFIFuyHELa9ktfK2pBNp2OJNbpC7Hcr06c8EvghbH3Cl+4Ugsp xfjjhbiW6jdCzmiHxAo0g== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:9bST6ClFWec=;EX25MDUEhkqz5jD4pWsz8Iluztc mj/La69PWSpNs+OCMaQWQysfsJpIo70hqYze6x8/LkmKPc8Qixcrqy2xzdkH4eI7s1sP3XLrQ YH1tm5UkwxOjT8akNAbNLM2YI+j1hsDOENKpw9k4Pn6aZ6bRglR/JQ6y4UAt134ohvGy0nJr5 R5gUT/KkEG4wPB1VFiPd/uYHST8jaDtbUOIEV5N0ZvvQJspbNkrZVvGniGqjie1b7zRQtbvrn GwCI4FjrTpsq4GrnHE5V5iN38O+lHfUFXafDSVHH06gkn6UOe/HiLOV4gJoySHechjR3V6B0W pKzu62QD6clR3e7heNA77Ufe2jjR0di32fnZbaBND/SZwv0riMbXsQBqkdhYdCcSKlBwrwDfA DN/cO/TdmUm1hEUQ7ixxupCp68QnGgXyBKFEbINtvofeDMyak2Z4KBBQX57WspBXq2vxRfObu okfesH43m6sktm/Zf/+WtmK7i6kKyyhDYLyCRS5B6EbNjxcO3uHRdSvU8zCb13yApOAMB/6S0 dFk2/h9je0Tjfz91PwuEjtkWP1mUQYH6FKNjsEED+zLLb1dWaR03jWf4N+dIf3QVFzpw4fe6q 1mSTQ4vpccYcok0SobF4qjHlFLZg+JgXqvlYkII95aAXZYHfTUA9w26ucSsOaazOUCZ6y1Y8M CPNjUZBivc/Aqu9AenExyWTb4glGYDxxF0GYJLYdXAe5vCecJnq8kbUzVRyjVI5l94U93AKdD hYcqEMQU36kC67Mz+4GJnOA8+y+fiLBPQ== 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=m70Z2LSA; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.10 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 Tested-by: Christian Eggers --- handlers/ubivol_handler.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) Changes since V2: - check for EBUSY Changes since V1: - fix comment - add missing close() in error case -- 2.34.1 diff --git a/handlers/ubivol_handler.c b/handlers/ubivol_handler.c index 0ad0321e..bf1ec00a 100644 --- a/handlers/ubivol_handler.c +++ b/handlers/ubivol_handler.c @@ -248,9 +248,30 @@ 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, errno can be checked + * for the source of errors. + * This should be changed in case ubi_update_start() + * will do own error recovery in future. + * Simply retries in case of error if the volume + * is accessed by another process + */ + err = ubi_update_start(libubi, fdout, bytes); + retries--; + if (err) { + if (errno != EBUSY) + break; + WARN("Not possible to lock UBI, retry"); + sleep(1); + } + } while (err && retries > 0); + if (err) { ERROR("cannot start volume \"%s\" update", node); + close(fdout); return -1; }