From: Theodore Ts'o Date: Sun, 1 Sep 2019 05:17:42 +0000 (-0400) Subject: libsupport: remove unnecessary code to set the quota inode size X-Git-Tag: v1.45.4~17 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=638940d422eade53c9d22ad3db8f412d74a76d90;p=tools%2Fe2fsprogs.git libsupport: remove unnecessary code to set the quota inode size This is done correctly by the fileio routines; and it forces the quota inode's file size to be unnecessarily rounded up to the block size. Also remove the unnecessary double colon in the quota's error messages. Signed-off-by: Theodore Ts'o --- diff --git a/lib/support/common.h b/lib/support/common.h index 19a75f4..00a9375 100644 --- a/lib/support/common.h +++ b/lib/support/common.h @@ -22,12 +22,12 @@ #endif #define log_err(format, arg ...) \ - fprintf(stderr, "[ERROR] %s:%d:%s:: " format "\n", \ + fprintf(stderr, "[ERROR] %s:%d:%s: " format "\n", \ __FILE__, __LINE__, __func__, ## arg) #ifdef DEBUG_QUOTA # define log_debug(format, arg ...) \ - fprintf(stderr, "[DEBUG] %s:%d:%s:: " format "\n", \ + fprintf(stderr, "[DEBUG] %s:%d:%s: " format "\n", \ __FILE__, __LINE__, __func__, ## arg) #else # define log_debug(...) diff --git a/lib/support/quotaio.c b/lib/support/quotaio.c index 2daf178..b41bb74 100644 --- a/lib/support/quotaio.c +++ b/lib/support/quotaio.c @@ -105,19 +105,6 @@ void update_grace_times(struct dquot *q) } } -static int compute_num_blocks_proc(ext2_filsys fs EXT2FS_ATTR((unused)), - blk64_t *blocknr EXT2FS_ATTR((unused)), - e2_blkcnt_t blockcnt EXT2FS_ATTR((unused)), - blk64_t ref_block EXT2FS_ATTR((unused)), - int ref_offset EXT2FS_ATTR((unused)), - void *private) -{ - blk64_t *num_blocks = private; - - *num_blocks += 1; - return 0; -} - errcode_t quota_inode_truncate(ext2_filsys fs, ext2_ino_t ino) { struct ext2_inode inode; @@ -147,18 +134,6 @@ errcode_t quota_inode_truncate(ext2_filsys fs, ext2_ino_t ino) return err; } -static ext2_off64_t compute_inode_size(ext2_filsys fs, ext2_ino_t ino) -{ - blk64_t num_blocks = 0; - - ext2fs_block_iterate3(fs, ino, - BLOCK_FLAG_READ_ONLY, - NULL, - compute_num_blocks_proc, - &num_blocks); - return num_blocks * fs->blocksize; -} - /* Functions to read/write quota file. */ static unsigned int quota_write_nomount(struct quota_file *qf, ext2_loff_t offset, @@ -413,17 +388,8 @@ errcode_t quota_file_close(quota_ctx_t qctx, struct quota_handle *h) if (h->qh_ops->end_io && h->qh_ops->end_io(h) < 0) return EIO; - if (h->qh_qf.e2_file) { - __u64 new_size, size; - - new_size = compute_inode_size(h->qh_qf.fs, h->qh_qf.ino); - ext2fs_file_flush(h->qh_qf.e2_file); - if (ext2fs_file_get_lsize(h->qh_qf.e2_file, &size)) - new_size = 0; - if (size != new_size) - ext2fs_file_set_size2(h->qh_qf.e2_file, new_size); + if (h->qh_qf.e2_file) ext2fs_file_close(h->qh_qf.e2_file); - } if (qctx->quota_file[h->qh_type] == h) ext2fs_free_mem(&qctx->quota_file[h->qh_type]); return 0;