#19 reflink: set metadata for hardlinked files
Merged a month ago by dcavalca. Opened 2 months ago by teknoraver.
rpms/ teknoraver/rpm c9s-sig-hyperscale  into  c9s-sig-hyperscale

@@ -0,0 +1,30 @@ 

+ From 3310d203e0aa162428c7b9dc1e9d8e09da768608 Mon Sep 17 00:00:00 2001

+ From: Matteo Croce <teknoraver@meta.com>

+ Date: Sat, 14 Sep 2024 09:32:48 -0700

+ Subject: [PATCH] reflink: set metadata for hardlinked files

+ 

+ RPM deduplicates identical files by creating them as hardlinks.

+ Since metadata is shared between copies, permissions are set when

+ extracting the last copy.

+ This breaks reflinks, where each copy has its own metadata.

+ Fix it by always set metadata when the file content is handled by a plugin.

+ ---

+  lib/fsm.c | 2 ++

+  1 file changed, 2 insertions(+)

+ 

+ diff --git a/lib/fsm.c b/lib/fsm.c

+ index 05c5bcf..e562220 100644

+ --- a/lib/fsm.c

+ +++ b/lib/fsm.c

+ @@ -1010,6 +1010,8 @@ int rpmPackageFilesInstall(rpmts ts, rpmte te, rpmfiles files,

+  		rc = plugin_rc;

+  	    } else if(plugin_rc == RPMRC_PLUGIN_CONTENTS){

+  		rc = RPMRC_OK;

+ +		/* The reflink plugins handles hardlink differently, metadata has to be set. */

+ +		fp->setmeta = 1;

+  	    } else if (S_ISREG(fp->sb.st_mode)) {

+  		if (rc == RPMERR_ENOENT) {

+  		    rc = fsmMkfile(di.dirfd, fi, fp, files, psm, nodigest,

+ -- 

+ 2.43.5

+ 

file modified
+5 -1
@@ -32,7 +32,7 @@ 

  

  %global rpmver 4.16.1.3

  #global snapver rc1

- %global rel 34.1

+ %global rel 34.2

  %global sover 9

  

  %global srcver %{rpmver}%{?snapver:-%{snapver}}
@@ -185,6 +185,7 @@ 

  Patch9935: 0035-rpmcow-fix-segfault-in-rpm2extents.patch

  Patch9936: 0036-bsearchr_static.patch

  Patch9937: 0037-plugin_path.patch

+ Patch9938: 0038-reflink-set-metadata-for-hardlinked-files.patch

  Provides: rpm(pr1470)

  Provides: rpm(pr1470_1)

  
@@ -763,6 +764,9 @@ 

  %doc doc/librpm/html/*

  

  %changelog

+ * Sat Sep 14 2024 Matteo Croce <teknoraver@meta.com> - 4.16.1.3-34.2

+ - Fix deduplication error in RPM CoW

+ 

  * Tue Aug 20 2024 Matteo Croce <teknoraver@meta.com> - 4.16.1.3-34.1

  - Backport fix from upstream

  

RPM deduplicates identical files by creating them as hardlinks.
Since metadata is shared between copies, permissions are set when
extracting the last copy.
This breaks reflinks, where each copy has its own metadata.
Fix it by always set metadata when the file content is handled by a plugin.

lgtm, but you should upstream this to RPM itself as it looks relevant regardless on CoW

Pull-Request has been merged by dcavalca

a month ago