Re: [PATCH v2 4/5] nilfs-utils: add support for NILFS_IOCTL_SET_SUINFO ioctl

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Jan 21, 2014, at 4:59 PM, Andreas Rohner wrote:

[snip]
> diff --git a/lib/gc.c b/lib/gc.c
> index 0b0e2d6..ebbe0ca 100644
> --- a/lib/gc.c
> +++ b/lib/gc.c
> @@ -29,6 +29,10 @@
> #include <syslog.h>
> #endif	/* HAVE_SYSLOG_H */
> 
> +#if HAVE_SYS_TIME_H
> +#include <sys/time.h>
> +#endif	/* HAVE_SYS_TIME */
> +
> #include <errno.h>
> #include <assert.h>
> #include <stdarg.h>
> @@ -615,7 +619,10 @@ ssize_t nilfs_reclaim_segment(struct nilfs *nilfs,
> {
> 	struct nilfs_vector *vdescv, *bdescv, *periodv, *vblocknrv;
> 	sigset_t sigset, oldset, waitset;
> -	ssize_t n, ret = -1;
> +	ssize_t n, i, ret = -1;
> +	__u32 freeblocks;
> +	struct nilfs_suinfo_update *supv;
> +	struct timeval tv;
> 
> 	if (nsegs == 0)
> 		return 0;
> @@ -678,6 +685,41 @@ ssize_t nilfs_reclaim_segment(struct nilfs *nilfs,
> 		goto out_lock;
> 	}
> 
> +	freeblocks = (nilfs_get_blocks_per_segment(nilfs) * n)
> +				- (nilfs_vector_get_size(vdescv)
> +				+ nilfs_vector_get_size(bdescv));
> +
> +	/* if there are less free blocks than the
> +	 * minimal threshold try to update suinfo
> +	 * instead of cleaning */
> +	if (freeblocks < minblocks * n) {
> +		ret = gettimeofday(&tv, NULL);
> +		if (ret < 0)
> +			goto out_lock;
> +
> +		supv = malloc(sizeof(struct nilfs_suinfo_update) * n);

Is it enough to allocate memory without zeroing?
Do you free allocated memory in the case of error? 

Thanks,
Vyacheslav Dubeyko.

--
To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystem Development]     [Linux BTRFS]     [Linux CIFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux