All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH/RFC] Return ENOSPC and EDQUOT for nfs writes earlier.
@ 2007-07-12  0:12 Neil Brown
  2007-07-12 20:31 ` Trond Myklebust
  0 siblings, 1 reply; 5+ messages in thread
From: Neil Brown @ 2007-07-12  0:12 UTC (permalink / raw)
  To: Trond Myklebust; +Cc: nfs


When a write to a local filesystem hits a space limitation such as
filesystem-full or quota-exhausted, the write fails synchronously.
You get ENOSPC or EDQUOT immediately.

NFS cannot do that efficiently.

Currently, you don't get these errors until 'fsync' or 'close'.  That
is very different from local filesystem behaviour, and is less than
ideal.

The following patch causes these two errors to be returned through the
next write call once they are known about.

A possible extension would be to set a flag when we first get such an
error, clear it when a write succeeds, and while the flag is set, do
all writes synchronously.  This would be even closer to
local-filesystem semantics, but I'm not sure it is worth it.

Thoughts?

Thanks,
NeilBrown

Make NFS writes return ENOSPC and EDQUOT more promptly.

Signed-off-by: Neil Brown <neilb@suse.de>

### Diffstat output
 ./fs/nfs/file.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)

diff .prev/fs/nfs/file.c ./fs/nfs/file.c
--- .prev/fs/nfs/file.c	2007-07-12 08:57:09.000000000 +1000
+++ ./fs/nfs/file.c	2007-07-12 09:56:58.000000000 +1000
@@ -367,6 +367,8 @@ const struct address_space_operations nf
 static ssize_t nfs_file_write(struct kiocb *iocb, const struct iovec *iov,
 				unsigned long nr_segs, loff_t pos)
 {
+	struct nfs_open_context *ctx =
+		(struct nfs_open_context *)iocb->ki_filp->private_data;
 	struct dentry * dentry = iocb->ki_filp->f_path.dentry;
 	struct inode * inode = dentry->d_inode;
 	ssize_t result;
@@ -397,6 +399,16 @@ static ssize_t nfs_file_write(struct kio
 	if (!count)
 		goto out;
 
+	if (ctx->error == -EDQUOT || ctx->error == -ENOSPC) {
+		/* Local file systems return these errors synchronously,
+		 * NFS cannot do that efficiently, so just return them
+		 * at the first opportunity.
+		 */
+		result = ctx->error;
+		ctx->error = 0;
+		goto out;
+	}
+
 	nfs_add_stats(inode, NFSIOS_NORMALWRITTENBYTES, count);
 	result = generic_file_aio_write(iocb, iov, nr_segs, pos);
 	/* Return error values for O_SYNC and IS_SYNC() */

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
NFS maillist  -  NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-07-13 21:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-12  0:12 [PATCH/RFC] Return ENOSPC and EDQUOT for nfs writes earlier Neil Brown
2007-07-12 20:31 ` Trond Myklebust
2007-07-13  0:01   ` Neil Brown
2007-07-13 17:16   ` Chuck Lever
2007-07-13 21:12     ` Trond Myklebust

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.