Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965452AbeAMEiw (ORCPT + 1 other); Fri, 12 Jan 2018 23:38:52 -0500 Received: from mail-yb0-f177.google.com ([209.85.213.177]:35734 "EHLO mail-yb0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965415AbeAMEiu (ORCPT ); Fri, 12 Jan 2018 23:38:50 -0500 X-Google-Smtp-Source: ACJfBosEqacuxutI9W4MWaCUzbOVIC0sK5tBz/a1MNxMmJOZ074qz9BgE+3PNSeSkFUbm1U/MjAnvWYuI6IAj9Uw3ik= MIME-Version: 1.0 In-Reply-To: <20180113001902.GA10063@axis.com> References: <20180113001902.GA10063@axis.com> From: Amir Goldstein Date: Sat, 13 Jan 2018 06:38:48 +0200 Message-ID: Subject: Re: overlayfs non-persistent inodes To: Niklas Cassel Cc: Miklos Szeredi , overlayfs , linux-kernel Content-Type: multipart/mixed; boundary="94eb2c18931e16f9560562a0f591" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: --94eb2c18931e16f9560562a0f591 Content-Type: text/plain; charset="UTF-8" On Sat, Jan 13, 2018 at 2:19 AM, Niklas Cassel wrote: > Hello Miklos, Amir > > We are having some problems with inotify + overlayfs. > > If we start to monitor a directory on an overlayfs, > and get into a low memory situation, or if > /proc/sys/vm/drop_caches is called explicitly, > our inotify stops reporting events. > > This appears to be caused by non-persistent inodes. Not "non-persistent" inodes, but "non-unique" inodes. inotify pins overlay inode in memory, but because overlay directory inodes are not hashed in inode cache, after drop caches, if nothing holds a reference to overlay dentry, overlay lookup will allocate a new dentry with a new inode instead of re-using the inotify pinned inode. > > Looking at the commits, it looked like inode numbers > were persistent since commit > b7a807dc2010 ("ovl: persistent inode number for directories"). > Persistent inode *number*, meaning that all non-unique overlay directory inodes have the same inode number - doesn't help inotify. > However, this doesn't seem to take different file systems > into account: > Are you saying that inotify issue is not happening when layers are on same fs? I doubt that. Please try attached patch. Thanks, Amir. --94eb2c18931e16f9560562a0f591 Content-Type: text/x-patch; charset="US-ASCII"; name="0001-ovl-hash-directory-inodes.patch" Content-Disposition: attachment; filename="0001-ovl-hash-directory-inodes.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_jccv3zli0 RnJvbSA5NjM1ZWI4YmZlMjI1NDJhYjU0MzExNjEyNmE1N2E2NTE1NGZiODRlIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBBbWlyIEdvbGRzdGVpbiA8YW1pcjczaWxAZ21haWwuY29tPgpE YXRlOiBNb24sIDEwIEp1bCAyMDE3IDE1OjU1OjU1ICswMzAwClN1YmplY3Q6IFtQQVRDSF0gb3Zs OiBoYXNoIGRpcmVjdG9yeSBpbm9kZXMKCmZzbm90aWZ5IHBpbnMgYSB3YXRjaGVkIGRpcmVjdG9y eSBpbm9kZSBpbiBjYWNoZSwgYnV0IGlmIGRpcmVjdG9yeSBkZW50cnkKaXMgcmVsZWFzZWQsIG5l dyBsb29rdXAgd2lsbCBhbGxvY2F0ZSBhIG5ldyBkZW50cnkgYW5kIGEgbmV3IGlub2RlLgpEaXJl Y3RvcnkgZXZlbnRzIHdpbGwgYmUgbm90aWZpZWQgb24gdGhlIG5ldyBpbm9kZSwgd2hpbGUgZnNu b2l0eSBsaXN0ZW5lcgppcyB3YXRjaGluZyB0aGUgb2xkIHBpbm5lZCBpbm9kZS4KCkhhc2ggYWxs IGRpcmVjdG9yeSBpbm9kZXMgdG8gcmV1c2UgdGhlIHBpbm5lZCBpbm9kZSBvbiBsb29rdXAuIFB1 cmUgdXBwZXIKZGlycyBhcmUgaGFzaGVzIGJ5IHJlYWwgdXBwZXIgaW5vZGUsIG1lcmdlIGFuZCBs b3dlciBkaXJzIGFyZSBoYXNoZWQgYnkKcmVhbCBsb3dlciBpbm9kZS4KClRoZSByZWZlcmVuY2Ug dG8gbG93ZXIgaW5vZGUgd2FzIGJlaW5nIGhlbGQgYnkgdGhlIGxvd2V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