drm/i915: set O_LARGEFILE in __create_shmem()
Subsystems (2)
PATCH v2 1/2 drm/i915: set O_LARGEFILE in __create_shmem()
From: Taotao Chen <[email protected]>
Without O_LARGEFILE, file->f_op->write_iter calls generic_write_check_limits(), which enforces a 2GB (MAX_NON_LFS) limit, causing -EFBIG on large writes.
In shmem_pwrite(), this error is later masked as -EIO due to the error handling order, leading to igt failures like gen9_exec_parse(bb-large).
Set O_LARGEFILE in __create_shmem() to prevent -EFBIG on large writes.
---
v2:
- Add force_o_largefile() guard before setting O_LARGEFILE
drivers/gpu/drm/i915/gem/i915_gem_shmem.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/gpu/drm/i915/gem/i915_gem_shmem.c +7 -0
@@ -514,6 +514,13 @@ static int __create_shmem(struct drm_i915_private *i915,if (IS_ERR (filp))return PTR_ERR (filp); +/* +* Prevent -EFBIG by allowing large writes beyond MAX_NON_LFS on shmem +* objects by setting O_LARGEFILE. +*/ +if (force_o_largefile ()) + filp->f_flags |=O_LARGEFILE ; + obj->filp = filp;return 0 ; }
Signature · 1 line
2.34.1
PATCH v2 2/2 drm/i915: Fix incorrect error handling in shmem_pwrite()
From: Taotao Chen <[email protected]>
shmem_pwrite() currently checks for short writes before negative error codes, which can overwrite real errors (e.g., -EFBIG) with -EIO. Reorder the checks to return negative errors first, then handle short writes.
---
v2:
- Drop Fixes tag
- Add Reviewed-by from Andi
- Add code comments (suggested by Rodrigo)
drivers/gpu/drm/i915/gem/i915_gem_shmem.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_shmem.c +12 -3
@@ -441,11 +441,20 @@ shmem_pwrite(struct drm_i915_gem_object *obj, written = file->f_op->write_iter (&kiocb, &iter);BUG_ON (written == -EIOCBQUEUED ); -if (written != size) -return -EIO ; - +/* +* First, check if write_iter returned a negative error. +* If the write failed, return the real error code immediately. +* This prevents it from being overwritten by the short write check below. +*/ if (written <0 )return written; +/* +* Check for a short write (written bytes != requested size). +* Even if some data was written, return -EIO to indicate that the +* write was not fully completed. +*/ +if (written != size) +return -EIO ;return 0 ; }
Signature · 1 line
2.34.1
Re: [PATCH v2 2/2] drm/i915: Fix incorrect error handling in shmem_pwrite()
Going to hit us with a katana, Taotao?
Quoted 49 lines · 陈涛涛 Taotao Chen
From: Taotao Chen <[email protected]>
shmem_pwrite()currently checks for short writes before negative error codes, which can overwrite real errors (e.g.,-EFBIG) with-EIO. Reorder the checks to return negative errors first, then handle short writes.Signed-off-by Taotao Chen <[email protected]>Reviewed-by Andi Shyti <[email protected]>---
v2:
- Drop Fixes tag
- Add Reviewed-by from Andi
- Add code comments (suggested by Rodrigo)drivers/gpu/drm/i915/gem/i915_gem_shmem.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)drivers/gpu/drm/i915/gem/i915_gem_shmem.c +12
-4@@ -441,11 +441,20 @@ shmem_pwrite(struct drm_i915_gem_object *obj, written = file->f_op->write_iter (&kiocb, &iter);BUG_ON (written == -EIOCBQUEUED ); -if (written != size) -return -EIO ; - +/* +* First, check if write_iter returned a negative error. +* If the write failed, return the real error code immediately. +* This prevents it from being overwritten by the short write check below. +*/ if (written <0 )return written; +/* +* Check for a short write (written bytes != requested size). +* Even if some data was written, return -EIO to indicate that the +* write was not fully completed. +*/ +if (written != size) +return -EIO ;return 0 ; } --2.34.1
Patchwork
CI✗ LGCI.VerificationFailed: failure for series starting with [v2,1/2] drm/i915: set O_LARGEFILE in __create_shmem()
In reply to 陈涛涛 Taotao Chen== Series Details ==
== Series Details ==
Series: series starting with [v2,1/2] drm/i915: set O_LARGEFILE in __create_shmem()
URL : https://patchwork.freedesktop.org/series/153326/
State : failure
== Summary ==
Address '[email protected]' is not on the allowlist, which prevents CI from being triggered for this patch. If you want Intel GFX CI to accept this address, please contact the script maintainers at [email protected]. Exception occurred during validation, bailing out!
Hi Taotao,
Quoted 9 lines · 陈涛涛 Taotao Chen
From: Taotao Chen <[email protected]>
Without
O_LARGEFILE,file->f_op->write_itercallsgeneric_write_check_limits(), which enforces a 2GB (MAX_NON_LFS) limit, causing-EFBIGon large writes.In
shmem_pwrite(), this error is later masked as-EIOdue to the error handling order, leading to igt failures likegen9_exec_parse(bb-large).
Quoted 6 lines
Set
O_LARGEFILEin__create_shmem()to prevent-EFBIGon large writes.Reported-by kernel test robot <[email protected]>Fixes 048832a3f400 ("drm/i915: Refactor shmem_pwrite() to use kiocb and write_iter")Signed-off-by Taotao Chen <[email protected]>
looks good to me:
Thanks,
Andi
Quoted 30 lines · 陈涛涛 Taotao Chen
From: Taotao Chen <[email protected]>
Without
O_LARGEFILE,file->f_op->write_itercallsgeneric_write_check_limits(), which enforces a 2GB (MAX_NON_LFS) limit, causing-EFBIGon large writes.In
shmem_pwrite(), this error is later masked as-EIOdue to the error handling order, leading to igt failures likegen9_exec_parse(bb-large).Set
O_LARGEFILEin__create_shmem()to prevent-EFBIGon large writes.Reported-by kernel test robot <[email protected]>Fixes 048832a3f400 ("drm/i915: Refactor shmem_pwrite() to use kiocb and write_iter")Signed-off-by Taotao Chen <[email protected]>---
v2:
- Addforce_o_largefile()guard before settingO_LARGEFILEdrivers/gpu/drm/i915/gem/i915_gem_shmem.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/gpu/drm/i915/gem/i915_gem_shmem.c +0
-0@@ -514,6 +514,13 @@ static int __create_shmem(struct drm_i915_private *i915,if (IS_ERR (filp))return PTR_ERR (filp);
drivers/gpu/drm/i915/gem/i915_gem_shmem.c static int __create_shmem(struct drm_i915_private *i915, · line 526
Quoted 10 lines
drivers/gpu/drm/i915/gem/i915_gem_shmem.c +7
-0+/* +* Prevent -EFBIG by allowing large writes beyond MAX_NON_LFS on shmem +* objects by setting O_LARGEFILE. +*/ +if (force_o_largefile ()) + filp->f_flags |=O_LARGEFILE ; + obj->filp = filp;return 0 ; }
Hi,
Just a gentle ping on this patch. Any further comments or plans to pick it up?
Thanks,
Taotao
Hi Taotao,
Quoted 13 lines
Quoted 13 lines
Without
O_LARGEFILE,file->f_op->write_itercallsgeneric_write_check_limits(), which enforces a 2GB (MAX_NON_LFS) limit, causing-EFBIGon large writes.In
shmem_pwrite(), this error is later masked as-EIOdue to the error handling order, leading to igt failures likegen9_exec_parse(bb-large).Set
O_LARGEFILEin__create_shmem()to prevent-EFBIGon large writes.Reported-by kernel test robot <[email protected]>Fixes 048832a3f400 ("drm/i915: Refactor shmem_pwrite() to use kiocb and write_iter")Signed-off-by Taotao Chen <[email protected]>
...
Quoted 2 lines
Just a gentle ping on this patch. Any further comments or plans to pick it up?
Unfortunately your patch has not been picked up by our CI, now I re-run the test.
In any case, your second patch can't be merged yet because your previous one(*) has been applied to the wrong branch from Christian while it should have gone through drm-intel-gt-next. Now we need to wait for a backmerge.
In any case, if the tests succeed, I can already apply your first patch so that it gets included in the Wednesday's pull request.
While the second patch, that is not a fix, has plenty of time and can wait the backmerge.
Andi
(*) 048832a3f400 ("drm/i915: Refactor shmem_pwrite() to use kiocb and write_iter")
Patchwork
CI✗ LGCI.VerificationFailed: failure for series starting with [v2,1/2] drm/i915: set O_LARGEFILE in __create_shmem() (rev2)
In reply to 陈涛涛 Taotao Chen== Series Details ==
== Series Details ==
Series: series starting with [v2,1/2] drm/i915: set O_LARGEFILE in __create_shmem() (rev2)
URL : https://patchwork.freedesktop.org/series/153326/
State : failure
== Summary ==
Address '[email protected]' is not on the allowlist, which prevents CI from being triggered for this patch. If you want Intel GFX CI to accept this address, please contact the script maintainers at [email protected]. Exception occurred during validation, bailing out!
Hi Taotao,
Both patches merged to drm-intel-gt-next.
Thank you,
Andi
Quoted 42 lines · 陈涛涛 Taotao Chen
From: Taotao Chen <[email protected]>
Without
O_LARGEFILE,file->f_op->write_itercallsgeneric_write_check_limits(), which enforces a 2GB (MAX_NON_LFS) limit, causing-EFBIGon large writes.In
shmem_pwrite(), this error is later masked as-EIOdue to the error handling order, leading to igt failures likegen9_exec_parse(bb-large).Set
O_LARGEFILEin__create_shmem()to prevent-EFBIGon large writes.Reported-by kernel test robot <[email protected]>Fixes 048832a3f400 ("drm/i915: Refactor shmem_pwrite() to use kiocb and write_iter")Signed-off-by Taotao Chen <[email protected]>---
v2:
- Addforce_o_largefile()guard before settingO_LARGEFILEdrivers/gpu/drm/i915/gem/i915_gem_shmem.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/gpu/drm/i915/gem/i915_gem_shmem.c +7
-0@@ -514,6 +514,13 @@ static int __create_shmem(struct drm_i915_private *i915,if (IS_ERR (filp))return PTR_ERR (filp); +/* +* Prevent -EFBIG by allowing large writes beyond MAX_NON_LFS on shmem +* objects by setting O_LARGEFILE. +*/ +if (force_o_largefile ()) + filp->f_flags |=O_LARGEFILE ; + obj->filp = filp;return 0 ; }Signature · 1 line
2.34.1