svn commit: r312836 - stable/11/sys/cam/ctl
Alexander Motin
mav at FreeBSD.org
Thu Jan 26 20:51:19 UTC 2017
Author: mav
Date: Thu Jan 26 20:51:18 2017
New Revision: 312836
URL: https://svnweb.freebsd.org/changeset/base/312836
Log:
MFC r311680: Make CTL_GETSTATS ioctl return partial data if buffer is small.
Modified:
stable/11/sys/cam/ctl/ctl.c
Directory Properties:
stable/11/ (props changed)
Modified: stable/11/sys/cam/ctl/ctl.c
==============================================================================
--- stable/11/sys/cam/ctl/ctl.c Thu Jan 26 20:50:01 2017 (r312835)
+++ stable/11/sys/cam/ctl/ctl.c Thu Jan 26 20:51:18 2017 (r312836)
@@ -2779,32 +2779,29 @@ ctl_ioctl(struct cdev *dev, u_long cmd,
break;
}
case CTL_GETSTATS: {
- struct ctl_stats *stats;
+ struct ctl_stats *stats = (struct ctl_stats *)addr;
int i;
- stats = (struct ctl_stats *)addr;
-
- if ((sizeof(struct ctl_lun_io_stats) * softc->num_luns) >
- stats->alloc_len) {
- stats->status = CTL_SS_NEED_MORE_SPACE;
- stats->num_luns = softc->num_luns;
- break;
- }
/*
* XXX KDM no locking here. If the LUN list changes,
* things can blow up.
*/
i = 0;
+ stats->status = CTL_SS_OK;
+ stats->fill_len = 0;
STAILQ_FOREACH(lun, &softc->lun_list, links) {
+ if (stats->fill_len + sizeof(lun->stats) >
+ stats->alloc_len) {
+ stats->status = CTL_SS_NEED_MORE_SPACE;
+ break;
+ }
retval = copyout(&lun->stats, &stats->lun_stats[i++],
sizeof(lun->stats));
if (retval != 0)
break;
+ stats->fill_len += sizeof(lun->stats);
}
stats->num_luns = softc->num_luns;
- stats->fill_len = sizeof(struct ctl_lun_io_stats) *
- softc->num_luns;
- stats->status = CTL_SS_OK;
#ifdef CTL_TIME_IO
stats->flags = CTL_STATS_FLAG_TIME_VALID;
#else
More information about the svn-src-stable-11
mailing list