Re: sysfs: write returns ENOMEM?

Pekka Enberg
2005-08-23T07:56:05Z

[-- Attachment #1: Type: text/plain, Size: 1373 bytes --]

On 8/23/05, Nathan Scott <nathans@sgi.com> wrote:
> FWIW, all filesystems using the generic page cache routines are able
> to return this - see mm/filemap.c -> generic_file_buffered_write...

I don't think it makes much sense to fix this in individual
filesystems as many functions returning -NOMEM can be used in other
paths as well where they're ok.

Andrew, please consider picking this up for -mm. (I've included it as
an attachment as well as gmail will surely mess up the patch. Sorry.)

Pekka

[PATCH] VFS: return ENOBUFS instead of ENOMEM for vfs_write()

As noticed by Dmitry Torokhov, write() can not return ENOMEM:

http://www.opengroup.org/onlinepubs/000095399/functions/write.html

Currently almost all filesystems can return -ENOMEM due to
generic_file_buffered_write() in mm/filemap.c so filter out the invalid
error code in vfs_write().

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
---

read_write.c | 2 ++
1 files changed, 2 insertions(+)

Index: 2.6-mm/fs/read_write.c
===================================================================
--- 2.6-mm.orig/fs/read_write.c
+++ 2.6-mm/fs/read_write.c
@@ -310,6 +310,8 @@ ssize_t vfs_write(struct file *file, con
}
}

+ if (ret == -ENOMEM)
+ ret = -ENOBUFS;
return ret;
}

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: vfs-vfs_write-return-ENOBUFS-instead-ENOMEM.patch --]
[-- Type: text/x-patch; name="vfs-vfs_write-return-ENOBUFS-instead-ENOMEM.patch", Size: 759 bytes --]

[PATCH] VFS: return ENOBUFS instead of ENOMEM for vfs_write()

As noticed by Dmitry Torokhov, write() can not return ENOMEM:

http://www.opengroup.org/onlinepubs/000095399/functions/write.html

Currently almost all filesystems can return -ENOMEM due to
generic_file_buffered_write() in mm/filemap.c so filter out the invalid
error code in vfs_write().

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
---

read_write.c | 2 ++
1 files changed, 2 insertions(+)

Index: 2.6-mm/fs/read_write.c
===================================================================
--- 2.6-mm.orig/fs/read_write.c
+++ 2.6-mm/fs/read_write.c
@@ -310,6 +310,8 @@ ssize_t vfs_write(struct file *file, con
}
}

+ if (ret == -ENOMEM)
+ ret = -ENOBUFS;
return ret;
}