public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Steve Dickson <SteveD@RedHat.com>
To: Alice Mitchell <ajmitchell@redhat.com>,
	Linux NFS Mailing list <linux-nfs@vger.kernel.org>
Subject: Re: [RFC PATCH 0/1] Enable config.d directory to be processed.
Date: Mon, 2 Nov 2020 09:23:01 -0500	[thread overview]
Message-ID: <4836616f-3aa6-d0bd-22db-cd7fecf4dce9@RedHat.com> (raw)
In-Reply-To: <6f3caf91-296c-0aa8-ba41-bc35d500adaa@RedHat.com>

Hello,

On 11/2/20 8:24 AM, Steve Dickson wrote:
>> You would need to write an equivalent of conf_load_file() that created
>> a new transaction id and read in all the files before committing them
>> to do it this way.
> I kinda do think we should be able to read in multiple files...
> If that free was not done until all the files are read in, would something
> like that work? I guess I'm ask how difficult would be to re-work
> the code to do something like this. 
> 
Something similar to this... load all the files under the same trans id:
(Compiled tested):
diff --git a/support/nfs/conffile.c b/support/nfs/conffile.c
index c60e511..f003fe1 100644
--- a/support/nfs/conffile.c
+++ b/support/nfs/conffile.c
@@ -578,6 +578,30 @@ static void conf_free_bindings(void)
 	}
 }
 
+static int
+conf_load_files(int trans, const char *conf_file)
+{
+	char *conf_data;
+	char *section = NULL;
+	char *subsection = NULL;
+
+	conf_data = conf_readfile(conf_file);
+	if (conf_data == NULL)
+		return 1;
+
+	/* Load default configuration values.  */
+	conf_load_defaults();
+
+	/* Parse config contents into the transaction queue */
+	conf_parse(trans, conf_data, &section, &subsection, conf_file);
+	if (section) 
+		free(section);
+	if (subsection) 
+		free(subsection);
+	free(conf_data);
+
+	return 0;
+}
 /* Open the config file and map it into our address space, then parse it.  */
 static int
 conf_load_file(const char *conf_file)
@@ -616,6 +640,7 @@ conf_init_dir(const char *conf_file)
 	struct dirent **namelist = NULL;
 	char *dname, fname[PATH_MAX + 1];
 	int n = 0, nfiles = 0, i, fname_len, dname_len;
+	int trans;
 
 	dname = malloc(strlen(conf_file) + 3);
 	if (dname == NULL) {
@@ -637,6 +662,7 @@ conf_init_dir(const char *conf_file)
 		return nfiles;
 	}
 
+	trans = conf_begin();
 	dname_len = strlen(dname);
 	for (i = 0; i < n; i++ ) {
 		struct dirent *d = namelist[i];
@@ -660,11 +686,17 @@ conf_init_dir(const char *conf_file)
 		}
 		sprintf(fname, "%s/%s", dname, d->d_name);
 
-		if (conf_load_file(fname))
+		if (conf_load_files(trans, fname))
 			continue;
 		nfiles++;
 	}
 
+	/* Free potential existing configuration.  */
+	conf_free_bindings();
+
+	/* Apply the new configuration values */
+	conf_end(trans, 1);
+
 	for (i = 0; i < n; i++)
 		free(namelist[i]);
 	free(namelist);


  reply	other threads:[~2020-11-02 14:25 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-29 21:04 [RFC PATCH 0/1] Enable config.d directory to be processed Steve Dickson
2020-10-29 21:04 ` [PATCH 1/1] conffile: process config.d directory config files Steve Dickson
2020-11-02 13:03 ` [RFC PATCH 0/1] Enable config.d directory to be processed Alice Mitchell
2020-11-02 13:24   ` Steve Dickson
2020-11-02 14:23     ` Steve Dickson [this message]
2020-11-02 15:05       ` Alice Mitchell
2020-11-02 15:16         ` Chuck Lever
2020-11-02 16:37           ` Steve Dickson
2020-11-02 16:42         ` Steve Dickson
2020-11-02 15:57       ` Alice Mitchell
2020-11-02 19:42         ` Steve Dickson
2020-11-02 22:01           ` McIntyre, Vincent (CASS, Marsfield)
2020-11-03 10:14           ` Alice Mitchell
2020-11-03 17:16             ` Steve Dickson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4836616f-3aa6-d0bd-22db-cd7fecf4dce9@RedHat.com \
    --to=steved@redhat.com \
    --cc=ajmitchell@redhat.com \
    --cc=linux-nfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox