Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/share/examples/puffs/pgfs reduce number of SQL statements fo...
details: https://anonhg.NetBSD.org/src/rev/a28ee49a6dfc
branches: trunk
changeset: 778734:a28ee49a6dfc
user: yamt <yamt%NetBSD.org@localhost>
date: Wed Apr 11 14:26:19 2012 +0000
description:
reduce number of SQL statements for inactivate
diffstat:
share/examples/puffs/pgfs/newfs.sql | 4 ++--
share/examples/puffs/pgfs/pgfs_puffs.c | 15 +++------------
share/examples/puffs/pgfs/pgfs_subs.c | 34 +++++++++++++++++++++++-----------
share/examples/puffs/pgfs/pgfs_subs.h | 4 ++--
4 files changed, 30 insertions(+), 27 deletions(-)
diffs (148 lines):
diff -r 85574b0dcf98 -r a28ee49a6dfc share/examples/puffs/pgfs/newfs.sql
--- a/share/examples/puffs/pgfs/newfs.sql Wed Apr 11 14:25:54 2012 +0000
+++ b/share/examples/puffs/pgfs/newfs.sql Wed Apr 11 14:26:19 2012 +0000
@@ -1,4 +1,4 @@
--- $NetBSD: newfs.sql,v 1.1 2011/10/12 01:05:00 yamt Exp $
+-- $NetBSD: newfs.sql,v 1.2 2012/04/11 14:26:19 yamt Exp $
-- Copyright (c)2010,2011 YAMAMOTO Takashi,
-- All rights reserved.
@@ -71,7 +71,7 @@
-- datafork table maintains the association between our files and its backing
-- large objects.
CREATE TABLE datafork (
- fileid fileid PRIMARY KEY REFERENCES file,
+ fileid fileid PRIMARY KEY, -- REFERENCES file
loid Oid NOT NULL UNIQUE);
-- we want the following but lo lives in system catalogs.
-- loid REFERENCES pg_largeobject_metadata(oid);
diff -r 85574b0dcf98 -r a28ee49a6dfc share/examples/puffs/pgfs/pgfs_puffs.c
--- a/share/examples/puffs/pgfs/pgfs_puffs.c Wed Apr 11 14:25:54 2012 +0000
+++ b/share/examples/puffs/pgfs/pgfs_puffs.c Wed Apr 11 14:26:19 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pgfs_puffs.c,v 1.2 2012/04/11 14:25:54 yamt Exp $ */
+/* $NetBSD: pgfs_puffs.c,v 1.3 2012/04/11 14:26:19 yamt Exp $ */
/*-
* Copyright (c)2010,2011 YAMAMOTO Takashi,
@@ -32,7 +32,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: pgfs_puffs.c,v 1.2 2012/04/11 14:25:54 yamt Exp $");
+__RCSID("$NetBSD: pgfs_puffs.c,v 1.3 2012/04/11 14:26:19 yamt Exp $");
#endif /* not lint */
#include <assert.h>
@@ -720,7 +720,6 @@
{
struct Xconn *xc;
fileid_t fileid = cookie_to_fileid(opc);
- struct vattr va;
int error;
/*
@@ -734,18 +733,10 @@
DPRINTF("%llu\n", fileid);
retry:
xc = begin(pu);
- error = getattr(xc, fileid, &va, GETATTR_NLINK|GETATTR_TYPE);
+ error = cleanupfile(xc, fileid);
if (error != 0) {
- DPRINTF("%llu GETATTR fail\n", fileid);
goto got_error;
}
- if (va.va_nlink == 0) {
- DPRINTF("%llu nlink=0\n", fileid);
- error = cleanupfile(xc, fileid, &va);
- if (error != 0) {
- goto got_error;
- }
- }
error = commit(xc);
if (error != 0) {
goto got_error;
diff -r 85574b0dcf98 -r a28ee49a6dfc share/examples/puffs/pgfs/pgfs_subs.c
--- a/share/examples/puffs/pgfs/pgfs_subs.c Wed Apr 11 14:25:54 2012 +0000
+++ b/share/examples/puffs/pgfs/pgfs_subs.c Wed Apr 11 14:26:19 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pgfs_subs.c,v 1.3 2011/10/13 14:40:06 yamt Exp $ */
+/* $NetBSD: pgfs_subs.c,v 1.4 2012/04/11 14:26:19 yamt Exp $ */
/*-
* Copyright (c)2010,2011 YAMAMOTO Takashi,
@@ -46,7 +46,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: pgfs_subs.c,v 1.3 2011/10/13 14:40:06 yamt Exp $");
+__RCSID("$NetBSD: pgfs_subs.c,v 1.4 2012/04/11 14:26:19 yamt Exp $");
#endif /* not lint */
#include <assert.h>
@@ -785,18 +785,31 @@
}
int
-cleanupfile(struct Xconn *xc, fileid_t fileid, struct vattr *va)
+cleanupfile(struct Xconn *xc, fileid_t fileid)
{
static struct cmd *c;
+ char *type;
+ unsigned int vtype;
+ int error;
- /*
- * XXX what to do when the filesystem is shared?
- */
-
- if (va->va_type == VREG || va->va_type == VLNK) {
+ CREATECMD(c, "DELETE FROM file WHERE fileid = $1 AND nlink = 0 "
+ "RETURNING type::text", INT8OID);
+ error = sendcmd(xc, c, fileid);
+ if (error != 0) {
+ return error;
+ }
+ error = simplefetch(xc, TEXTOID, &type);
+ if (error == ENOENT) {
+ return 0; /* probably nlink > 0 */
+ }
+ if (error != 0) {
+ return error;
+ }
+ vtype = tovtype(type);
+ free(type);
+ if (vtype == VREG || vtype == VLNK) {
static struct cmd *c_datafork;
int32_t ret;
- int error;
CREATECMD(c_datafork,
"WITH loids AS (DELETE FROM datafork WHERE fileid = $1 "
@@ -814,8 +827,7 @@
return EIO; /* lo_unlink failed */
}
}
- CREATECMD(c, "DELETE FROM file WHERE fileid = $1", INT8OID);
- return simplecmd(xc, c, fileid);
+ return 0;
}
/*
diff -r 85574b0dcf98 -r a28ee49a6dfc share/examples/puffs/pgfs/pgfs_subs.h
--- a/share/examples/puffs/pgfs/pgfs_subs.h Wed Apr 11 14:25:54 2012 +0000
+++ b/share/examples/puffs/pgfs/pgfs_subs.h Wed Apr 11 14:26:19 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pgfs_subs.h,v 1.1 2011/10/12 01:05:00 yamt Exp $ */
+/* $NetBSD: pgfs_subs.h,v 1.2 2012/04/11 14:26:19 yamt Exp $ */
/*-
* Copyright (c)2010,2011 YAMAMOTO Takashi,
@@ -68,6 +68,6 @@
uid_t, gid_t, fileid_t *);
int mklinkfile_lo(struct Xconn *, fileid_t, const char *, enum vtype, mode_t,
uid_t, gid_t, fileid_t *, int *);
-int cleanupfile(struct Xconn *, fileid_t, struct vattr *);
+int cleanupfile(struct Xconn *, fileid_t);
int check_path(struct Xconn *, fileid_t, fileid_t);
int isempty(struct Xconn *, fileid_t, bool *);
Home |
Main Index |
Thread Index |
Old Index