From d9d9571785dabc5c311111b1263fe0881b0ccda5 Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Thu, 13 Dec 2018 12:25:32 -0600 Subject: [PATCH] afs: Reword "cache is full" messages Currently, there are multiple different areas in the code that log a message that look like this, when we encounter an ENOSPC error when writing to the cache: *** Cache partition is FULL - Decrease cachesize!!! *** The message is a bit unclear, and doesn't even mention AFS at all. Reword the message to try to explain a little more what's happening. Also, since we log the same message in several different places, move them all to a common function, called afs_WarnENOSPC, so we only need to change the message in one place. Change-Id: If1c259bd22a382ff56ed29326aa20c86389d06bc Reviewed-on: https://gerrit.openafs.org/13410 Reviewed-by: Benjamin Kaduk Tested-by: BuildBot --- src/afs/AIX/osi_file.c | 3 +-- src/afs/HPUX/osi_file.c | 3 +-- src/afs/IRIX/osi_file.c | 3 +-- src/afs/LINUX/osi_file.c | 3 +-- src/afs/VNOPS/afs_vnop_write.c | 3 +-- src/afs/afs_prototypes.h | 1 + src/afs/afs_warn.c | 15 +++++++++++++++ 7 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/afs/AIX/osi_file.c b/src/afs/AIX/osi_file.c index 6df3b41..806baf7 100644 --- a/src/afs/AIX/osi_file.c +++ b/src/afs/AIX/osi_file.c @@ -235,8 +235,7 @@ afs_osi_Write(struct osi_file *afile, afs_int32 offset, void *aptr, afs_Trace3(afs_iclSetp, CM_TRACE_WRITEFAILED, ICL_TYPE_INT32, asize, ICL_TYPE_INT32, resid, ICL_TYPE_INT32, code); if (code == ENOSPC) - afs_warnuser - ("\n\n\n*** Cache partition is FULL - Decrease cachesize!!! ***\n\n"); + afs_WarnENOSPC(); setuerror(code); if (code > 0) { code = -code; diff --git a/src/afs/HPUX/osi_file.c b/src/afs/HPUX/osi_file.c index bd52756..d8f8562 100644 --- a/src/afs/HPUX/osi_file.c +++ b/src/afs/HPUX/osi_file.c @@ -202,8 +202,7 @@ afs_osi_Write(struct osi_file *afile, afs_int32 offset, void *aptr, afile->offset += code; } else { if (code == ENOSPC) - afs_warnuser - ("\n\n\n*** Cache partition is FULL - Decrease cachesize!!! ***\n\n"); + afs_WarnENOSPC(); setuerror(code); if (code > 0) { code = -code; diff --git a/src/afs/IRIX/osi_file.c b/src/afs/IRIX/osi_file.c index b9e886b..773a4bd 100644 --- a/src/afs/IRIX/osi_file.c +++ b/src/afs/IRIX/osi_file.c @@ -186,8 +186,7 @@ afs_osi_Write(struct osi_file *afile, afs_int32 offset, void *aptr, afile->offset += code; } else { if (code == ENOSPC) - afs_warnuser - ("\n\n\n*** Cache partition is FULL - Decrease cachesize!!! ***\n\n"); + afs_WarnENOSPC(); if (code > 0) { code = -code; } diff --git a/src/afs/LINUX/osi_file.c b/src/afs/LINUX/osi_file.c index 8f12246..a920b81 100644 --- a/src/afs/LINUX/osi_file.c +++ b/src/afs/LINUX/osi_file.c @@ -294,8 +294,7 @@ afs_osi_Write(struct osi_file *afile, afs_int32 offset, void *aptr, afile->offset += code; } else { if (code == ENOSPC) - afs_warnuser - ("\n\n\n*** Cache partition is FULL - Decrease cachesize!!! ***\n\n"); + afs_WarnENOSPC(); if (code > 0) { code = -code; } diff --git a/src/afs/VNOPS/afs_vnop_write.c b/src/afs/VNOPS/afs_vnop_write.c index c7c56dc..5372af6 100644 --- a/src/afs/VNOPS/afs_vnop_write.c +++ b/src/afs/VNOPS/afs_vnop_write.c @@ -130,8 +130,7 @@ afs_UFSWriteUIO(struct vcache *avc, afs_dcache_id_t *inode, struct uio *tuiop) # endif AFS_GLOCK(); if (code == ENOSPC) - afs_warnuser - ("\n\n\n*** Cache partition is full - decrease cachesize!!! ***\n\n\n"); + afs_WarnENOSPC(); #elif defined(AFS_SGI_ENV) AFS_GUNLOCK(); avc->f.states |= CWritingUFS; diff --git a/src/afs/afs_prototypes.h b/src/afs/afs_prototypes.h index f2aa588..615b0bf 100644 --- a/src/afs/afs_prototypes.h +++ b/src/afs/afs_prototypes.h @@ -1044,6 +1044,7 @@ extern void afs_warnuser(char *fmt, ...) extern void afs_warnall(char *fmt, ...) AFS_ATTRIBUTE_FORMAT(__printf__, 1, 2); #endif +extern void afs_WarnENOSPC(void); /* afs_vcache.c */ extern int VCHash(struct VenusFid *fid); diff --git a/src/afs/afs_warn.c b/src/afs/afs_warn.c index 17d3c89..ba0b757 100644 --- a/src/afs/afs_warn.c +++ b/src/afs/afs_warn.c @@ -254,3 +254,18 @@ afs_warnall(char *fmt, ...) # endif /* AFS_LINUX20_ENV */ } #endif /* AFS_AIX_ENV */ + +/* + * Log a warning when we encounter an ENOSPC error when writing to the cache + * partition. We should not normally encounter ENOSPC errors, since we limit + * our space usage according to the client config, which should be configured + * such that we never run out of space. + */ +void +afs_WarnENOSPC(void) +{ + afs_warnuser("afs: Cache partition is FULL! This should not happen, and " + "can result in errors in userspace applications. To avoid " + "this, reduce the configured cache size so we do not run out " + "of space.\n"); +} -- 1.9.4