mirror of
https://github.com/samba-team/samba.git
synced 2025-08-03 04:22:09 +03:00
s3:net: wrap net conf import into one big transaction
This speeds up "net conf import" of a file with 2000 shares from 11 minutest to 1m50s on my box. Michael
This commit is contained in:
@ -331,6 +331,12 @@ static int net_conf_import(struct net_context *c, struct smbconf_ctx *conf_ctx,
|
|||||||
"would import the following configuration:\n\n");
|
"would import the following configuration:\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
werr = smbconf_transaction_start(conf_ctx);
|
||||||
|
if (!W_ERROR_IS_OK(werr)) {
|
||||||
|
d_printf("error starting transaction: %s\n", win_errstr(werr));
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
if (servicename != NULL) {
|
if (servicename != NULL) {
|
||||||
struct smbconf_service *service = NULL;
|
struct smbconf_service *service = NULL;
|
||||||
|
|
||||||
@ -338,11 +344,11 @@ static int net_conf_import(struct net_context *c, struct smbconf_ctx *conf_ctx,
|
|||||||
servicename,
|
servicename,
|
||||||
&service);
|
&service);
|
||||||
if (!W_ERROR_IS_OK(werr)) {
|
if (!W_ERROR_IS_OK(werr)) {
|
||||||
goto done;
|
goto cancel;
|
||||||
}
|
}
|
||||||
werr = import_process_service(c, conf_ctx, service);
|
werr = import_process_service(c, conf_ctx, service);
|
||||||
if (!W_ERROR_IS_OK(werr)) {
|
if (!W_ERROR_IS_OK(werr)) {
|
||||||
goto done;
|
goto cancel;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
struct smbconf_service **services = NULL;
|
struct smbconf_service **services = NULL;
|
||||||
@ -352,24 +358,39 @@ static int net_conf_import(struct net_context *c, struct smbconf_ctx *conf_ctx,
|
|||||||
&num_shares,
|
&num_shares,
|
||||||
&services);
|
&services);
|
||||||
if (!W_ERROR_IS_OK(werr)) {
|
if (!W_ERROR_IS_OK(werr)) {
|
||||||
goto done;
|
goto cancel;
|
||||||
}
|
}
|
||||||
if (!c->opt_testmode) {
|
if (!c->opt_testmode) {
|
||||||
werr = smbconf_drop(conf_ctx);
|
werr = smbconf_drop(conf_ctx);
|
||||||
if (!W_ERROR_IS_OK(werr)) {
|
if (!W_ERROR_IS_OK(werr)) {
|
||||||
goto done;
|
goto cancel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (sidx = 0; sidx < num_shares; sidx++) {
|
for (sidx = 0; sidx < num_shares; sidx++) {
|
||||||
werr = import_process_service(c, conf_ctx,
|
werr = import_process_service(c, conf_ctx,
|
||||||
services[sidx]);
|
services[sidx]);
|
||||||
if (!W_ERROR_IS_OK(werr)) {
|
if (!W_ERROR_IS_OK(werr)) {
|
||||||
goto done;
|
goto cancel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
werr = smbconf_transaction_commit(conf_ctx);
|
||||||
|
if (!W_ERROR_IS_OK(werr)) {
|
||||||
|
d_printf("error committing transaction: %s\n",
|
||||||
|
win_errstr(werr));
|
||||||
|
} else {
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
goto done;
|
||||||
|
|
||||||
|
cancel:
|
||||||
|
werr = smbconf_transaction_cancel(conf_ctx);
|
||||||
|
if (!W_ERROR_IS_OK(werr)) {
|
||||||
|
d_printf("error cancelling transaction: %s\n",
|
||||||
|
win_errstr(werr));
|
||||||
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
TALLOC_FREE(mem_ctx);
|
TALLOC_FREE(mem_ctx);
|
||||||
|
Reference in New Issue
Block a user