From 3fb7f8919a8cbc788ecd99c6a468923f3f278599 Mon Sep 17 00:00:00 2001 From: Antonio SJ Musumeci Date: Thu, 6 Oct 2016 13:54:57 -0400 Subject: [PATCH] add EDQUOT to errors which trigger moveonenospc --- README.md | 2 +- man/mergerfs.1 | 6 +++--- src/write.cpp | 10 +++++++++- src/write_buf.cpp | 12 ++++++++++-- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 5c77b183..aabec530 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ mergerfs -o<options> <srcmounts> <mountpoint> * **defaults**: a shortcut for FUSE's **atomic_o_trunc**, **auto_cache**, **big_writes**, **default_permissions**, **splice_move**, **splice_read**, and **splice_write**. These options seem to provide the best performance. * **direct_io**: causes FUSE to bypass an addition caching step which can increase write speeds at the detriment of read speed. * **minfreespace**: the minimum space value used for creation policies. Understands 'K', 'M', and 'G' to represent kilobyte, megabyte, and gigabyte respectively. (default: 4G) -* **moveonenospc**: when enabled (set to **true**) if a **write** fails with **ENOSPC** a scan of all drives will be done looking for the drive with most free space which is at least the size of the file plus the amount which failed to write. An attempt to move the file to that drive will occur (keeping all metadata possible) and if successful the original is unlinked and the write retried. (default: false) +* **moveonenospc**: when enabled (set to **true**) if a **write** fails with **ENOSPC** or **EDQUOT** a scan of all drives will be done looking for the drive with most free space which is at least the size of the file plus the amount which failed to write. An attempt to move the file to that drive will occur (keeping all metadata possible) and if successful the original is unlinked and the write retried. (default: false) * **func.<func>=<policy>**: sets the specific FUSE function's policy. See below for the list of value types. Example: **func.getattr=newest** * **category.<category>=<policy>**: Sets policy of all FUSE functions in the provided category. Example: **category.create=mfs** * **fsname**: sets the name of the filesystem as seen in **mount**, **df**, etc. Defaults to a list of the source paths concatenated together with the longest common prefix removed. diff --git a/man/mergerfs.1 b/man/mergerfs.1 index dca503c2..165454b1 100644 --- a/man/mergerfs.1 +++ b/man/mergerfs.1 @@ -52,9 +52,9 @@ kilobyte, megabyte, and gigabyte respectively. (default: 4G) .IP \[bu] 2 \f[B]moveonenospc\f[]: when enabled (set to \f[B]true\f[]) if a -\f[B]write\f[] fails with \f[B]ENOSPC\f[] a scan of all drives will be -done looking for the drive with most free space which is at least the -size of the file plus the amount which failed to write. +\f[B]write\f[] fails with \f[B]ENOSPC\f[] or \f[B]EDQUOT\f[] a scan of +all drives will be done looking for the drive with most free space which +is at least the size of the file plus the amount which failed to write. An attempt to move the file to that drive will occur (keeping all metadata possible) and if successful the original is unlinked and the write retried. diff --git a/src/write.cpp b/src/write.cpp index cdd0c1c5..78fb9162 100644 --- a/src/write.cpp +++ b/src/write.cpp @@ -25,6 +25,14 @@ #include "rwlock.hpp" #include "ugid.hpp" +static +bool +_out_of_space(const int error) +{ + return ((error == ENOSPC) || + (error == EDQUOT)); +} + static int _write(const int fd, @@ -54,7 +62,7 @@ namespace mergerfs FileInfo* fi = reinterpret_cast(ffi->fh); rv = _write(fi->fd,buf,count,offset); - if(rv == -ENOSPC) + if(_out_of_space(-rv)) { const fuse_context *fc = fuse_get_context(); const Config &config = Config::get(fc); diff --git a/src/write_buf.cpp b/src/write_buf.cpp index 94abc86e..db262436 100644 --- a/src/write_buf.cpp +++ b/src/write_buf.cpp @@ -37,6 +37,14 @@ using std::string; using std::vector; using namespace mergerfs; +static +bool +_out_of_space(const int error) +{ + return ((error == ENOSPC) || + (error == EDQUOT)); +} + static int _write_buf(const int fd, @@ -69,8 +77,8 @@ namespace mergerfs FileInfo *fi = reinterpret_cast(ffi->fh); rv = _write_buf(fi->fd,*src,offset); - if(rv == -ENOSPC) - { + if(_out_of_space(-rv)) + { const fuse_context *fc = fuse_get_context(); const Config &config = Config::get(fc);