Skip to content

WIP: Lustre plugin for gufi_dir2index #170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

bertschinger
Copy link
Contributor

@bertschinger bertschinger commented Mar 25, 2025

This is a work-in-progress change that adds the ability to pass a plugin library to run user-specific code during gufi_dir2index.

The plugin included here does some simple gathering of Lustre stripe information and stores it into the sqlite3 database.

@calccrypto
Copy link
Collaborator

Can you also add a simple test plugin + tests?

int rc = llapi_file_get_stripe(path, layout_info);

if (rc) {
printf("lustre plugin: error getting stripe info for %s: %s\n", path, strerror(errno));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stderr

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

errno should be copied before being used

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

errno should be copied before being used

What's the reasoning for that?

Copy link
Collaborator

@calccrypto calccrypto Mar 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While in this case you're probably fine, people tend to call other functions that they don't realize change errno, and end up getting prints that say that there are no errors even though they entered an error block. The way to prevent this is to copy errno so that side effects don't mess up the call to strerror. I forget what I was doing, but I've seen this happen recently.

src/utils.c Outdated
return 0;
}

void *lib = dlopen(in->plugin_name.data, RTLD_NOW);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does dlclose need to be called?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is unloading shared libraries normal practice? Valgrind, at least, doesn't seem to perceive it as a resource leak...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I have a habit of closing things I open.

This is needed for dynamically loading plugins that use sqlite3
functions.

GUFI binaries are built with the sqlite3 object file statically linked.
When a plugin is loaded that calls sqlite3 functons, it must refer to
the definitions of the sqlite3 symbols that live in the GUFI binary that
the plugin is loaded into.

The `-export-dynamic` linker option makes the GUFI binaries export these
symbols so that the plugin is able to resolve them correctly.
This enables the user to run custom code during database generation. The
user can populate the database with new tables, modify entries, etc.
Copy link

codecov bot commented Mar 27, 2025

Codecov Report

Attention: Patch coverage is 11.53846% with 23 lines in your changes missing coverage. Please review.

Project coverage is 91.06%. Comparing base (6d5998e) to head (7c2f11e).

Files with missing lines Patch % Lines
src/bf.c 11.76% 15 Missing ⚠️
src/gufi_dir2index.c 11.11% 4 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #170      +/-   ##
==========================================
- Coverage   91.32%   91.06%   -0.26%     
==========================================
  Files          57       57              
  Lines        8376     8398      +22     
  Branches     1109     1116       +7     
==========================================
- Hits         7649     7648       -1     
- Misses        451      470      +19     
- Partials      276      280       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bertschinger
Copy link
Contributor Author

Can you also add a simple test plugin + tests?

Yep, I'll work on that next.

*
* $ cd contrib
*
* $ gcc -g -O0 -c -fPIC -I../build/deps/sqlite3/include -I../include -I$LUSTRE_INCLUDE_DIR -I$LUSTRE_INCLUDE_DIR/uapi lustre_plugin.c
Copy link
Collaborator

@calccrypto calccrypto Mar 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

../build/deps/sqlite3/include -> "${DEP_INSTALL_PREFIX}/sqlite3/include"

*
* Returns 0 on success or 1 on failure.
*/
int load_plugin_library(struct input *in, char *plugin_name) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static

IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 empty lines

Comment on lines +74 to +76
* $ gcc -g -O0 -c -fPIC -I../build/deps/sqlite3/include -I../include -I$LUSTRE_INCLUDE_DIR -I$LUSTRE_INCLUDE_DIR/uapi lustre_plugin.c
*
* $ gcc -shared -o liblustre_plugin.so lustre_plugin.o -L$LUSTRE_LIBRARY_DIR -llustreapi
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add to CMake

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants