[zumastor commit] r1729 - trunk/ddsnap

1 view
Skip to first unread message

codesite...@google.com

unread,
Jul 15, 2008, 12:04:31 PM7/15/08
to zumastor...@googlegroups.com
Author: Daniel.Raymond.Phillips
Date: Tue Jul 15 09:03:50 2008
New Revision: 1729

Modified:
trunk/ddsnap/ddsnapd.c

Log:
Auto test failed so let's revert the trivial patch and see if that was it


Modified: trunk/ddsnap/ddsnapd.c
==============================================================================
--- trunk/ddsnap/ddsnapd.c (original)
+++ trunk/ddsnap/ddsnapd.c Tue Jul 15 09:03:50 2008
@@ -28,7 +28,6 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
-#include <sys/time.h>
#include <netinet/in.h>
#include <netdb.h> // gethostbyname2_r
#include <popt.h>
@@ -72,7 +71,6 @@
#define PR_SET_MEMALLOC 24
#define MAX_NEW_METACHUNKS 10
#define MAX_DEFERRED_ALLOCS 500
-#define MAX_CLIENTS 100

#ifndef trace
#define trace trace_off
@@ -161,8 +159,6 @@
+ Restart/Error recovery/reporting
*/

-#define fieldtype(structname, fieldname) typeof(((struct structname *)NULL)->fieldname)
-
/*
* Snapshot btree
*/
@@ -216,8 +212,6 @@

enum sbflags { SB_BUSY = 2 };

-typedef uint32_t tag_t; // !!! use this everywhere for tags
-
struct disksuper
{
typeof((char[])SB_MAGIC) magic;
@@ -314,14 +308,6 @@
struct alloc_range deferred_alloc[MAX_DEFERRED_ALLOCS], defer;
};

-struct client
-{
- u64 id;
- int sock;
- int snaptag;
- u32 flags;
-};
-
static int valid_sb(struct superblock *sb)
{
return !memcmp(sb->image.magic, (char[])SB_MAGIC, sizeof(sb->image.magic));
@@ -352,19 +338,6 @@
return !!(sb->runflags & RUN_DEFER);
}

-static inline int is_squashed(struct snapshot *snapshot)
-{
- return snapshot->bit == SNAPSHOT_SQUASHED;
-}
-
-/* usecount() calculates and returns the usecount for a given snapshot.
- * The persistent (on disk) usecount is added to the transient usecount
- * (for devices using the snapshot). */
-static inline u16 usecount(struct superblock *sb, struct snapshot *snap)
-{
- return (is_squashed(snap) ? 0 : sb->usecount[snap->bit]) + snap->usecount;
-}
-
/*
* Journalling
*/
@@ -772,11 +745,13 @@
#define show_journal(sb) do { warn("Journal..."); _show_journal(sb); }
while (0)
#endif

+#define fieldtype(structname, fieldname) typeof(((struct structname *)NULL)->fieldname)
+
static int replay_journal(struct superblock *sb)
{
struct buffer *buffer;
int jblocks = sb->image.journal_size, commits = 0;;
- char *why = "";
+ char const *why = "";

warn("Replaying journal");
fieldtype(commit_block, sequence) seq[jblocks];
@@ -1202,14 +1177,6 @@
}
}

-static void save_sb_check(struct superblock *sb)
-{
- commit_deferred_allocs(sb);
- if (dirty_buffer_count)
- warn("%i dirty buffers when all should be clean!", dirty_buffer_count);
- save_sb(sb);
-}
-
/*
* Allocation bitmaps
*/
@@ -1880,45 +1847,6 @@
}

