From: Thomas Veerman Date: Fri, 16 Dec 2011 09:17:37 +0000 (+0000) Subject: Don't repeat out-of-space messages X-Git-Tag: v3.2.0~165 X-Git-Url: http://zhaoyanbai.com/repos/?a=commitdiff_plain;h=c89bc850091b8dede71c81e19d681e4aefbbbf4e;p=minix.git Don't repeat out-of-space messages This patch makes PFS, EXT2 and MFS print only once that they're out of space. After freeing up space and running out of space again, the message will be printed again also. --- diff --git a/servers/apfs/inode.c b/servers/apfs/inode.c index e73d39ca6..98be69203 100644 --- a/servers/apfs/inode.c +++ b/servers/apfs/inode.c @@ -245,14 +245,18 @@ PUBLIC struct inode *alloc_inode(dev_t dev, mode_t bits) register struct inode *rip; bit_t b; ino_t i_num; + int print_oos_msg = 1; b = alloc_bit(); if (b == NO_BIT) { err_code = ENOSPC; - printf("PipeFS is out of inodes\n"); + if (print_oos_msg) + printf("PipeFS is out of inodes\n"); + print_oos_msg = 0; /* Don't repeat message */ return(NULL); } i_num = (ino_t) b; + print_oos_msg = 1; /* Try to acquire a slot in the inode table. */ diff --git a/servers/ext2/ialloc.c b/servers/ext2/ialloc.c index e7f008dff..44f9e0d96 100644 --- a/servers/ext2/ialloc.c +++ b/servers/ext2/ialloc.c @@ -37,8 +37,9 @@ PUBLIC struct inode *alloc_inode(struct inode *parent, mode_t bits) register struct inode *rip; register struct super_block *sp; - int major, minor, inumb; + int inumb; bit_t b; + static int print_oos_msg = 1; sp = get_super(parent->i_dev); /* get pointer to super_block */ if (sp->s_rd_only) { /* can't allocate an inode on a read only device. */ @@ -50,11 +51,13 @@ PUBLIC struct inode *alloc_inode(struct inode *parent, mode_t bits) b = alloc_inode_bit(sp, parent, (bits & I_TYPE) == I_DIRECTORY); if (b == NO_BIT) { err_code = ENOSPC; - major = (int) (sp->s_dev >> MAJOR) & BYTE; - minor = (int) (sp->s_dev >> MINOR) & BYTE; - ext2_debug("Out of i-nodes on device %d/%d\n", major, minor); + if (print_oos_msg) + ext2_debug("Out of i-nodes on device %d/%d\n", + major(sp->s_dev), minor(sp->s_dev)); + print_oos_msg = 0; /* Don't repeat message */ return(NULL); } + print_oos_msg = 1; inumb = (int) b; /* be careful not to pass unshort as param */ @@ -79,7 +82,7 @@ PUBLIC struct inode *alloc_inode(struct inode *parent, mode_t bits) wipe_inode(rip); } - return(rip); + return(rip); } diff --git a/servers/mfs/cache.c b/servers/mfs/cache.c index 3adfec4c9..8d66afe8a 100644 --- a/servers/mfs/cache.c +++ b/servers/mfs/cache.c @@ -263,9 +263,9 @@ PUBLIC zone_t alloc_zone( { /* Allocate a new zone on the indicated device and return its number. */ - int major, minor; bit_t b, bit; struct super_block *sp; + static int print_oos_msg = 1; /* Note that the routine alloc_bit() returns 1 for the lowest possible * zone, which corresponds to sp->s_firstdatazone. To convert a value @@ -285,11 +285,13 @@ PUBLIC zone_t alloc_zone( b = alloc_bit(sp, ZMAP, bit); if (b == NO_BIT) { err_code = ENOSPC; - major = (int) (sp->s_dev >> MAJOR) & BYTE; - minor = (int) (sp->s_dev >> MINOR) & BYTE; - printf("No space on device %d/%d\n", major, minor); + if (print_oos_msg) + printf("No space on device %d/%d\n", major(sp->s_dev), + minor(sp->s_dev)); + print_oos_msg = 0; /* Don't repeat message */ return(NO_ZONE); } + print_oos_msg = 1; if (z == sp->s_firstdatazone) sp->s_zsearch = b; /* for next time */ return( (zone_t) (sp->s_firstdatazone - 1) + (zone_t) b); }