You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by jp...@apache.org on 2010/09/14 18:41:56 UTC
svn commit: r996982 - in /trafficserver/traffic/trunk/iocore/cache: Cache.cc
CacheDisk.cc I_Store.h P_CacheDisk.h P_CachePart.h Store.cc
Author: jplevyak
Date: Tue Sep 14 16:41:55 2010
New Revision: 996982
URL: http://svn.apache.org/viewvc?rev=996982&view=rev
Log:
TS-43: handle disk/partition alignment for disks with 4096 hardware sector size
This should handle DOS partitions aligned at 63 512 byte sectors
Modified:
trafficserver/traffic/trunk/iocore/cache/Cache.cc
trafficserver/traffic/trunk/iocore/cache/CacheDisk.cc
trafficserver/traffic/trunk/iocore/cache/I_Store.h
trafficserver/traffic/trunk/iocore/cache/P_CacheDisk.h
trafficserver/traffic/trunk/iocore/cache/P_CachePart.h
trafficserver/traffic/trunk/iocore/cache/Store.cc
Modified: trafficserver/traffic/trunk/iocore/cache/Cache.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/iocore/cache/Cache.cc?rev=996982&r1=996981&r2=996982&view=diff
==============================================================================
--- trafficserver/traffic/trunk/iocore/cache/Cache.cc (original)
+++ trafficserver/traffic/trunk/iocore/cache/Cache.cc Tue Sep 14 16:41:55 2010
@@ -517,7 +517,6 @@ CacheProcessor::start_internal(int flags
int fd = open(path, opts, 0644);
int blocks = sd->blocks;
- off_t offset = sd->offset;
if (fd > 0) {
#if defined (_WIN32)
aio_completion_port.register_handle((void *) fd, 0);
@@ -544,7 +543,9 @@ CacheProcessor::start_internal(int flags
sector_size = cache_config_force_sector_size;
if (sd->hw_sector_size <= 0 || sector_size > STORE_BLOCK_SIZE)
Error("bad hardware sector size");
- gdisks[gndisks]->open(path, blocks, offset, sector_size, fd, clear);
+ off_t skip = ROUND_TO_STORE_BLOCK((sd->offset < START_POS ? START_POS + sd->alignment : sd->offset));
+ blocks = blocks - ROUND_TO_STORE_BLOCK(sd->offset - skip);
+ gdisks[gndisks]->open(path, blocks, skip, sector_size, fd, clear);
gndisks++;
}
} else
Modified: trafficserver/traffic/trunk/iocore/cache/CacheDisk.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/iocore/cache/CacheDisk.cc?rev=996982&r1=996981&r2=996982&view=diff
==============================================================================
--- trafficserver/traffic/trunk/iocore/cache/CacheDisk.cc (original)
+++ trafficserver/traffic/trunk/iocore/cache/CacheDisk.cc Tue Sep 14 16:41:55 2010
@@ -25,13 +25,12 @@
int
-CacheDisk::open(char *s, off_t blocks, off_t dir_skip, int ahw_sector_size, int fildes, bool clear)
+CacheDisk::open(char *s, off_t blocks, off_t askip, int ahw_sector_size, int fildes, bool clear)
{
path = xstrdup(s);
hw_sector_size = ahw_sector_size;
fd = fildes;
- skip = ROUND_TO_STORE_BLOCK((dir_skip < START_POS ? START_POS : dir_skip));
- start_offset = dir_skip;
+ skip = askip;
start = skip;
/* we can't use fractions of store blocks. */
len = blocks;
@@ -50,11 +49,10 @@ CacheDisk::open(char *s, off_t blocks, o
}
disk_parts = (DiskPart **) xmalloc((l / MIN_PART_SIZE + 1) * sizeof(DiskPart **));
-
memset(disk_parts, 0, (l / MIN_PART_SIZE + 1) * sizeof(DiskPart **));
header_len = ROUND_TO_STORE_BLOCK(header_len);
start = skip + header_len;
- num_usable_blocks = (off_t(len * STORE_BLOCK_SIZE) - (start - start_offset)) >> STORE_BLOCK_SHIFT;
+ num_usable_blocks = (off_t(len * STORE_BLOCK_SIZE) - (start - askip)) >> STORE_BLOCK_SHIFT;
#if defined(_WIN32)
header = (DiskHeader *) malloc(header_len);
Modified: trafficserver/traffic/trunk/iocore/cache/I_Store.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/iocore/cache/I_Store.h?rev=996982&r1=996981&r2=996982&view=diff
==============================================================================
--- trafficserver/traffic/trunk/iocore/cache/I_Store.h (original)
+++ trafficserver/traffic/trunk/iocore/cache/I_Store.h Tue Sep 14 16:41:55 2010
@@ -49,6 +49,7 @@ struct Span
bool file_pathname; // the pathname is a file
bool isRaw;
int64 offset; // used only if (file == true)
+ int alignment;
int disk_id;
LINK(Span, link);
@@ -93,7 +94,7 @@ public:
char *buf, int buflen); // where to store the path
Span():pathname(NULL), blocks(0), hw_sector_size(DEFAULT_HW_SECTOR_SIZE), file_pathname(false),
- isRaw(true), offset(0), disk_id(0), is_mmapable_internal(false) {
+ isRaw(true), offset(0), alignment(0), disk_id(0), is_mmapable_internal(false) {
}
~Span();
};
@@ -176,9 +177,6 @@ extern Store theStore;
// store either free or in the cache, can be stolen for reconfiguration
void stealStore(Store & s, int blocks);
-// store either free or in the cache, can be stolen for reconfiguration
-void stealStore(Store & s, int blocks);
-
int initialize_store();
struct storageConfigFile {
Modified: trafficserver/traffic/trunk/iocore/cache/P_CacheDisk.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/iocore/cache/P_CacheDisk.h?rev=996982&r1=996981&r2=996982&view=diff
==============================================================================
--- trafficserver/traffic/trunk/iocore/cache/P_CacheDisk.h (original)
+++ trafficserver/traffic/trunk/iocore/cache/P_CacheDisk.h Tue Sep 14 16:41:55 2010
@@ -96,7 +96,6 @@ struct CacheDisk:public Continuation
off_t len; // in blocks (STORE_BLOCK)
off_t start;
off_t skip;
- off_t start_offset;
int num_usable_blocks;
int hw_sector_size;
int fd;
@@ -109,14 +108,14 @@ struct CacheDisk:public Continuation
int open(bool clear);
CacheDisk():Continuation(new_ProxyMutex()), header(NULL),
- path(NULL), header_len(0), len(0), start(0), skip(0), start_offset(0),
+ path(NULL), header_len(0), len(0), start(0), skip(0),
num_usable_blocks(0), fd(-1), free_space(0), wasted_space(0),
disk_parts(NULL), free_blocks(NULL), num_errors(0), cleared(0)
{
}
~CacheDisk();
- int open(char *s, off_t blocks, off_t dir_skip, int hw_sector_size, int fildes, bool clear);
+ int open(char *s, off_t blocks, off_t skip, int hw_sector_size, int fildes, bool clear);
int clearDisk();
int clearDone(int event, void *data);
int openStart(int event, void *data);
Modified: trafficserver/traffic/trunk/iocore/cache/P_CachePart.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/iocore/cache/P_CachePart.h?rev=996982&r1=996981&r2=996982&view=diff
==============================================================================
--- trafficserver/traffic/trunk/iocore/cache/P_CachePart.h (original)
+++ trafficserver/traffic/trunk/iocore/cache/P_CachePart.h Tue Sep 14 16:41:55 2010
@@ -35,7 +35,7 @@
// Part
#define PART_MAGIC 0xF1D0F00D
-#define START_BLOCKS 32 // 8k
+#define START_BLOCKS 16 // 8k, STORE_BLOCK_SIZE
#define START_POS ((off_t)START_BLOCKS * CACHE_BLOCK_SIZE)
#define AGG_SIZE (4 * 1024 * 1024) // 4MB
#define AGG_HIGH_WATER (AGG_SIZE / 2) // 2MB
Modified: trafficserver/traffic/trunk/iocore/cache/Store.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/iocore/cache/Store.cc?rev=996982&r1=996981&r2=996982&view=diff
==============================================================================
--- trafficserver/traffic/trunk/iocore/cache/Store.cc (original)
+++ trafficserver/traffic/trunk/iocore/cache/Store.cc Tue Sep 14 16:41:55 2010
@@ -361,7 +361,6 @@ Lfail:;
return err;
}
-
int
Store::write_config_data(int fd)
{
@@ -375,12 +374,8 @@ Store::write_config_data(int fd)
return 0;
}
-
-
-
-
#if defined(freebsd) || defined(darwin) || defined(solaris)
-// TODO: Those are probaply already included from the ink_platform.h
+// TODO: Those are probably already included from the ink_platform.h
#include <ctype.h>
#include <sys/types.h>
#include <sys/param.h>
@@ -628,6 +623,14 @@ Span::init(char *filename, int64 size)
Debug("cache_init", "Span::init - %s hw_sector_size = %d,is_disk = %d,adjusted_sec = %d", filename, hw_sector_size, is_disk,adjusted_sec);
}
+ alignment = 0;
+#ifdef BLKALIGNOFF
+ if (ioctl(fd, BLKALIGNOFF, &arg) == 0) {
+ alignment = arg;
+ Debug("cache_init", "Span::init - %s alignment = %d", filename, alignment);
+ }
+#endif
+
if (is_disk) {
long physsectors = 0;