From patchwork Wed Jul 10 09:58:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1958790 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=m0tcSvp9; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::137; helo=mail-lf1-x137.google.com; envelope-from=swupdate+bncbd2zdgn6sekrbrnwxg2amgqey5s5tvi@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-lf1-x137.google.com (mail-lf1-x137.google.com [IPv6:2a00:1450:4864:20::137]) (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 4WJtbd5DBTz1xqc for ; Wed, 10 Jul 2024 19:58:37 +1000 (AEST) Received: by mail-lf1-x137.google.com with SMTP id 2adb3069b0e04-52e994d8e26sf6298280e87.2 for ; Wed, 10 Jul 2024 02:58:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1720605510; cv=pass; d=google.com; s=arc-20160816; b=lbOXkjOc75me8jE/ca16ieAYAO9nH1VdRX3ux/itDwHiDNZcquolpnys5J/3rKLXDK f2VB3nkSZTknS/7m9d4I5uT+qLfjPeDeSwNius4Gxcrt5yKvxhHvGx0LzmNRPefvkQFp nWraqlvxgOJ2nhfKRByfuCBMNOWfNbbuG7uccuijJmIDFVhrnlcO6+6D/qWqmvbQ519l GP0hOEVg9+PnW+al3gc1v3cv2E/gUQhiik2NGNbvX7H4ZqljxNFBp9FDNMNzSy/FJQiz EeEXkDZJeueVtZ/asOVQZ0C+L+ml5HMquXEeVFkGOrSTcK2zOs5J/EPtRpt26dEUYLia jvIQ== 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=czI6km2XvcUYhdVC4ehR8r06szfUMmVn+VbrkBGmR30=; fh=nn7lrXNQheiMGU4Gl84wfYn57F9dRC9MvAcHlHKVZWQ=; b=nM9tIUrfunCyWGtJzLYXA2wnKtW+F6VZwBp1bVJL4p+negq4udwmYgJCVrgKWelWrX B4avKOsHvk94JiD3Eqc6mkf6lHtWVuClZ+zRAPJONM9FPoYQPn0Kfot0yESdu78SW9WL QE35JU3fH1G16Yv2zVukXHTBBj5vg7b6L7KaagPzTlyfhuQV6Dqi/5iJZe5f0ygxVmFP Hb1IcODFGSVkOsDT6KQIclskc7r7BD42mW1A/rBeLMGN1XYsT0SCGiskNj5k3KiXqSu7 wxmwiBb5PNZIFseP0yVdz02CMa53sCYq471TcE8viM4HfYDGDF0KiZScZdTqAclW/F4i yKTQ==; 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=Fo8MEBF9; 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=1720605510; x=1721210310; 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=czI6km2XvcUYhdVC4ehR8r06szfUMmVn+VbrkBGmR30=; b=m0tcSvp9yrE2RaHu5HlH8RoJJ0v4UzdahVMgrdbUc3Cm3icBfn31vw0qeO86TVVU7B GqrbiByUG+yMsmRVvVHEjJnNavQPJEEeOthfvjQInP7/AM5n2U5QHHNp/syfGE9TJErd BE5Y9DDAOycVku4x0yrdWD/Lpf08/ebdaB8akPjHBlhXn3P9M0mAoRv8WkngnbkP+TVm Pme19QxXFB6S0z9JNdkyEoi1Veh3kmHdO2vyfROjlZeftpRLcSkQXu/kQQnY4K/jGp32 LLA1PpUvnptEIKZK7boYUV0bjSTnoziWsSGCyxQm7fZYCCBEpmqeqZvtl8vT+7x4kaFD ZVQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720605510; x=1721210310; 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=czI6km2XvcUYhdVC4ehR8r06szfUMmVn+VbrkBGmR30=; b=USSV2ZLL0yoJEuyBw13EbeE1Bzg+VT+U9NTwA78qUYXhl04gJ9o3PVvAVsV1ghcmTz vkBUt1TUSg2U697o9xNvHG8V7ADhD8CKza2mjw5HUUHd08fQxqUVlOPOo8cmLwPfX4YE K+rYBFhntlIRRYHDYWush4twQJ5eZbQfX37O1Z10NTNHzFp2hosprXn9k4QtrThYy5cW eUEBNG2Z1dp/eebAtWnX4j8RqLEVQLoQxwTULqOspwjWZzSPhgUrDnGYpX3v1Qo5RPpC kL2Lb1vz52eMvQjzASkjXqD7J2WPJ51oYVuRuFKfhvMo9gSmKxBc6YU5yf1cnat1Coup V+LA== Sender: swupdate@googlegroups.com X-Forwarded-Encrypted: i=2; AJvYcCX37Kmcge7c6tRyqXhJculXZWgszZMC6YtLxKlsSIfoT9rd4zKP/ZMO+XfyiEDYFB9FPy2qhinG4TG1ZMbFlfB2XQLrSK9LsIs+wpDgPQ== X-Gm-Message-State: AOJu0YzKs09Yo60zKASGTzjUWI9BDMs4HNjAXQqPLegvJzB6bHLYpLQh nDOa4O3ZbZvAwT9K1kBsSgkgbFhdjKKrmfuxggYVoMfcnn1ISsEm X-Google-Smtp-Source: AGHT+IFrEeZfTYxN1OpLqbA2H7q1QTOREfFaRLHDnhkgP0V09xjqkEInYBeD2RO8sA9RUVjXGr9SdQ== X-Received: by 2002:a05:6512:3d01:b0:52b:88c3:b2bc with SMTP id 2adb3069b0e04-52eb99d151bmr3961880e87.48.1720605509809; Wed, 10 Jul 2024 02:58:29 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6512:3496:b0:52c:dec2:ccf4 with SMTP id 2adb3069b0e04-52e9f30cbd6ls1239250e87.2.-pod-prod-01-eu; Wed, 10 Jul 2024 02:58:27 -0700 (PDT) X-Received: by 2002:a05:6512:3f14:b0:52c:812b:6e72 with SMTP id 2adb3069b0e04-52eb9990cafmr3490127e87.1.1720605507003; Wed, 10 Jul 2024 02:58:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720605506; cv=none; d=google.com; s=arc-20160816; b=V9y1hPi1PPSI2r81dDq5A+DXyRGg5OMf+KVFLyq+2E8IEXSqIuFdzT7YmziKBhw9pr zo6EOShoCxD0AVN8/Tw3PCfm2A3EcdFb930qCo+mi2SAqIO88OEzX/vqIauHkzhuw8SH hzCFQSMh3T9QSALwYcjt1phUH/y02U04Qcs5KBvQDaCTaIXPLjYMNDb7p6Loew0rSLtd jzVuSr1iLa/j6LBgIMBePm6DI8TzUVw3RRo6yFh8s4af8fb7XhBVjPw6yTxvXTxq2Si6 gF/1Hmg6eClZhoG3m/MkURgy5Z2AUbFBs/dFFxjnTGn/k9ElpfbCVhIt9AZeoClHHRGc +52A== 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=WGsMPvziQtIAE0+FxLKjWQKfvtyhEPgERJAbWuR17Zw=; fh=B1tLJRnpVURVF77rcFTt56FaA+ftMwJCVZP7QR8V05A=; b=I4XErXru9MTiIpY8uGcJce0lo/oDX4WUXJYVIALOh8CogEmFmiwQ592PchzHxZCAmj OWYgSjjN2dcQAoor7VTT4AooJG6EuoKz/hkq2/LSY/nT+zOxXXktg/42XscrOIK2QFo/ FyZZCOrWzbdEMfoW6qq9BBYQwx2hfy8lXHKUTCpdpzv+6lSkHxDpkHRLPwbzZJPh9wzf SWhlwYrb7bP7gmHy34EwMko/CXFzzrAvPz1q+F8/CG4bKV7SJaQMXHkrlcmSvJnPWYk2 2ipdUF0ShGl88IdFO4WAq1Sg2r82OkVpBjM4AN1gcxZWHGsoRSypk4XhodsFFMFBPFtR 2/ng==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=Fo8MEBF9; 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-426740d51e7si1462885e9.1.2024.07.10.02.58.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jul 2024 02:58:26 -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 (mreue106 [213.165.67.113]) with ESMTPSA (Nemesis) id 1MWSJJ-1stkCH1Zf9-00IDqd; Wed, 10 Jul 2024 11:58:26 +0200 From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic , Christian Eggers Subject: [swupdate] [PATCH V2] handler: ubivol: relax accessing UBI volume Date: Wed, 10 Jul 2024 11:58:19 +0200 Message-Id: <20240710095819.132389-1-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Provags-ID: V03:K1:vtGwxTjhE5XCje+MHPugTwIwS8GxFayErMdJKa8JJR8HT4XE81s w/N2I8OAMK4yCe/DDfE5MJTbbn4iyWXstWYfHA7Da0FaYk9f4gB3/EOkI723G46W8c7qBj0 s2JL6jycMJ8TJDTtW1k91Mt+bvBnF1prZmZ7T6PMC93qyxjzOhTUzjEGxUbpk54nzabfWvv BDIW+jxH2avSu4FetQLbA== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:gHTObRQg9Og=;ovJ1mCNilvuI6l1p7/doKHYH2VJ joQ9MVxsMfJBPzgJpb9UBiXKpwryvA2Nmw7FEMxa/YEq8ZRFHEPx5sPfWteTpg7Hmszyxt17Y URe5XTuu6ishyKfdDM5lm1X+oNkaa/I8uencBKRWpqRUs1GJEesNRcHifAHlYiieollPIr3SJ qRPhvAohjWgU7H13kDRVMyHWPp4dYbo4XKIVvPMPtIMfWZT6YUTfGaDnc/uhMjKDPXpo7VXq9 CduLrHKPQjRdjOjMrJYr+RSfrnFIqESf7jsIcomKISxA+yPbs1V/CkYOHrrzncsE1u3pXEmkn VIkTmciPH2HDsYh9WAEIJRwFln4Fu08xiD1zZc8p+e1xBbrqGQh3H1imjx+0LXjKrjDGwu08b GeaAlOPMt8gPs0nPgE5X/6oU7vdq8FMtJcdK6yHfc94zfgicw9YXMO+eA9Ito0fFuDGxFS6/y K43as5axep7NfQ7ywSs/pg4p+FZbdHlg3dYwYsOJ/bantlgtGoITqnsa/R25FivDDcYAhE+bP A2ieYdXrz5McKjrtjkFBq3f19cjRyl33MTOxKiEUnbMPm7YmwpzINbFacH3zD0WiiZltQlY5y 8/UdfDm5Tjpfk3NH+FrZ7O8bp31mp4nBzxkxh2k+/8ZnnOuoF3G3EzAbl4j8jOLoEQ2VOiSan oENoFIvDrpWt5/6bcXgKbdFH8JEGb5o+o9VMKapHhmUlWTSXeUaP3Yb0FoZek9QR72mX9yynx g4kL3dwD16fkOsuJAWgjqRLWQEIrrxRoB9B5UpOw6zwhE+nl+m7toM= 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=Fo8MEBF9; 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 --- handlers/ubivol_handler.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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..09b297cf 100644 --- a/handlers/ubivol_handler.c +++ b/handlers/ubivol_handler.c @@ -248,9 +248,25 @@ 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 + * is accessed 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); + close(fdout); return -1; }