add audit flushing by demand. lctl flush_audit <mountpoint> will flush audit messages to syslog
#define AUDIT_FAIL AUDIT_MAX
#define AUDIT_DIR (AUDIT_MAX + 1)
#define AUDIT_FS (AUDIT_MAX + 2)
+#define AUDIT_SYNC (AUDIT_MAX + 3)
#define AUD_BIT(a) (1 << a)
sbi->ll_audit_mask = arg;
exp = ll_i2dtexp(inode);
rc = obd_set_info(exp, 5, "audit", sizeof(msg), &msg);
+ } else if (IS_AUDIT_OP(arg, AUDIT_SYNC)) {
+ exp = ll_i2dtexp(inode);
+ rc = obd_set_info(exp, 5, "audit", sizeof(msg), &msg);
} else {
lli->lli_audit_mask = arg;
}
int i;
LASSERT(mds < lmv->desc.ld_tgt_count);
- if (IS_AUDIT_OP(msg->attr, AUDIT_FS)) {
+ if (IS_AUDIT_OP(msg->attr, AUDIT_FS) ||
+ IS_AUDIT_OP(msg->attr, AUDIT_SYNC)) {
//FS audit, send message to all mds
for (i = 0; i < lmv->desc.ld_tgt_count;i++) {
obd_set_info(lmv->tgts[i].ltd_exp,
ENTRY;
+ if (IS_AUDIT_OP((*mask), AUDIT_SYNC)) {
+ struct audit_priv *priv;
+
+ priv = smfs_get_plg_priv(S2SMI(sb), SMFS_PLG_AUDIT);
+ if (priv)
+ audit_notify(priv->audit_ctxt->loc_handle, NULL);
+ //to wait for flush
+ return audit_notify(NULL, NULL);
+ }
if (IS_AUDIT_OP((*mask), AUDIT_FS))
return smfs_set_fs_audit(sb, mask);
static int transferd_users = 0;
char *buf = NULL;
+static int transferd_check(struct transferd_ctl *tc)
+{
+ int rc = 0;
+ ENTRY;
+
+ if (test_bit(TRANSFERD_STOP, &tc->tc_flags))
+ RETURN(1);
+
+ spin_lock(&tc->tc_lock);
+ rc = list_empty(&tc->tc_list) ? 0 : 1;
+ spin_unlock(&tc->tc_lock);
+
+ RETURN(rc);
+}
+
int audit_notify(struct llog_handle *llh, void * arg)
{
struct transfer_item *ti;
+ struct list_head tmp_list;
ENTRY;
down(&transferd_sem);
spin_unlock(&transferd_tc.tc_lock);
wake_up(&transferd_tc.tc_waitq);
+
+ if (llh == NULL) /* demand to flush list */
+ {
+ struct l_wait_info lwi = { 0 };
+ l_wait_event(transferd_tc.tc_waitq,
+ transferd_check(&transferd_tc), &lwi);
+ }
RETURN(0);
}
struct llog_handle *llh = ti->ti_llh;
int rc = 0;
ENTRY;
+
+ if (!llh)
+ RETURN(0);
rc = llog_cat_process(llh, (llog_cb_t)&transfer_cb, ti->id2name);
if (rc)
RETURN(0);
}
-static int transferd_check(struct transferd_ctl *tc)
-{
- int rc = 0;
- ENTRY;
-
- if (test_bit(TRANSFERD_STOP, &tc->tc_flags))
- RETURN(1);
-
- spin_lock(&tc->tc_lock);
- rc = list_empty(&tc->tc_list) ? 0 : 1;
- spin_unlock(&tc->tc_lock);
-
- RETURN(rc);
-}
-
static int transferd(void *arg)
{
struct transferd_ctl *tc = arg;
return set_audit(argc, argv, 1);
}
+static int jt_flush_audit(int argc, char **argv)
+{
+ __u64 mask = 0;
+ int rc, fd;
+
+ if (argc != 2)
+ return CMD_HELP;
+
+ //open file/dir
+ fd = open(argv[1], O_RDONLY);
+ if (fd < 0) {
+ fprintf(stderr, "can't open: %s: %s\n", argv[1],
+ strerror(rc = errno));
+ return -1;
+ }
+
+ SET_AUDIT_OP(mask, AUDIT_SYNC);
+
+ rc = ioctl(fd, LL_IOC_AUDIT, mask);
+ close(fd);
+ return rc;
+}
+
/*
* XXX Should not belong to here
*/
"usage: audit type operations filename\n"},
{"fs_audit", jt_set_fsaudit, 0,
"usage: fs_audit type operations mountpoint\n"},
+ {"flush_audit", jt_flush_audit, 0,
+ "usage: flush_audit mountpoin\n"},
{"lsync", jt_obd_reint_sync, 0,
"usage: lsync\n"},
{"cache_on", jt_obd_cache_on, 0,