/*
- * Find the given snapshot tag in the list of snapshots in the superblock.
- * Return a pointer to that snapshot entry.
- */
-static struct snapshot *find_snap(struct superblock *sb, u32 tag)
-{
- struct snapshot *snapshot = sb->image.snaplist;
- struct snapshot *end = snapshot + sb->image.snapshots;
-
- for (; snapshot < end; snapshot++)
- if (snapshot->tag == tag)
- return snapshot;
- return NULL;
-}
-
-/*
- * Find the oldest snapshot with 0 usecnt and lowest priority.
- * if no such snapshot exists, find the snapshot with lowest priority
- */
-static struct snapshot *find_victim(struct superblock *sb)
-{
- struct snapshot *snaplist = sb->image.snaplist;
- u32 snapshots = sb->image.snapshots;
-
- assert(snapshots);
- struct snapshot *snap, *best = snaplist;
-
- for (snap = snaplist + 1; snap < snaplist + snapshots; snap++) {
- if (is_squashed(snap))
- continue;
- if (!is_squashed(best) && (usecount(sb, snap) && !usecount(sb, best)))
- continue;
- if (!is_squashed(best) && (!usecount(sb, snap) == !usecount(sb,
best)) && (snap->prio >= best->prio))
- continue;
- best = snap;
- }
- return best;
-}
-
-/*
* Delete all chunks in the B-tree for the snapshot(s) indicated by the
* passed snapshot mask, beginning at the passed chunk.
*
@@ -2095,6 +2023,57 @@
}

/*
+ * Find the given snapshot tag in the list of snapshots in the superblock.
+ * Return a pointer to that snapshot entry.
+ */
+static struct snapshot *find_snap(struct superblock *sb, u32 tag)
+{
+ struct snapshot *snapshot = sb->image.snaplist;
+ struct snapshot *end = snapshot + sb->image.snapshots;
+
+ for (; snapshot < end; snapshot++)
+ if (snapshot->tag == tag)
+ return snapshot;
+ return NULL;
+}
+
+static inline int is_squashed(const struct snapshot *snapshot)
+{
+ return snapshot->bit == SNAPSHOT_SQUASHED;
+}
+
+/* usecount() calculates and returns the usecount for a given snapshot.
+ * The persistent (on disk) usecount is added to the transient usecount
+ * (for devices using the snapshot). */
+static inline u16 usecount(struct superblock *sb, struct snapshot *snap)
+{
+ return (is_squashed(snap) ? 0 : sb->usecount[snap->bit]) + snap->usecount;
+}
+
+/* find the oldest snapshot with 0 usecnt and lowest priority.
+ * if no such snapshot exists, find the snapshot with lowest priority
+ */
+static struct snapshot *find_victim(struct superblock *sb)
+{
+ struct snapshot *snaplist = sb->image.snaplist;
+ u32 snapshots = sb->image.snapshots;
+
+ assert(snapshots);
+ struct snapshot *snap, *best = snaplist;
+
+ for (snap = snaplist + 1; snap < snaplist + snapshots; snap++) {
+ if (is_squashed(snap))
+ continue;
+ if (!is_squashed(best) && (usecount(sb, snap) && !usecount(sb, best)))
+ continue;
+ if (!is_squashed(best) && (!usecount(sb, snap) == !usecount(sb,
best)) && (snap->prio >= best->prio))
+ continue;
+ best = snap;
+ }
+ return best;
+}
+
+/*
* Delete the passed snapshot.
*/
static int delete_snap(struct superblock *sb, struct snapshot *snap)
@@ -2228,7 +2207,7 @@
u64 newchunk;
int i;
u32 snap = cl->tgt_snap;
- struct snapshot *snaplist = sb->image.snaplist;
+ struct snapshot const *snaplist = sb->image.snaplist;
u64 snap_sectors = 0;

for (i = 0; i < sb->image.snapshots; i++)
@@ -2650,7 +2629,7 @@
static unsigned int snapbit_tag(struct superblock *sb, unsigned bit)
{
unsigned int i, n = sb->image.snapshots;
- struct snapshot *snap = sb->image.snaplist;
+ struct snapshot const *snap = sb->image.snaplist;

for (i = 0; i < n; i++)
if (snap[i].bit == bit)
@@ -2741,6 +2720,14 @@

#define SNAPCLIENT_BIT 1

+struct client
+{
+ u64 id;
+ int sock;
+ int snaptag;
+ u32 flags;
+};
+
/*
* Cross-client Locking strategy
*
@@ -3331,8 +3318,16 @@
return 0;
}

-static int init_journal(struct superblock *sb)
+static void save_sb_check(struct superblock *sb)
{
+ commit_deferred_allocs(sb);
+ if (dirty_buffer_count)
+ warn("%i dirty buffers when all should be clean!", dirty_buffer_count);
+ save_sb(sb);
+}
+
+static int init_journal(struct superblock *sb)
+ {
chunk_t metafree = sb->image.metadata.freechunks;
chunk_t snapfree = sb->image.snapdata.freechunks;
for (int i = 0; i < sb->image.journal_size; i++) {
@@ -3477,7 +3472,7 @@

void get_status(struct superblock *sb, unsigned sock)
{
- struct snapshot *snaplist = sb->image.snaplist;
+ struct snapshot const *snaplist = sb->image.snaplist;

unsigned snapshots = sb->image.snapshots;
size_t reply_len = snapshot_details_calc_size(snapshots, snapshots);
@@ -3742,9 +3737,7 @@
trace(warn("got identify request, setting id="U64FMT" snap=%i
(tag=%u), sending chunksize_bits=%u\n",
client->id, client->snap, tag, sb->snapdata.asi->allocsize_bits););
warn("client id %Lx, snaptag %u", client->id, tag);
- // !!! do not pollute the snapshot tag space !!!
- // !!! there is no reason to make 0xffffffff an invalid tag !!!
- // !!! make the identify tag field 64 bits and this works !!!
+
if (tag != (u32)~0UL) {
struct snapshot *snapshot = find_snap(sb, tag);

@@ -4036,7 +4029,7 @@
}
memcpy(&request, message.body, sizeof(request));

- struct snapshot *snaplist = sb->image.snaplist;
+ struct snapshot const *snaplist = sb->image.snaplist;
struct state_message reply;
unsigned int i;

@@ -4055,7 +4048,7 @@
case REQUEST_SNAPSHOT_SECTORS:
{
u32 snap = ((struct status_request *)message.body)->snap;
- struct snapshot *snaplist = sb->image.snaplist;
+ struct snapshot const *snaplist = sb->image.snaplist;
struct snapshot_sectors reply;
char err_msg[MAX_ERRMSG_SIZE];
int i;
@@ -4127,7 +4120,7 @@
free(pe);
break;
}
- default:
+ default:
{
uint32_t proto_err = ERROR_UNKNOWN_MESSAGE;
char *err_msg = "Server received unknown message";

Reply all
Reply to author
Forward
0 new messages