From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AC056C2BA16 for ; Wed, 8 Apr 2020 14:51:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 786DE2082D for ; Wed, 8 Apr 2020 14:51:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dYPQOqKq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726709AbgDHOvh (ORCPT ); Wed, 8 Apr 2020 10:51:37 -0400 Received: from mail-io1-f47.google.com ([209.85.166.47]:45720 "EHLO mail-io1-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727612AbgDHOvg (ORCPT ); Wed, 8 Apr 2020 10:51:36 -0400 Received: by mail-io1-f47.google.com with SMTP id i19so246020ioh.12 for ; Wed, 08 Apr 2020 07:51:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=9lOsuvSeby8kvzpQygwGXUOd+vqDt6XltsVMYcXumzE=; b=dYPQOqKqpz5VeLNTzoJZZI4ZLprPwfCEhs0UAFzkzQohZKXsbUWuxUD/k0eQYwi97M y+Ytc/oOc4nE0P6nL7sO50AROJhJCcYesoFQuUzpGeXGqoNyVHMBVWemcS8m1vYSYBEt xsiqL2uQHUdEbtFoMK2sOnscyzRsge/M4dfDELATxUoU7pl5Pt5HsFI7/J/usXdEepjA H1gVd9lR88Stg+W+WgihuAYl6P2D57rtrfVt8ZIPeEWuHL4vqyIWeJ+f/m5oIOjJZilJ pt4JqG1XCy4AdGDDXl2zzPHEDUd55/Y7bUCZVkMwidkZjQsqp9T0hWcu7WYHBC/QTcY2 LXTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=9lOsuvSeby8kvzpQygwGXUOd+vqDt6XltsVMYcXumzE=; b=cq2A4LudNw8a+S3Wgc3tPGJ+TtV+zxeC7jNH7h2N8Qy5E9hOnV7weXqZ8MSUKOm27z 7Z0HvElH96JrssXQTUFGidyU1LadaoMkQdkqJxs5fM59e84kt/94UO/1zIApn3L8EjK7 Ml1iKsgoBAs5cRpq33KCthGXbBXYKgSrqOHLUKTn4Qg8rWuu7kRt0P0fLIWHV9qmWqCs RHg0NVzagwm/HADYhJU9Oj1F1XXinup/roJAOjBfAt1OaRpfYVS1N0umJ0l/A4rE3yDk 9ULc8ykFzkC8Dy5bJmDpS88uarOmm+meKXqsxhm4XB5zl8N9HGz0HFpA28VaPImhi2mS F+/w== X-Gm-Message-State: AGi0PuZ47BfQdD4+k0jynno+d6q/raGRYMWBrOYU32j0Y+Hfit/H3CVl /jhATQfTGSmF65A8PypZPouDUk0KFNM3irAUmGuXdKj/v4A= X-Google-Smtp-Source: APiQypI5+ZvaB7sBaGKm2RMu+mF+pQj+XSQ0cGCZGfJxn/j3tRK1tgFejX9DdrJmdPl4wX6U0paF8DgqWZjnlOTOXuw= X-Received: by 2002:a02:2944:: with SMTP id p65mr101858jap.89.1586357495510; Wed, 08 Apr 2020 07:51:35 -0700 (PDT) MIME-Version: 1.0 From: Dmitry Kadashev Date: Wed, 8 Apr 2020 21:51:23 +0700 Message-ID: Subject: io_uring's openat doesn't work with large (2G+) files To: io-uring@vger.kernel.org Content-Type: multipart/mixed; boundary="000000000000020c2305a2c8a3a1" Sender: io-uring-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org --000000000000020c2305a2c8a3a1 Content-Type: text/plain; charset="UTF-8" Hi, io_uring's openat seems to produce FDs that are incompatible with large files (>2GB). If a file (smaller than 2GB) is opened using io_uring's openat then writes -- both using io_uring and just sync pwrite() -- past that threshold fail with EFBIG. If such a file is opened with sync openat, then both io_uring's writes and sync writes succeed. And if the file is larger than 2GB then io_uring's openat fails right away, while the sync one works. Kernel versions: 5.6.0-rc2, 5.6.0. A couple of reproducers attached, one demos successful open with failed writes afterwards, and another failing open (in comparison with sync calls). The output of the former one for example: *** sync openat openat succeeded sync write at offset 0 write succeeded sync write at offset 4294967296 write succeeded *** sync openat openat succeeded io_uring write at offset 0 write succeeded io_uring write at offset 4294967296 write succeeded *** io_uring openat openat succeeded sync write at offset 0 write succeeded sync write at offset 4294967296 write failed: File too large *** io_uring openat openat succeeded io_uring write at offset 0 write succeeded io_uring write at offset 4294967296 write failed: File too large -- Dmitry --000000000000020c2305a2c8a3a1 Content-Type: text/x-csrc; charset="US-ASCII"; name="test-io_uring-write-large-offset.c" Content-Disposition: attachment; filename="test-io_uring-write-large-offset.c" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_k8rg0xau1 I2luY2x1ZGUgPGxpYnVyaW5nLmg+CiNpbmNsdWRlIDxzdHJpbmcuaD4KI2luY2x1ZGUgPHN0ZGlv Lmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1ZGUgPHN5cy90eXBlcy5oPgojaW5jbHVkZSA8 c3lzL3N0YXQuaD4KI2luY2x1ZGUgPGZjbnRsLmg+CiNpbmNsdWRlIDxlcnJuby5oPgojaW5jbHVk ZSA8c3lzL3Jlc291cmNlLmg+CiNpbmNsdWRlIDx1bmlzdGQuaD4KCnN0YXRpYyBjb25zdCBp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VyaW5nX3F1ZXVlX2luaXQoUlNJWkUsICZyaW5nLCAwKTsKCWlmIChyZXQgPCAwKSB7CgkJ RElFKCJmYWlsZWQgdG8gaW5pdCBpb191cmluZzogJXNcbiIsIHN0cmVycm9yKC1yZXQpKTsKCX0K Cgl0ZXN0X29wZW5fd3JpdGUoJnJpbmcsIDEsIDEsIGRmZCwgImlvX3VyaW5nX29wZW5hdF93cml0 ZV90ZXN0MSIpOwoJdGVzdF9vcGVuX3dyaXRlKCZyaW5nLCAxLCAwLCBkZmQsICJpb191cmluZ19v cGVuYXRfd3JpdGVfdGVzdDIiKTsKCXRlc3Rfb3Blbl93cml0ZSgmcmluZywgMCwgMSwgZGZkLCAi aW9fdXJpbmdfb3BlbmF0X3dyaXRlX3Rlc3QzIik7Cgl0ZXN0X29wZW5fd3JpdGUoJnJpbmcsIDAs IDAsIGRmZCwgImlvX3VyaW5nX29wZW5hdF93cml0ZV90ZXN0NCIpOwoKCWlvX3VyaW5nX3F1ZXVl X2V4aXQoJnJpbmcpOwoJY2xvc2UoZGZkKTsKCXJldHVybiAwOwp9Cg== --000000000000020c2305a2c8a3a1 Content-Type: text/x-csrc; charset="US-ASCII"; name="test-io_uring-openat-large-file.c" Content-Disposition: attachment; filename="test-io_uring-openat-large-file.c" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_k8rg0xa10 I2luY2x1ZGUgPGxpYnVyaW5nLmg+CiNpbmNsdWRlIDxzdHJpbmcuaD4KI2luY2x1ZGUgPHN0ZGlv Lmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1ZGUgPHN5cy90eXBlcy5oPgojaW5jbHVkZSA8 c3lzL3N0YXQuaD4KI2luY2x1ZGUgPGZjbnRsLmg+CiNpbmNsdWRlIDxlcnJuby5oPgojaW5jbHVk ZSA8c3lzL3Jlc291cmNlLmg+CiNpbmNsdWRlIDx1bmlzdGQuaD4KCiNkZWZpbmUgRElFKC4uLikg ZG8ge1wKCQlmcHJpbnRmKH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