You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ig...@apache.org on 2013/01/15 16:37:47 UTC
[3/4] git commit: get and use hw_sector_size, set disk_id
get and use hw_sector_size, set disk_id
get hw_sector_size from ioctl
use it in the calculation, rather than the #define
We also forgot to set the disk_id
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/4ffb3428
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/4ffb3428
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/4ffb3428
Branch: refs/heads/3.2.x
Commit: 4ffb342816565478b20d7cd5efad0d53cd5339d2
Parents: dc8c555
Author: Igor Galić <i....@brainsware.org>
Authored: Sat Oct 13 12:28:55 2012 +0200
Committer: Igor Galić <i....@brainsware.org>
Committed: Tue Jan 15 16:22:58 2013 +0100
----------------------------------------------------------------------
iocore/cache/Store.cc | 21 +++++++++++----------
1 files changed, 11 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4ffb3428/iocore/cache/Store.cc
----------------------------------------------------------------------
diff --git a/iocore/cache/Store.cc b/iocore/cache/Store.cc
index 740f43d..dd84298 100644
--- a/iocore/cache/Store.cc
+++ b/iocore/cache/Store.cc
@@ -389,9 +389,6 @@ Span::init(char *an, int64_t size)
const char *err = NULL;
int ret = 0;
- //
- // All file types on Solaris can be mmaped
- //
is_mmapable_internal = true;
// handle symlinks
@@ -452,6 +449,11 @@ Span::init(char *an, int64_t size)
err = "unable to get label information";
goto Lfail;
}
+ if (ioctl(fd, DIOCGSECTORSIZE, &hw_sector_size) < 0) {
+ Warning("unable to get disk information for '%s': %s", n, strerror(errno));
+ err = "unable to get label information";
+ goto Lfail;
+ }
devnum = s.st_rdev;
break;
}
@@ -471,21 +473,20 @@ Span::init(char *an, int64_t size)
break;
}
- // estimate the disk SOLARIS specific
- if ((devnum >> 16) == 0x80)
- disk_id = (devnum >> 3) & 0x3F;
- else {
- disk_id = devnum;
- }
+ disk_id = devnum;
pathname = ats_strdup(an);
- blocks = size / STORE_BLOCK_SIZE;
+ blocks = size / hw_sector_size;
file_pathname = !((s.st_mode & S_IFMT) == S_IFDIR);
+ // This is so FreeBSD admins don't worry about our malicious code creating boot sector viruses:
if (((s.st_mode & S_IFMT) == S_IFBLK) || ((s.st_mode & S_IFMT) == S_IFCHR)) {
blocks--;
offset = 1;
}
+
+ Debug("cache_init", "Span::init - %s hw_sector_size = %d size = %" PRId64 ", blocks = %" PRId64 ", disk_id = %d, file_pathname = %d", pathname, hw_sector_size, size, blocks, disk_id, file_pathname);
+
Lfail:
socketManager.close(fd);
return err;