get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/2216952/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2216952,
    "url": "http://patchwork.ozlabs.org/api/patches/2216952/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/ltp/patch/20260327122237.8071-1-wegao@suse.com/",
    "project": {
        "id": 59,
        "url": "http://patchwork.ozlabs.org/api/projects/59/?format=api",
        "name": "Linux Test Project development",
        "link_name": "ltp",
        "list_id": "ltp.lists.linux.it",
        "list_email": "ltp@lists.linux.it",
        "web_url": "",
        "scm_url": "",
        "webscm_url": "",
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<20260327122237.8071-1-wegao@suse.com>",
    "list_archive_url": null,
    "date": "2026-03-27T12:22:37",
    "name": "[v7] fanotify22.c: handle multiple asynchronous error events",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "6eb21d758cd7671855ac265e4c18506c04d5218d",
    "submitter": {
        "id": 85577,
        "url": "http://patchwork.ozlabs.org/api/people/85577/?format=api",
        "name": "Wei Gao",
        "email": "wegao@suse.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/ltp/patch/20260327122237.8071-1-wegao@suse.com/mbox/",
    "series": [
        {
            "id": 497758,
            "url": "http://patchwork.ozlabs.org/api/series/497758/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/ltp/list/?series=497758",
            "date": "2026-03-27T12:22:37",
            "name": "[v7] fanotify22.c: handle multiple asynchronous error events",
            "version": 7,
            "mbox": "http://patchwork.ozlabs.org/series/497758/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2216952/comments/",
    "check": "success",
    "checks": "http://patchwork.ozlabs.org/api/patches/2216952/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it>",
        "X-Original-To": [
            "incoming@patchwork.ozlabs.org",
            "ltp@lists.linux.it"
        ],
        "Delivered-To": [
            "patchwork-incoming@legolas.ozlabs.org",
            "ltp@picard.linux.it"
        ],
        "Authentication-Results": [
            "legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=lists.linux.it header.i=@lists.linux.it\n header.a=rsa-sha256 header.s=picard header.b=Qe9KSugE;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256\n header.s=google header.b=g4Gjep23;\n\tdkim-atps=neutral",
            "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it\n (client-ip=213.254.12.146; helo=picard.linux.it;\n envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it;\n receiver=patchwork.ozlabs.org)"
        ],
        "Received": [
            "from picard.linux.it (picard.linux.it [213.254.12.146])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fj0CY3rHMz1xy1\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 27 Mar 2026 23:22:49 +1100 (AEDT)",
            "from picard.linux.it (localhost [IPv6:::1])\n\tby picard.linux.it (Postfix) with ESMTP id 2733A3CFAA2\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 27 Mar 2026 13:22:47 +0100 (CET)",
            "from in-5.smtp.seeweb.it (in-5.smtp.seeweb.it\n [IPv6:2001:4b78:1:20::5])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature ECDSA (secp384r1))\n (No client certificate requested)\n by picard.linux.it (Postfix) with ESMTPS id 0C8643CFAA2\n for <ltp@lists.linux.it>; Fri, 27 Mar 2026 13:22:42 +0100 (CET)",
            "from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com\n [IPv6:2a00:1450:4864:20::42e])\n (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by in-5.smtp.seeweb.it (Postfix) with ESMTPS id 57B8F60093F\n for <ltp@lists.linux.it>; Fri, 27 Mar 2026 13:22:42 +0100 (CET)",
            "by mail-wr1-x42e.google.com with SMTP id\n ffacd0b85a97d-43b9d3ebed5so692869f8f.1\n for <ltp@lists.linux.it>; Fri, 27 Mar 2026 05:22:42 -0700 (PDT)",
            "from localhost ([2a07:de40:b240:0:2ad6:ed42:2ad6:ed42])\n by smtp.gmail.com with UTF8SMTPSA id\n 5b1f17b1804b1-48722c95041sm87164505e9.6.2026.03.27.05.22.40\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Fri, 27 Mar 2026 05:22:40 -0700 (PDT)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=lists.linux.it;\n i=@lists.linux.it; q=dns/txt; s=picard; t=1774614167; h=to : date :\n message-id : mime-version : subject : list-id : list-unsubscribe :\n list-archive : list-post : list-help : list-subscribe : from :\n reply-to : cc : content-type : content-transfer-encoding : sender :\n from; bh=5wUQ6IqdJE6dFcByrQKKF/xoz2cH9bBSG2AigdxB8GM=;\n b=Qe9KSugEjddfaLXwMAwwZjCwIK7e44cZJATjkJ8dA5dO2fOS76ws2KNwDWmL++tmLS89L\n uHUKYo4w7OPKZDFvyKsRwc9ra5pmJSE4CFtkAHnFmoR/tixsroiT/CS3TBa5x7LC+8vebIH\n aNP78cvc/VEuPgu8vuRYaqxMJ4PNuvQ=",
            "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=suse.com; s=google; t=1774614161; x=1775218961; darn=lists.linux.it;\n h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n :to:from:from:to:cc:subject:date:message-id:reply-to;\n bh=lu/2YxRnmTvIj2IwgKGo9VotoSd6iIiGO6UmNY1m/gc=;\n b=g4Gjep23j8JxrsalZfrSqvGdKHV+/2SrMBQ4jQtL62DiQwqmVQ/FgPJMlTfIufEjVZ\n WLKMvnfE/nB+g0Rr6imOHatMSE9jsrqAR4ixCcccRjPN/jUX9tcYSogjnpVm9kVjawyV\n JEZOhuaxlkGm5klxQH3g8zEd5E27Oo9MUDS+h2qJEzwu0udMzM25dmpy6XiPj0f0xK/0\n NGFXgaCELjrisq0lmbVKLDflWYNqbA4zgstUUVJkr1OUXSUqqmVCA/YGChSdpVNumosD\n 2pAdIKpE4oHIywaPljiBH1BzAR3dXYLF8KgeZ99MX5S5957JggTeqgGXQvV7AEACF5hD\n Rpzw=="
        ],
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1774614161; x=1775218961;\n h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date\n :message-id:reply-to;\n bh=lu/2YxRnmTvIj2IwgKGo9VotoSd6iIiGO6UmNY1m/gc=;\n b=VWvdBFPc0LhdCmFEiv/TmB3j/0ktKDmzB2WAn7OQD9alcG4bYOrIa+pC4o+tcHeJIj\n +OpRb9B4uFceKYHWNqk6NWS8XwNgKPmEvMYxU4afkGmBG8B3lRzO+1tjoIl7O1CPQlHi\n 7MbvyTNuOiKwzm3w4C117tnbAgaFFkN5pw1Ze1RNuhjASROqQ/q5Z0qllqgWErFByU21\n gHDd6wUu32nuro69Lt9ZSRIuKpi5JXtgOxZ4cmlbJhsxU3HnWL19X7esGZgfmxxcaG68\n tdcjz2NsCOJk9wwaNEydEYVZsjjAb44xSAYLmK5ThNy5CIQsBR65Dfzyfv+NjI8kURT4\n 4ABQ==",
        "X-Gm-Message-State": "AOJu0YyjURRKc6yb20e9e+VnrkS4nzhyZdr+uJEJwl8RwLYUf5uj5BYS\n c9977oeWsl7RLbv/kbrpMzmgD9kWrkWpBQsjS8XGrW+Yi2yDO4qgQFiheU1PXs1rzOFGUqrILmB\n AOU0=",
        "X-Gm-Gg": "ATEYQzzqlgHlR1oyBFW5vBgcvWE+ekno8k2CnkhuK5g5XaR6Ni6pyBcPJoII3u4OPDR\n JebuQTVmXx0x9Z+QBbVTekUwrssVqdSFkR9u5F1xeH3ECdyKIrq4csoZKNyo2EUr+ubSYrs3oRW\n cvbTpMlWOMvEgIqNleliehYxMWv/bANM//U1xFoHT0yqQmDF8w8KQjFN4uXu5/0WyANKofZZ613\n 9+z5czgF+wfQkNGdnHU3RvrpaROZ3Dy/XWv9vfkeVPiV5c284LVNEoYlExIeqFiGLMSVFAqpcOg\n ucZqh5Xj7lfBZDd7OpkYO3xc3xvcGYCJgqV5OeB44ZgBpdv6Ikce+TUNFTHucVk77ff3zTj3mvE\n MaUZKifxwvJJIE+LBinV0iWAB2CKZ13Zo2hqOp4ZbptD7H+1n+DmSi/oc1vkbAqLkqUIOqJP+fw\n YP8w49B8nvcwk=",
        "X-Received": "by 2002:a05:600c:64c3:b0:477:6d96:b3e5 with SMTP id\n 5b1f17b1804b1-48727d59bb9mr41161325e9.7.1774614161289;\n Fri, 27 Mar 2026 05:22:41 -0700 (PDT)",
        "To": "ltp@lists.linux.it",
        "Date": "Fri, 27 Mar 2026 12:22:37 +0000",
        "Message-ID": "<20260327122237.8071-1-wegao@suse.com>",
        "X-Mailer": "git-send-email 2.43.0",
        "MIME-Version": "1.0",
        "X-Spam-Status": "No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID,\n DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS shortcircuit=no\n autolearn=disabled version=4.0.1",
        "X-Spam-Checker-Version": "SpamAssassin 4.0.1 (2024-03-25) on in-5.smtp.seeweb.it",
        "X-Virus-Scanned": "clamav-milter 1.0.9 at in-5.smtp.seeweb.it",
        "X-Virus-Status": "Clean",
        "Subject": "[LTP] [PATCH v7] fanotify22.c: handle multiple asynchronous error\n events",
        "X-BeenThere": "ltp@lists.linux.it",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "Linux Test Project <ltp.lists.linux.it>",
        "List-Unsubscribe": "<https://lists.linux.it/options/ltp>,\n <mailto:ltp-request@lists.linux.it?subject=unsubscribe>",
        "List-Archive": "<http://lists.linux.it/pipermail/ltp/>",
        "List-Post": "<mailto:ltp@lists.linux.it>",
        "List-Help": "<mailto:ltp-request@lists.linux.it?subject=help>",
        "List-Subscribe": "<https://lists.linux.it/listinfo/ltp>,\n <mailto:ltp-request@lists.linux.it?subject=subscribe>",
        "From": "Wei Gao via ltp <ltp@lists.linux.it>",
        "Reply-To": "Wei Gao <wegao@suse.com>",
        "Cc": "Jan Kara <jack@suse.cz>, kernel test robot <oliver.sang@intel.com>",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Errors-To": "ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it",
        "Sender": "\"ltp\" <ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it>"
    },
    "content": "Since the introduction of the asynchronous fserror reporting framework\n(kernel commit 81d2e13a57c9), fanotify22 has encountered sporadic failures\ndue to the non-deterministic nature of event delivery and merging:\n\n1) tcase3 failure: A race condition occurs when the test reads the\n   notification fd between two events. Use a poll() and read() loop to wait\n   until the expected event.\n\n2) tcase4 failure: The kernel may deliver errors as independent events\n   instead of a single merged event, since different worker kthread can\n   end up generating each event so they won't be merged. As suggested by\n   Jan Kara, this patch introduces a consolidate_events() helper. It iterates\n   through the event buffer, accumulates the error_count from all independent\n   events, and updates the first event's count in-place.\n\nReported-by: kernel test robot <oliver.sang@intel.com>\nCloses: https://lore.kernel.org/oe-lkp/202602042124.87bd00e3-lkp@intel.com\nSuggested-by: Jan Kara <jack@suse.cz>\nCc: Andrea Cervesato <andrea.cervesato@suse.com>\nSigned-off-by: Wei Gao <wegao@suse.com>\n---\nv6 -> v7:\n- Replaced read() with SAFE_READ().\n- Added TINFO message at the start of do_test().\n- Removed redundant test case names from error messages.\n- Improved buffer overflow check in do_test().\n\n .../kernel/syscalls/fanotify/fanotify22.c     | 110 +++++++++++++++---\n 1 file changed, 94 insertions(+), 16 deletions(-)",
    "diff": "diff --git a/testcases/kernel/syscalls/fanotify/fanotify22.c b/testcases/kernel/syscalls/fanotify/fanotify22.c\nindex e8002b160..9a555c247 100644\n--- a/testcases/kernel/syscalls/fanotify/fanotify22.c\n+++ b/testcases/kernel/syscalls/fanotify/fanotify22.c\n@@ -28,6 +28,7 @@\n #include \"tst_test.h\"\n #include <sys/fanotify.h>\n #include <sys/types.h>\n+#include <poll.h>\n \n #ifdef HAVE_SYS_FANOTIFY_H\n #include \"fanotify.h\"\n@@ -88,7 +89,6 @@ static void trigger_bad_link_lookup(void)\n \t\t\tret, BAD_LINK, errno, EUCLEAN);\n }\n \n-\n static void tcase3_trigger(void)\n {\n \ttrigger_bad_link_lookup();\n@@ -104,6 +104,7 @@ static void tcase4_trigger(void)\n static struct test_case {\n \tchar *name;\n \tint error;\n+\tint error2;\n \tunsigned int error_count;\n \tstruct fanotify_fid_t *fid;\n \tvoid (*trigger_error)(void);\n@@ -134,37 +135,79 @@ static struct test_case {\n \t\t.trigger_error = &tcase4_trigger,\n \t\t.error_count = 2,\n \t\t.error = EFSCORRUPTED,\n+\t\t.error2 = ESHUTDOWN,\n \t\t.fid = &bad_file_fid,\n \t}\n };\n \n+static size_t consolidate_events(char *buf, size_t len, const struct test_case *ex)\n+{\n+\tstruct fanotify_event_metadata *metadata, *first = NULL;\n+\tstruct fanotify_event_info_error *first_info = NULL;\n+\tunsigned int total_count = 0;\n+\tint event_num = 0;\n+\n+\tfor (metadata = (struct fanotify_event_metadata *)buf;\n+\t\t\tFAN_EVENT_OK(metadata, len);\n+\t\t\tmetadata = FAN_EVENT_NEXT(metadata, len)) {\n+\n+\t\tevent_num++;\n+\t\tstruct fanotify_event_info_error *info = get_event_info_error(metadata);\n+\n+\t\tif (!info) {\n+\t\t\ttst_res(TFAIL, \"Event [%d] missing error info\", event_num);\n+\t\t\tcontinue;\n+\t\t}\n+\n+\t\tif (info->error != ex->error && (ex->error2 == 0 || info->error != ex->error2)) {\n+\t\t\ttst_res(TFAIL, \"Event [%d] unexpected errno (%d)\",\n+\t\t\t\t\tevent_num, info->error);\n+\t\t\tcontinue;\n+\t\t}\n+\n+\t\tif (!first) {\n+\t\t\tfirst = metadata;\n+\t\t\tfirst_info = info;\n+\t\t}\n+\t\ttotal_count += info->error_count;\n+\n+\t\ttst_res(TINFO, \"Event [%d]: errno=%d, error_count=%d\",\n+\t\t\t\tevent_num, info->error, info->error_count);\n+\t}\n+\n+\tif (first_info)\n+\t\tfirst_info->error_count = total_count;\n+\n+\treturn (first) ? first->event_len : 0;\n+}\n+\n static int check_error_event_info_fid(struct fanotify_event_info_fid *fid,\n \t\t\t\t const struct test_case *ex)\n {\n \tstruct file_handle *fh = (struct file_handle *) &fid->handle;\n \n \tif (memcmp(&fid->fsid, &ex->fid->fsid, sizeof(fid->fsid))) {\n-\t\ttst_res(TFAIL, \"%s: Received bad FSID type (%x...!=%x...)\",\n-\t\t\tex->name, FSID_VAL_MEMBER(fid->fsid, 0),\n+\t\ttst_res(TFAIL, \"Received bad FSID type (%x...!=%x...)\",\n+\t\t\tFSID_VAL_MEMBER(fid->fsid, 0),\n \t\t\tex->fid->fsid.val[0]);\n \n \t\treturn 1;\n \t}\n \tif (fh->handle_type != ex->fid->handle.handle_type) {\n-\t\ttst_res(TFAIL, \"%s: Received bad file_handle type (%d!=%d)\",\n-\t\t\tex->name, fh->handle_type, ex->fid->handle.handle_type);\n+\t\ttst_res(TFAIL, \"Received bad file_handle type (%d!=%d)\",\n+\t\t\tfh->handle_type, ex->fid->handle.handle_type);\n \t\treturn 1;\n \t}\n \n \tif (fh->handle_bytes != ex->fid->handle.handle_bytes) {\n-\t\ttst_res(TFAIL, \"%s: Received bad file_handle len (%d!=%d)\",\n-\t\t\tex->name, fh->handle_bytes, ex->fid->handle.handle_bytes);\n+\t\ttst_res(TFAIL, \"Received bad file_handle len (%d!=%d)\",\n+\t\t\tfh->handle_bytes, ex->fid->handle.handle_bytes);\n \t\treturn 1;\n \t}\n \n \tif (memcmp(fh->f_handle, ex->fid->handle.f_handle, fh->handle_bytes)) {\n-\t\ttst_res(TFAIL, \"%s: Received wrong handle. \"\n-\t\t\t\"Expected (%x...) got (%x...) \", ex->name,\n+\t\ttst_res(TFAIL, \"Received wrong handle. \"\n+\t\t\t\"Expected (%x...) got (%x...) \",\n \t\t\t*(int *)ex->fid->handle.f_handle, *(int *)fh->f_handle);\n \t\treturn 1;\n \t}\n@@ -177,14 +220,14 @@ static int check_error_event_info_error(struct fanotify_event_info_error *info_e\n \tint fail = 0;\n \n \tif (info_error->error_count != ex->error_count) {\n-\t\ttst_res(TFAIL, \"%s: Unexpected error_count (%d!=%d)\",\n-\t\t\tex->name, info_error->error_count, ex->error_count);\n+\t\ttst_res(TFAIL, \"Unexpected error_count (%d!=%d)\",\n+\t\t\tinfo_error->error_count, ex->error_count);\n \t\tfail++;\n \t}\n \n \tif (info_error->error != ex->error) {\n-\t\ttst_res(TFAIL, \"%s: Unexpected error code value (%d!=%d)\",\n-\t\t\tex->name, info_error->error, ex->error);\n+\t\ttst_res(TFAIL, \"Unexpected error code value (%d!=%d)\",\n+\t\t\tinfo_error->error, ex->error);\n \t\tfail++;\n \t}\n \n@@ -248,19 +291,54 @@ static void check_event(char *buf, size_t len, const struct test_case *ex)\n static void do_test(unsigned int i)\n {\n \tconst struct test_case *tcase = &testcases[i];\n-\tsize_t read_len;\n+\tsize_t read_len = 0;\n+\tstruct pollfd pfd;\n+\tunsigned int accumulated_count = 0;\n+\n+\ttst_res(TINFO, \"Test case: %s\", tcase->name);\n \n \tSAFE_FANOTIFY_MARK(fd_notify, FAN_MARK_ADD|FAN_MARK_FILESYSTEM,\n \t\t\t   FAN_FS_ERROR, AT_FDCWD, MOUNT_PATH);\n \n \ttcase->trigger_error();\n \n-\tread_len = SAFE_READ(0, fd_notify, event_buf, BUF_SIZE);\n+\tpfd.fd = fd_notify;\n+\tpfd.events = POLLIN;\n+\n+\twhile (accumulated_count < tcase->error_count) {\n+\t\tif (poll(&pfd, 1, 5000) <= 0) {\n+\t\t\ttst_res(TFAIL, \"Timeout waiting for events\");\n+\t\t\tgoto out;\n+\t\t}\n+\n+\t\tif (BUF_SIZE - read_len < FAN_EVENT_METADATA_LEN)\n+\t\t\ttst_brk(TBROK, \"Insufficient buffer space for next event\");\n+\n+\t\tchar *current_pos = event_buf + read_len;\n+\t\tssize_t ret = SAFE_READ(0, fd_notify, current_pos, BUF_SIZE - read_len);\n+\n+\t\tstruct fanotify_event_metadata *m =\n+\t\t\t(struct fanotify_event_metadata *)current_pos;\n+\t\twhile (FAN_EVENT_OK(m, ret)) {\n+\t\t\tstruct fanotify_event_info_error *e = get_event_info_error(m);\n+\n+\t\t\tif (e)\n+\t\t\t\taccumulated_count += e->error_count;\n+\n+\t\t\tread_len += m->event_len;\n+\t\t\tm = FAN_EVENT_NEXT(m, ret);\n+\t\t}\n+\t}\n+\n+\tread_len = consolidate_events(event_buf, read_len, tcase);\n+\n+\tcheck_event(event_buf, read_len, tcase);\n+\n+out:\n \n \tSAFE_FANOTIFY_MARK(fd_notify, FAN_MARK_REMOVE|FAN_MARK_FILESYSTEM,\n \t\t\t   FAN_FS_ERROR, AT_FDCWD, MOUNT_PATH);\n \n-\tcheck_event(event_buf, read_len, tcase);\n \t/* Unmount and mount the filesystem to get it out of the error state */\n \tSAFE_UMOUNT(MOUNT_PATH);\n \tSAFE_MOUNT(tst_device->dev, MOUNT_PATH, tst_device->fs_type, 0, NULL);\n",
    "prefixes": [
        "v7"
    ]
}