svn commit: r275893 - stable/10/sys/cam/ctl
Alexander Motin
mav at FreeBSD.org
Thu Dec 18 08:43:37 UTC 2014
Author: mav
Date: Thu Dec 18 08:43:36 2014
New Revision: 275893
URL: https://svnweb.freebsd.org/changeset/base/275893
Log:
MFC r275481:
Add to CTL support for threshold notifications for file-backed LUNs.
Previously it was supported only for ZVOL-backed LUNs, but now should work
for file-backed LUNs too. Used value in this case is a space occupied by
the backing file, while available value is an available space on file
system. Pool thresholds are still not implemented in this case.
Sponsored by: iXsystems, Inc.
Modified:
stable/10/sys/cam/ctl/ctl_backend_block.c
Directory Properties:
stable/10/ (props changed)
Modified: stable/10/sys/cam/ctl/ctl_backend_block.c
==============================================================================
--- stable/10/sys/cam/ctl/ctl_backend_block.c Thu Dec 18 08:38:07 2014 (r275892)
+++ stable/10/sys/cam/ctl/ctl_backend_block.c Thu Dec 18 08:43:36 2014 (r275893)
@@ -245,6 +245,8 @@ static void ctl_be_block_dispatch_file(s
struct ctl_be_block_io *beio);
static void ctl_be_block_gls_file(struct ctl_be_block_lun *be_lun,
struct ctl_be_block_io *beio);
+static uint64_t ctl_be_block_getattr_file(struct ctl_be_block_lun *be_lun,
+ const char *attrname);
static void ctl_be_block_flush_dev(struct ctl_be_block_lun *be_lun,
struct ctl_be_block_io *beio);
static void ctl_be_block_unmap_dev(struct ctl_be_block_lun *be_lun,
@@ -802,6 +804,31 @@ ctl_be_block_gls_file(struct ctl_be_bloc
ctl_complete_beio(beio);
}
+static uint64_t
+ctl_be_block_getattr_file(struct ctl_be_block_lun *be_lun, const char *attrname)
+{
+ struct vattr vattr;
+ struct statfs statfs;
+ int error;
+
+ if (be_lun->vn == NULL)
+ return (UINT64_MAX);
+ if (strcmp(attrname, "blocksused") == 0) {
+ error = VOP_GETATTR(be_lun->vn, &vattr, curthread->td_ucred);
+ if (error != 0)
+ return (UINT64_MAX);
+ return (vattr.va_bytes >> be_lun->blocksize_shift);
+ }
+ if (strcmp(attrname, "blocksavail") == 0) {
+ error = VFS_STATFS(be_lun->vn->v_mount, &statfs);
+ if (error != 0)
+ return (UINT64_MAX);
+ return ((statfs.f_bavail * statfs.f_bsize) >>
+ be_lun->blocksize_shift);
+ }
+ return (UINT64_MAX);
+}
+
static void
ctl_be_block_dispatch_zvol(struct ctl_be_block_lun *be_lun,
struct ctl_be_block_io *beio)
@@ -1727,6 +1754,7 @@ ctl_be_block_open_file(struct ctl_be_blo
be_lun->dispatch = ctl_be_block_dispatch_file;
be_lun->lun_flush = ctl_be_block_flush_file;
be_lun->get_lba_status = ctl_be_block_gls_file;
+ be_lun->getattr = ctl_be_block_getattr_file;
error = VOP_GETATTR(be_lun->vn, &vattr, curthread->td_ucred);
if (error != 0) {
More information about the svn-src-stable-10
mailing list